Supported
Reviewed workflows and cached answers¶
Contract¶
Match state |
Reuse decision |
|---|---|
Similar, reviewed, authorized, and fresh |
Reuse cached answer or procedure |
Similar and stale |
Retrieve and recompute |
Similar and outside allowed documents |
Ignore before scoring |
Below similarity threshold |
Run the normal workflow |
Cache quality depends on caller-provided query vectors and the threshold. Mari places authorization and freshness checks on the decision path.
Example cache decisions
Similarity |
Dependencies |
Review state |
Decision |
|---|---|---|---|
Above threshold |
Fresh and readable |
Approved |
Reuse |
Above threshold |
Stale |
Approved |
Reject |
Above threshold |
Unauthorized |
Approved |
Reject |
Highest score |
Fresh |
Unreviewed |
Reject. Consider lower approved match |
0.00run normally
0.72start retrieval
0.95consider reuse
1.00
from mari_kit.trajectories import (
WorkflowPolicy, build_reviewed_workflow_index, decide_reviewed_workflow,
)
index = build_reviewed_workflow_index(reviewed_workflows)
decision = decide_reviewed_workflow(query_vectors, index, current_revisions,
policy=WorkflowPolicy(speculation_threshold=0.72, cache_threshold=0.95),
allowed_document_ids=authorized_document_ids)
Related APIs: match_reviewed_workflow, start_speculative_retrieval, match_cached_response, and workflow_freshness. Reuse requires a strong match plus fresh, authorized dependencies.
Research basis
GPTCache: semantic caching for language-model queriesBuild Systems à la Carte: dependency-valid reuse
The two thresholds, authorization gate, and exact freshness condition are Mari policy.
Reviewed workflow indexes match new requests to approved intents. Separate policy thresholds control speculative retrieval and direct cached-response reuse.
How it works¶
Build an index from reviewed workflow intent vectors. At query time, compute normalized similarity and filter workflows by dependency authorization. Choose the best match with stable ties. The lower threshold makes speculative retrieval eligible. The higher threshold makes reuse eligible. A cached response requires fresh exact evidence dependencies. ACL and revision checks govern the final decision.