Skip to main content

zeph_agent_context/
lib.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3// Allow async stubs during scaffold phase — async signatures are load-bearing for callers.
4#![allow(clippy::unused_async)]
5
6//! Agent context-assembly service for Zeph.
7//!
8//! This crate provides [`service::ContextService`] — a stateless façade for all
9//! context-assembly operations that were previously implemented directly on `Agent<C>`
10//! in `zeph-core`. Extracting this logic means that editing context-assembly code does
11//! not trigger recompilation of the tool dispatcher (`zeph-agent-tools`) or the
12//! persistence layer (`zeph-agent-persistence`).
13//!
14//! # Architecture
15//!
16//! `zeph-agent-context` depends on `zeph-memory`, `zeph-llm`, `zeph-context`,
17//! `zeph-config`, `zeph-common`, `zeph-skills`, and `zeph-sanitizer`. It does **not**
18//! depend on `zeph-core` — this is the core invariant that keeps context-assembly
19//! changes from triggering full workspace rebuilds.
20//!
21//! `zeph-core` depends on this crate and constructs narrow borrow-lens views
22//! ([`state::MessageWindowView`], [`state::ContextAssemblyView`],
23//! [`state::ContextSummarizationView`]) from `Agent<C>` field projections, then
24//! delegates to `ContextService`.
25//!
26//! # Features
27//!
28//! - `self-check` — gates retrieved-memory mirror types for the MARCH self-check pipeline.
29//! - `index` — enables `zeph-index` integration via the `IndexAccess` trait.
30
31pub mod compaction;
32pub mod error;
33pub mod helpers;
34#[cfg(feature = "self-check")]
35#[cfg_attr(docsrs, doc(cfg(feature = "self-check")))]
36pub mod retrieved;
37pub mod service;
38pub mod state;
39pub mod summarization;
40
41pub use compaction::{
42    BlockScore, ContentDensity, SubgoalExtractionResult, SubgoalId, SubgoalRegistry, SubgoalState,
43    classify_density, extract_scorable_text, partition_by_density, run_focus_auto_consolidation,
44    score_blocks_mig, score_blocks_subgoal, score_blocks_subgoal_mig, score_blocks_task_aware,
45};
46pub use error::ContextError;
47pub use helpers::BudgetHint;
48pub use service::ContextService;
49pub use state::{
50    CompactionOutcome, CompactionPersistence, CompactionProbeCallback, ContextAssemblyView,
51    ContextDelta, ContextSummarizationView, MessageWindowView, MetricsCallback, MetricsCounters,
52    ProbeOutcome, ProviderHandles, QdrantPersistFuture, SecurityEventSink, StatusSink,
53    ToolOutputArchive, TrustGate,
54};
55
56#[cfg(feature = "self-check")]
57#[cfg_attr(docsrs, doc(cfg(feature = "self-check")))]
58pub use retrieved::{RetrievedContext, collect_retrieved_context};