Expand description
v0.7.0 Gap 3 (#886) — recall-consumption observation tier.
The Batman 6-form audit closeout flagged a missing “what did the
caller actually use after we ranked it” feedback channel: recall
ranking telemetry stops at the recall response, so the substrate
cannot tell which candidates the caller subsequently cited in a
memory_store or memory_link payload. This module is the
write-side half of the closeout:
record_recall— at the end of everymemory_recallcall, the dispatcher writes one ledger row per returned candidate (recall_id + memory_id + retriever + rank + score). The recall_id is a fresh UUID returned in the response so the caller can echo it back on a later store/link.mark_consumed— when amemory_storeormemory_linkrequest cites arecall_id+memory_idslist, the matching rows flipconsumed = TRUEand capture theconsumed_by_memory_idFK of the row that did the citing.
Read-side is exposed via the gc submodule (TTL prune) and the
memory_recall_observations MCP tool defined in
crate::mcp::tools::recall_observations.
§Schema
recall_observations (migration 0038_v07_recall_observations.sql,
schema v47) is the backing table. Composite primary key
(recall_id, memory_id) keeps the substrate idempotent under
duplicate writes (an exact replay of the same recall is a no-op,
not a UNIQUE-violation refusal).
Modules§
- gc
- v0.7.0 Gap 3 (#886) —
recall_observationsTTL pruner.
Structs§
- Candidate
- One candidate row passed to
record_recall. - Observation
- One row of
recall_observationsas it travels over the read-side MCPmemory_recall_observationstool. Mirrors the SQL columns 1:1 plus a derivedconsumedboolean (the SQL column is an INTEGER 0/1).
Functions§
- list_
observations - Read-side query for the
memory_recall_observationsMCP tool. - mark_
consumed - Flip the
consumedflag (and captureconsumed_at+consumed_by_memory_id) for every(recall_id, memory_id)pair wherememory_idis incited_memory_ids. Idempotent — replaying the same call is a no-op because the WHERE clause requiresconsumed = 0. - parse_
cite_ batch - Convenience helper used by the MCP store/link consume hook: read
the
recall_id+cited_memory_idsarray out of an MCP requestparamsValue. Both must be present for a cite-batch to fire. - record_
recall - Write one
recall_observationsrow percandidatesentry under a singlerecall_id. The call is best-effort: a SQL error during insertion logs at warn level and continues, since the substrate MUST NOT block a successful recall response on a failed audit write. - table_
exists - Probe whether the
recall_observationstable exists on this connection. Used by the recall-side instrumentation as a soft gate so a pre-v47 database doesn’t blow up the recall response when the binary briefly precedes the migration apply (the migration runs at open time, so this is only relevant for hand-rolledConnection::opentest fixtures that skipcrate::storage::open). - try_
mark_ consumed_ from_ params - Best-effort wrapper around
mark_consumedused by thehandle_store/handle_linkhot paths: parses the cite batch, invokes the SQL update, and logs (rather than propagates) any substrate error. The recall ledger MUST NOT block the underlying write — it’s an audit trail, not a precondition.