chore(libsy): Give libsy its own error type LibsyError#129
Conversation
Previously we returned `Box<dyn Error ..>` which makes it difficult for the caller to identify what happened, and handle different errors differently. Now we return `LibsyError` based on `thiserror`. This means the tests can also match on the specific error variant, rather than `is_err()` or a string fragment. Dependency `protocol` gives us a `Box<dyn Error ..>` so we preserve that in one variant of `LibsyError`. Later that will also get a typed error and we can remove this. Signed-off-by: Graham King <grahamk@nvidia.com>
|
@coderabbitai full review |
✅ Action performedFull review finished. |
WalkthroughThe pull request introduces a typed ChangesTyped error contract
Core execution and driver plumbing
Algorithm implementations and examples
Observability and server integration
Estimated code review effort: 4 (Complex) | ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/libsy/src/error.rs (1)
49-56: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRedundant
#[source]alongside#[from].
#[from]already implies#[source]on the same field, so the explicit#[source]here is unnecessary.♻️ Optional cleanup
AlgorithmTask { /// Tokio task failure, including panic and unexpected cancellation details. #[from] - #[source] source: tokio::task::JoinError, },🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/libsy/src/error.rs` around lines 49 - 56, Remove the redundant #[source] attribute from the source field in the AlgorithmTask error variant, leaving #[from] to provide the error source behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/libsy/src/error.rs`:
- Around line 49-56: Remove the redundant #[source] attribute from the source
field in the AlgorithmTask error variant, leaving #[from] to provide the error
source behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: e377c9a7-c62d-4828-8f7a-a943e509e386
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (20)
crates/libsy/Cargo.tomlcrates/libsy/README.mdcrates/libsy/examples/ensemble.rscrates/libsy/examples/research_agent.rscrates/libsy/examples/research_agent_core.rscrates/libsy/examples/streaming_agent.rscrates/libsy/src/algorithms/fall_through.rscrates/libsy/src/algorithms/llm_class.rscrates/libsy/src/algorithms/noop.rscrates/libsy/src/algorithms/rand.rscrates/libsy/src/algorithms/subagent_override.rscrates/libsy/src/core/algorithm.rscrates/libsy/src/core/classifier.rscrates/libsy/src/core/driver.rscrates/libsy/src/core/processor.rscrates/libsy/src/error.rscrates/libsy/src/lib.rscrates/libsy/src/observability.rscrates/libsy/tests/observability.rscrates/switchyard-server/src/lib.rs
Signed-off-by: Graham King <grahamk@nvidia.com>
We don't need errors relating to algo internals. We still provide a descriptive error message for debugging. Signed-off-by: Graham King <grahamk@nvidia.com>
Replaces the crate-wide
BoxErralias with two typed enums in a newerror.rs:LibsyErrorandDriverError.Previously we returned
Box<dyn Error ..>which makes it difficult for the caller to identify what happened, and handle different errors differently.Now we return
LibsyErrorbased onthiserror.This means the tests can also match on the specific error variant, rather than
is_err()or a string fragment.Dependency
protocolgives us aBox<dyn Error ..>so we preserve that in one variant ofLibsyError. Later that will also get a typed error and we can remove this.Claude's review:
Claude was remarkably complimentary of Sol's work.
Signed-off-by: Graham King grahamk@nvidia.com
Assisted-by: Codex:GPT 5.6 Sol medium
Summary by CodeRabbit
New Features
Documentation