Skip to main content

Module context_bundle

Module context_bundle 

Source
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 single crate::retrieval_router::RetrievalPlan type 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 a ContextBundle whose ContextAudit records 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§

AuditEntry
ContextAudit
ContextBundle
ContextFilters
ContextItem
One candidate or selected context item. stable_key follows the SessionStart identity convention (memory:<id>, session_summary:<id>).
ContextRequest
CurrentTruthShadowDiff
Inclusion/exclusion diff between today’s Core channel and CurrentTruth. Not a user-facing section: audit-only, no memory text.
ExecutorInputs
Candidate inputs for one execution. enrichment_available = false degrades the bundle to canonical_only: generated and graph-derived candidates are dropped instead of being served without their backing enrichment stack.
PlannedChannel
PreselectionDrop
ProjectRef
SectionBudgets
Per-section token budgets plus the total request budget.

Enums§

AgentRole
ChannelKind
The retrieval channels the v1 planner knows about; they mirror the SessionStart sections.
ContextIntent
DegradedMode
Bounded degradation contract: enrichment/vector/rerank incompatibility may degrade to CanonicalOnly; only canonical schema or scope-safety failures produce Blocked.
ItemValidity
RiskClass
SourceKind
Where an item’s text came from. Generated or graph-derived projections explain “why it was found” and must never masquerade as canonical memory.
TrustClass

Constants§

CONTEXT_BUNDLE_SCHEMA_VERSION
Version of the request/plan/bundle/audit JSON shapes.

Functions§

blocked_before_load
A Blocked bundle 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.