refactor(code-quality): typed errors, test module gating, deferred TODO markers#3401
Merged
refactor(code-quality): typed errors, test module gating, deferred TODO markers#3401
Conversation
…ariants
Add ApiError { provider, status } to LlmError to replace the common pattern
of wrapping non-success HTTP responses in Other(String). Add NoActiveSession
to ChannelError to replace Other("no active chat"/"no active channel") across
telegram, discord, and slack adapters.
Move context-length detection from is_context_length_error() into a
pub(crate) body_is_context_length_error() helper used at the transport layer
in each provider (claude, openai, gemini). is_context_length_error() now only
matches ContextLengthExceeded, removing the string-heuristic fallback.
Update all affected tests to assert on the new typed error format.
… markers - Gate pub mod testing/mock behind #[cfg(any(test, feature = "testing"))] in zeph-core, zeph-llm, zeph-memory, zeph-mcp (C1) - Add TODO comments at deferral points for A1 (Agent god object), A2 (typestate builder), A3 (Channel trait split), D1 (AnyProvider object safety), D2/G3 (ToolExecutor consolidation + middleware), D4 (config presets) - Rename SkillRegistry::get_skill/get_body to skill/body (F1 naming cleanup)
…essions Add TODO(B2)/TODO(B3) comments to allow(clippy::too_many_lines) and allow(clippy::too_many_arguments) attributes that had no justification comment, making it clear these are deferred refactors rather than accepted exceptions.
…ix broken doc link
This was referenced Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Code quality improvements pass — scoped to changes that do not introduce new abstractions or architectural rewrites (per CLAUDE.md v1.0 directive and critic review).
E1/E2 — Typed error variants
Replace
Other(String)catch-all with specific typed variants acrossLlmError,AgentError,ChannelError,MemoryError:ApiError { provider, status }— HTTP errors from LLM providers (no raw body exposure)ContextLengthExceeded,RateLimited,Unavailable— provider state variantsInvalidInput { provider, message }— structured 400 responsesNoActiveSession— channel state (replaces stringly-typedOther("no active chat"))StructuredParse— structured output parse failuresis_context_length_error()now matches on typed variant instead of substring-matching English text.body_is_context_length_error()ispub(crate)transport-layer helper.C1 — Gate test scaffolding behind cfg
pub mod testing/pub mod mockin production builds: zeph-core, zeph-llm, zeph-memory, zeph-mcp all gated behind#[cfg(any(test, feature = "testing"))]. Verifiedtestingfeature is absent from all default andfullfeature sets.F1 — Naming cleanup
SkillRegistry::get_skill→skill,get_body→body(drops redundantget_prefix).Deferred TODO markers
Architectural items that exceed the scope of this PR are documented at their deferral points:
Agent<C>god object decomposition (zeph-core/src/agent/mod.rs)zeph-core/src/agent/builder.rs)Channeltrait split into sub-traits (zeph-core/src/channel.rs)AnyProvider→Arc<dyn LlmProvider>(zeph-llm/src/any.rs)ToolExecutorconsolidation + middleware stack (zeph-tools/src/executor.rs)zeph-config/src/lib.rs)allow(clippy::too_many_lines/arguments)(7 sites)Validation
cargo +nightly fmt --check: passcargo clippy --workspace --lib --bins -- -D warnings: 0 warningscargo nextest run --workspace --lib --bins: 8500 passed / 0 failedcargo check --workspace: pass