From 57c3c148e6a937f144df677539a910747cd3c69c Mon Sep 17 00:00:00 2001 From: "Andrei G." Date: Sat, 30 May 2026 04:24:59 +0200 Subject: [PATCH] fix(agent-pipeline): add #[non_exhaustive] to error enums Add the #[non_exhaustive] attribute to five public error enums across the agent pipeline crates to comply with the workspace convention established in #4658/#4660: - ToolDispatchError (zeph-agent-tools) - ContextError, CompactionOutcome, SubgoalState (zeph-agent-context) - PersistenceError (zeph-agent-persistence) Update three downstream exhaustive match sites in zeph-core that break under the new attribute: - zeph-core: compact_context_command() wildcard for CompactionOutcome - zeph-core: debug_dump SubgoalState display arm - zeph-agent-context: compaction weight match (within-crate, stays exhaustive) Closes #4717 Closes #4718 Closes #4719 --- CHANGELOG.md | 6 ++++++ crates/zeph-agent-context/src/compaction.rs | 1 + crates/zeph-agent-context/src/error.rs | 1 + crates/zeph-agent-context/src/state.rs | 1 + crates/zeph-agent-persistence/src/error.rs | 1 + crates/zeph-agent-tools/src/error.rs | 1 + .../zeph-core/src/agent/context/summarization/compaction.rs | 1 + crates/zeph-core/src/debug_dump/mod.rs | 1 + 8 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eebd44c59..9c562f2fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). discarding operator-configured Benna-Fusi rates and falling back to hardcoded defaults (fast=0.5, slow=0.05). Both rates are now threaded through `GraphExtractionConfig` and applied at all extraction callsites, including the backfill path in `agent_access_impl.rs`. Closes #4711. +- `zeph-agent-tools`: add `#[non_exhaustive]` to `ToolDispatchError` to allow adding variants + without breaking downstream crates. Updated exhaustive match sites in `zeph-core`. Closes #4717. +- `zeph-agent-context`: add `#[non_exhaustive]` to `ContextError`, `CompactionOutcome`, and + `SubgoalState`. Updated exhaustive match sites in `zeph-core`. Closes #4718. +- `zeph-agent-persistence`: add `#[non_exhaustive]` to `PersistenceError` to allow adding + variants without breaking downstream crates. Closes #4719. ### Performance diff --git a/crates/zeph-agent-context/src/compaction.rs b/crates/zeph-agent-context/src/compaction.rs index 83b480c74..fd7a41e24 100644 --- a/crates/zeph-agent-context/src/compaction.rs +++ b/crates/zeph-agent-context/src/compaction.rs @@ -290,6 +290,7 @@ pub struct SubgoalId(pub u32); /// Lifecycle state of a subgoal. #[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] pub enum SubgoalState { /// Currently being worked on. Messages tagged with this subgoal are protected. Active, diff --git a/crates/zeph-agent-context/src/error.rs b/crates/zeph-agent-context/src/error.rs index ab572904e..a7f6d00eb 100644 --- a/crates/zeph-agent-context/src/error.rs +++ b/crates/zeph-agent-context/src/error.rs @@ -10,6 +10,7 @@ use thiserror::Error; /// The caller in `zeph-core` maps these variants to `AgentError` via a `From` impl. /// Each variant corresponds to one subsystem that the context service touches. #[derive(Debug, Error)] +#[non_exhaustive] pub enum ContextError { /// Memory backend returned an error during recall or summary loading. /// diff --git a/crates/zeph-agent-context/src/state.rs b/crates/zeph-agent-context/src/state.rs index 6aa10df8e..d00001e9e 100644 --- a/crates/zeph-agent-context/src/state.rs +++ b/crates/zeph-agent-context/src/state.rs @@ -467,6 +467,7 @@ pub type QdrantPersistFuture = Pin + Send + 'stati /// Gives `maybe_compact()` enough information to handle probe rejection without triggering /// the `Exhausted` state — which would only be correct if summarization itself is stuck. #[must_use] +#[non_exhaustive] pub enum CompactionOutcome { /// Messages were drained and replaced with a summary. `SQLite` persistence succeeded. /// diff --git a/crates/zeph-agent-persistence/src/error.rs b/crates/zeph-agent-persistence/src/error.rs index 32f20e03b..0319dc829 100644 --- a/crates/zeph-agent-persistence/src/error.rs +++ b/crates/zeph-agent-persistence/src/error.rs @@ -10,6 +10,7 @@ use thiserror::Error; /// The caller in `zeph-core` maps these variants to `AgentError` via `From`. /// Callers can distinguish degradable errors (Qdrant offline) from fatal errors (`SQLite` corrupt). #[derive(Debug, Error)] +#[non_exhaustive] pub enum PersistenceError { /// Qdrant vector store is unavailable. Embedding is skipped; `SQLite` write may still succeed. /// Callers should degrade gracefully and continue the conversation without semantic search. diff --git a/crates/zeph-agent-tools/src/error.rs b/crates/zeph-agent-tools/src/error.rs index 20e0fdb19..55fa81304 100644 --- a/crates/zeph-agent-tools/src/error.rs +++ b/crates/zeph-agent-tools/src/error.rs @@ -9,6 +9,7 @@ use thiserror::Error; /// /// The caller in `zeph-core` maps these to `AgentError` via `From`. #[derive(Debug, Error)] +#[non_exhaustive] pub enum ToolDispatchError { /// LLM provider returned an error during tool-loop inference. #[error("LLM provider error: {0}")] diff --git a/crates/zeph-core/src/agent/context/summarization/compaction.rs b/crates/zeph-core/src/agent/context/summarization/compaction.rs index d5155987a..e55fa362e 100644 --- a/crates/zeph-core/src/agent/context/summarization/compaction.rs +++ b/crates/zeph-core/src/agent/context/summarization/compaction.rs @@ -83,6 +83,7 @@ impl Agent { Original context preserved." .to_owned()) } + _ => Ok("Context compacted successfully.".to_owned()), } } diff --git a/crates/zeph-core/src/debug_dump/mod.rs b/crates/zeph-core/src/debug_dump/mod.rs index e20475857..b308bf303 100644 --- a/crates/zeph-core/src/debug_dump/mod.rs +++ b/crates/zeph-core/src/debug_dump/mod.rs @@ -320,6 +320,7 @@ impl DebugDumper { let state_str = match sg.state { zeph_agent_context::SubgoalState::Active => "Active ", zeph_agent_context::SubgoalState::Completed => "Completed", + _ => "Unknown ", }; let _ = std::fmt::write( &mut output,