Expand description
Experience-memory tier (DocTrace, arXiv:2606.10921).
DocTrace’s two-tier idea: tier 1 is the raw memory store (everything mnemo already does); tier 2 is an experience memory that caches a successful retrieval/reasoning plan — the query signature, the steps taken, the chunks that led to a confirmed-good outcome, and an outcome score — and replays that plan when a structurally-similar query recurs, instead of re-running full retrieval from scratch.
This is implemented as a mode, not a new store: plans are
persisted as ordinary [MemoryRecord]s carrying the reserved
EXPERIENCE_PLAN_TAG with the plan payload in metadata. That
buys backend-agnosticism (DuckDB + PostgreSQL, unchanged schema) and
RBAC/consent (scope + ACL) for free, and lets the existing
remember write-path handle hashing, embedding, and audit events.
§Two new ops (gated)
REMEMBER_PLAN(execute_remember_plan): persist a plan, but only when itsoutcome_scoreclearsDEFAULT_SUCCESS_THRESHOLD— failures are never cached.RECALL_PLAN(execute_recall_plan): on a new query, return the best stored plan whose query signature matches above a similarity threshold, or a miss.
Both are gated behind MnemoEngine::with_experience_memory; with
the mode off (the default) REMEMBER_PLAN is a validation error
and RECALL_PLAN always misses, so default behaviour is unchanged.
Plan records are also excluded from ordinary recall (they are
replayed only via RECALL_PLAN).
§Signature & similarity
A query signature is its normalized significant-token set
(signature_tokens); structural similarity is the
jaccard overlap of two signatures. This is deterministic and
backend-/embedder-agnostic (works under NoopEmbedding), which is
what the v0 replay gate needs; a learned signature is a later knob.
Structs§
- Cached
Plan - A replayable plan plus the similarity that matched it.
- Plan
Payload - The cached plan payload, serialized into the record
metadata. - Recall
Plan Request RECALL_PLANinput.- Recall
Plan Response RECALL_PLANoutput.- Remember
Plan Request REMEMBER_PLANinput.- Remember
Plan Response REMEMBER_PLANoutput.
Constants§
- DEFAULT_
SIMILARITY_ THRESHOLD - Default Jaccard threshold above which a stored plan is replayed.
- DEFAULT_
SUCCESS_ THRESHOLD - Plans scoring below this outcome are treated as failures and never cached.
- EXPERIENCE_
PLAN_ TAG - Reserved tag stamped on every experience-tier plan record. Plans are
excluded from ordinary
recalland read back only viaRECALL_PLAN. - PLAN_
METADATA_ KEY - Metadata key under which the
PlanPayloadis serialized.
Functions§
- execute_
recall_ plan RECALL_PLAN— return the best replayable plan for a query, or a miss.- execute_
remember_ plan REMEMBER_PLAN— persist a successful plan into the experience tier.- jaccard
- Jaccard overlap
|A∩B| / |A∪B|of two signature token sets. Returns0.0when both are empty. - signature_
tokens - Normalize a query into its signature token set: lowercase, split on non-alphanumerics, drop tokens shorter than 3 chars, dedup, and sort so the signature is order-independent.