Expand description
Context Bundle v1 (GH-932): versioned request/bundle/audit contract.
remem’s callers should face a policy-aware context compiler instead of “several search tools plus one pre-rendered text blob”. This module holds the v1 internal Rust contract:
- the plan is compiled by
crate::retrieval_router::plan, which owns the singlecrate::retrieval_router::RetrievalPlantype covering both the retrieval-source side (channels, weights, trust floors) and the output-section side (sections, item limits, budgets), under one stable plan hash; execute(plan, inputs)selects caller-provided candidates by reusing the existing SessionStart relevance policy, enforces per-section and total token budgets, and returns aContextBundlewhoseContextAuditrecords every considered/selected/dropped candidate with a machine-readable reason and a degraded mode (full / canonical_only / blocked).
v1 is an experimental internal API. MCP/REST endpoints, DB-backed executor wiring, rerank/graph channels, doctor plan summaries, and benchmark artifact hashes are follow-up work on GH-932.
Structs§
- Audit
Entry - Context
Audit - Context
Bundle - Context
Filters - Context
Item - One candidate or selected context item.
stable_keyfollows the SessionStart identity convention (memory:<id>,session_summary:<id>). - Context
Request - Current
Truth Shadow Diff - Inclusion/exclusion diff between today’s Core channel and CurrentTruth. Not a user-facing section: audit-only, no memory text.
- Executor
Inputs - Candidate inputs for one execution.
enrichment_available = falsedegrades the bundle tocanonical_only: generated and graph-derived candidates are dropped instead of being served without their backing enrichment stack. - Planned
Channel - Preselection
Drop - Project
Ref - Section
Budgets - Per-section token budgets plus the total request budget.
Enums§
- Agent
Role - Channel
Kind - The retrieval channels the v1 planner knows about; they mirror the SessionStart sections.
- Context
Intent - Degraded
Mode - Bounded degradation contract: enrichment/vector/rerank incompatibility
may degrade to
CanonicalOnly; only canonical schema or scope-safety failures produceBlocked. - Item
Validity - Risk
Class - Source
Kind - Where an item’s text came from. Generated or graph-derived projections explain “why it was found” and must never masquerade as canonical memory.
- Trust
Class
Constants§
- CONTEXT_
BUNDLE_ SCHEMA_ VERSION - Version of the request/plan/bundle/audit JSON shapes.
Functions§
- blocked_
before_ load - A
Blockedbundle for a failure that happened before any candidate existed — a canonical load error, most importantly. - compile_
session_ start_ bundle - Compile a SessionStart bundle from the database.
- execute
- Execute a plan over the provided candidates.