Skip to main content

Module context_bundle

Module context_bundle 

Source
Expand description

Context Bundle v1 (GH-932): versioned request/plan/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:

  • plan(request) builds a deterministic ContextPlan with a stable plan hash (no timestamps or randomness enter the 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>).
ContextPlan
ContextRequest
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
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_POLICY_VERSION
Bump when planner/executor selection or budget policy changes.
CONTEXT_BUNDLE_SCHEMA_VERSION
Version of the request/plan/bundle/audit JSON shapes.

Functions§

execute
Execute a plan over the provided candidates.
plan
Build a deterministic plan for the request.