Skip to main content

remem/
context_bundle.rs

1//! Context Bundle v1 (GH-932): versioned request/bundle/audit contract.
2//!
3//! remem's callers should face a policy-aware context compiler instead of
4//! "several search tools plus one pre-rendered text blob". This module holds
5//! the v1 internal Rust contract:
6//!
7//! - the plan is compiled by [`crate::retrieval_router::plan`], which owns
8//!   the single [`crate::retrieval_router::RetrievalPlan`] type covering
9//!   both the retrieval-source side (channels, weights, trust floors) and
10//!   the output-section side (sections, item limits, budgets), under one
11//!   stable plan hash;
12//! - `execute(plan, inputs)` selects caller-provided candidates by reusing
13//!   the existing SessionStart relevance policy, enforces per-section and
14//!   total token budgets, and returns a [`ContextBundle`] whose
15//!   [`ContextAudit`] records every considered/selected/dropped candidate
16//!   with a machine-readable reason and a degraded mode
17//!   (full / canonical_only / blocked).
18//!
19//! v1 is an experimental internal API. MCP/REST endpoints, DB-backed
20//! executor wiring, rerank/graph channels, doctor plan summaries, and
21//! benchmark artifact hashes are follow-up work on GH-932.
22
23mod audit;
24mod compile;
25mod current_truth;
26mod domain;
27mod executor;
28pub(crate) mod persistence;
29mod policy;
30#[cfg(test)]
31mod tests;
32
33pub use compile::compile_session_start_bundle;
34pub(crate) use compile::{
35    compile_session_start_for_renderer, reseal_after_emission_gate, seal_session_start_bundle,
36};
37pub(crate) use current_truth::{
38    abstained_memory_ids, abstention_reason_for_memory, append_core_abstention_lines,
39    core_render_memories, project_for_scope,
40};
41pub use domain::{
42    AgentRole, AuditEntry, ChannelKind, ContextAudit, ContextBundle, ContextFilters, ContextIntent,
43    ContextItem, ContextRequest, CurrentTruthShadowDiff, DegradedMode, ItemValidity,
44    PlannedChannel, ProjectRef, RiskClass, SectionBudgets, SourceKind, TrustClass,
45    CONTEXT_BUNDLE_SCHEMA_VERSION,
46};
47pub use executor::{blocked_before_load, execute, ExecutorInputs, PreselectionDrop};
48pub(crate) use persistence::{cleanup_persisted_audits_before, persist_context_bundle_audit};
49pub(crate) use policy::{section_budgets, section_budgets_from_limits, validate_request};