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
4// The graph-retrieval-strategy dispatch in `helpers::fetch_graph_facts` chains several
5// nested async fns (`run_graph_strategy`, `run_synapse_strategy`, `run_hybrid_strategy`, ...),
6// which pushes the compiler's Future-layout query depth beyond the default limit of 128.
7// This only manifests with the `full` feature bundle combined with `postgres` at the
8// *workspace* level (`cargo check --workspace --all-targets --no-default-features
9// --features full,postgres`) — `full` pulls in additional dependent crates (candle, pdf,
10// scheduler, tui, acp, gateway, a2a, otel, prometheus) whose types push the query depth
11// further than `postgres` alone. A crate-scoped build (`-p zeph-agent-context --features
12// postgres`) does NOT reproduce this; always verify against the workspace+full+postgres
13// combination before touching this attribute again.
14#![recursion_limit = "256"]
15
16//! Agent context-assembly service for Zeph.
17//!
18//! This crate provides [`service::ContextService`] — a stateless façade for all
19//! context-assembly operations that were previously implemented directly on `Agent<C>`
20//! in `zeph-core`. Extracting this logic means that editing context-assembly code does
21//! not trigger recompilation of the tool dispatcher (`zeph-agent-tools`) or the
22//! persistence layer (`zeph-agent-persistence`).
23//!
24//! # Architecture
25//!
26//! `zeph-agent-context` depends on `zeph-memory`, `zeph-llm`, `zeph-context`,
27//! `zeph-config`, `zeph-common`, `zeph-skills`, and `zeph-sanitizer`. It does **not**
28//! depend on `zeph-core` — this is the core invariant that keeps context-assembly
29//! changes from triggering full workspace rebuilds.
30//!
31//! `zeph-core` depends on this crate and constructs narrow borrow-lens views
32//! ([`state::MessageWindowView`], [`state::ContextAssemblyView`],
33//! [`state::ContextSummarizationView`]) from `Agent<C>` field projections, then
34//! delegates to `ContextService`.
35//!
36//! # Features
37//!
38//! - `index` — enables `zeph-index` integration via the `IndexAccess` trait.
39
40pub mod compaction;
41pub mod error;
42pub mod helpers;
43pub mod memory_backend;
44pub mod retrieved;
45pub mod service;
46pub mod state;
47pub mod summarization;
48pub mod type_aware_compose;
49
50pub use compaction::{
51    BlockScore, ContentDensity, SubgoalExtractionResult, SubgoalId, SubgoalRegistry, SubgoalState,
52    classify_density, extract_scorable_text, partition_by_density, run_focus_auto_consolidation,
53    score_blocks_mig, score_blocks_subgoal, score_blocks_subgoal_mig, score_blocks_task_aware,
54};
55pub use error::ContextError;
56pub use helpers::BudgetHint;
57pub use service::{ContextService, SemanticRecallParams};
58pub use state::{
59    CompactionOutcome, CompactionPersistence, CompactionProbeCallback, ContextAssemblyView,
60    ContextDelta, ContextSummarizationView, MessageWindowView, MetricsCallback, MetricsCounters,
61    ProbeOutcome, ProviderHandles, QdrantPersistFuture, SecurityEventSink, StatusSink,
62    ToolOutputArchive, TrustGate,
63};
64
65pub use retrieved::{RetrievedContext, collect_retrieved_context};