Skip to main content

Module retrieval

Module retrieval 

Source
Expand description

v0.4.4 — RetrievalMode typed enum + 5 starter HarnessAware adapters.

§What this module is

A typed superset of the existing RecallRequest::strategy: Option<String> field, plus a new HarnessAware variant that lets the recall response envelope be reshaped per agent harness (Claude Code, Codex, Gemini CLI, Chronos, generic) per the framing in arXiv 2605.15184: “overall scores still depend strongly on which harness and tool-calling style is used, even when the underlying conversation data are the same.”

§Backwards-compatible introduction

RecallRequest gains an optional mode: Option<RetrievalMode> field in this release. The legacy strategy: Option<String> field stays in place; if mode is set it takes precedence, otherwise the engine continues to parse strategy exactly as before. Existing SDK callers (Python mnemo-db, TypeScript @mndfreek/mnemo-sdk, Go mnemo.Recall) continue to work unchanged because they all marshal through the string-typed field.

§HarnessAware semantics

HarnessAware { harness, format } does NOT change which records are retrieved — under the hood it delegates to the default HybridRrf retrieval path. What it changes is how the crate::query::recall::ScoredMemory hits are shaped into a string envelope that a specific agent harness prefers (inline fenced blocks, file-based side-channel pointers with line numbers, generic line-numbered list, …). The HarnessEnvelope::shape method returns the rendered envelope string; the recall response continues to carry the typed ScoredMemory hits so downstream consumers that want the typed payload are not blocked.

§Not in scope for v0.4.4

  • No SDK ripple. The Python / TypeScript / Go SDKs are NOT updated in this release. They continue to use the string-typed strategy field. SDK migration to a typed mode field is a follow-up tracked separately.
  • No REST / gRPC / pgwire schema bump. The new mode field serialises through the same RecallRequest Serde definition; inbound JSON that omits mode continues to work.
  • No envelope-trait stabilisation. The HarnessEnvelope trait + the five adapter structs are intentionally minimal — each adapter produces a deterministic string with the shape the corresponding harness expects, but the contents of those strings are not a stability surface in v0.4.4. Operators relying on a specific envelope shape should pin the mnemo minor version.

Structs§

ChronosEnvelope
Chronos envelope — timeline-shaped: one line per hit with the hit id, score, and the first line of content. Chronos prefers temporally-anchored single-line summaries.
ClaudeCodeEnvelope
Claude Code envelope — fenced markdown blocks with recall://<id> anchors for inline; line-numbered file-pointer summary for the non-inline branch.
CodexEnvelope
Codex envelope — file-based by default (writes hits to a path-root the caller chose), with an inline JSON pointer summary in the response. The Inline branch keeps the raw content in the response.
GeminiCliEnvelope
Gemini CLI envelope — plain numbered list with [N] markers + the hit content; tool-call-style framing the Gemini CLI surfaces well.
GenericEnvelope
Generic envelope — minimal id\tscore\tcontent TSV one line per hit. The fallback when no harness-specific adapter applies.

Enums§

EnvelopeFormat
Where the envelope payload lives — inline in the response, written to a file the harness reads via a side-channel pointer, or written to a side-channel out-of-band stream.
HarnessKind
Which agent harness the response envelope should be shaped for.
RetrievalMode
Typed recall strategy. Superset of the legacy RecallRequest.strategy: Option<String> API — the variant ↔ string mapping is documented on each variant.

Traits§

HarnessEnvelope
Trait implemented by each per-harness adapter. The contract is minimal: take a slice of typed ScoredMemory hits and return a rendered string envelope shaped for the harness.