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//! - `index` — enables `zeph-index` integration via the `IndexAccess` trait.
29
30pub mod compaction;
31pub mod error;
32pub mod helpers;
33pub mod memory_backend;
34pub mod retrieved;
35pub mod service;
36pub mod state;
37pub mod summarization;
38
39pub use compaction::{
40    BlockScore, ContentDensity, SubgoalExtractionResult, SubgoalId, SubgoalRegistry, SubgoalState,
41    classify_density, extract_scorable_text, partition_by_density, run_focus_auto_consolidation,
42    score_blocks_mig, score_blocks_subgoal, score_blocks_subgoal_mig, score_blocks_task_aware,
43};
44pub use error::ContextError;
45pub use helpers::BudgetHint;
46pub use service::{ContextService, SemanticRecallParams};
47pub use state::{
48    CompactionOutcome, CompactionPersistence, CompactionProbeCallback, ContextAssemblyView,
49    ContextDelta, ContextSummarizationView, MessageWindowView, MetricsCallback, MetricsCounters,
50    ProbeOutcome, ProviderHandles, QdrantPersistFuture, SecurityEventSink, StatusSink,
51    ToolOutputArchive, TrustGate,
52};
53
54pub use retrieved::{RetrievedContext, collect_retrieved_context};