Repository navigation
Tighten linting and harden CLI tests - #19
Conversation
Reviewer's GuideThis PR enforces stricter lint rules, introduces anyhow-powered error propagation in CLI tests and support code by converting panicking calls into fallible helpers and Context-based errors, restructures daemon simulation helpers to reduce nesting, and updates Cargo manifests to add the anyhow dependency. Entity relationship diagram for new dependency on anyhowerDiagram
"weaver-cli" ||--o{ "anyhow" : uses
"workspace" ||--o{ "anyhow" : uses
Class diagram for updated CLI test support helpersclassDiagram
class CliTestSupport {
+run_command(args) Result
+simulate_daemon() Result
}
class Result {
}
CliTestSupport --> Result: returns
Class diagram for error propagation in CLI testsclassDiagram
class BehaviourTest {
+test_case() Result
}
class UnitTest {
+test_case() Result
}
class Result {
}
BehaviourTest --> Result: returns
UnitTest --> Result: returns
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Note Reviews pausedUse the following commands to manage reviews:
Summary by CodeRabbit
Summary by CodeRabbitRelease Notes
WalkthroughTighten workspace linting (many new deny rules and reduced thresholds) and refactor weaver-cli tests and test support to use anyhow::Result with contextual error handling; add socket helpers and a TryCloneStream abstraction. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Runner as Test runner
participant World as TestWorld
participant Daemon as FakeDaemon
participant Socket as Client socket
Note over Runner,World: Behaviour steps now return Result and propagate errors
Runner->>World: start_daemon() ?
World->>Daemon: spawn(lines) ?
Daemon-->>World: spawn Result (handle)
Runner->>Socket: connect & send request
Socket->>Daemon: accept connection
Daemon->>Daemon: record_request() / stream_responses()
Daemon-->>Socket: response lines
Note over Runner,World: Errors bubble up as anyhow::Result with Context
Estimated code review effort🎯 4 (Complex) | ⏱️ ~35–45 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
crates/weaver-cli/Cargo.toml (1)
14-23: Use explicit caret (^) versions per policy.Enforce caret requirements across non-workspace deps. Update these entries.
[target.'cfg(unix)'.dependencies] -socket2 = { version = "0.5" } +socket2 = { version = "^0.5" } [dev-dependencies] anyhow = { workspace = true } -rstest = { workspace = true } -rstest-bdd = { workspace = true } -rstest-bdd-macros = { workspace = true } -assert_cmd = "2.0" -predicates = "3.0" -tempfile = { workspace = true } +rstest = { workspace = true } +rstest-bdd = { workspace = true } +rstest-bdd-macros = { workspace = true } +assert_cmd = "^2.0" +predicates = "^3.0" +tempfile = { workspace = true }As per coding guidelines.
Cargo.toml (1)
14-28: Make caret explicit on all workspace dependencies.Apply caret prefixes to satisfy the dependency policy.
[workspace.dependencies] -anyhow = "1.0" -camino = { version = "1.1", features = ["serde1"] } -clap = { version = "4.5", features = ["derive"] } -once_cell = "1.19" -ortho_config = "0.5.0" -rstest = "0.23" -rstest-bdd = "0.1.0-alpha4" -rstest-bdd-macros = "0.1.0-alpha4" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -thiserror = "2.0" -tempfile = "3.10" -dirs = "6.0" +anyhow = "^1.0" +camino = { version = "^1.1", features = ["serde1"] } +clap = { version = "^4.5", features = ["derive"] } +once_cell = "^1.19" +ortho_config = "^0.5.0" +rstest = "^0.23" +rstest-bdd = "^0.1.0-alpha4" +rstest-bdd-macros = "^0.1.0-alpha4" +serde = { version = "^1.0", features = ["derive"] } +serde_json = "^1.0" +thiserror = "^2.0" +tempfile = "^3.10" +dirs = "^6.0"As per coding guidelines.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
Cargo.toml(2 hunks)clippy.toml(1 hunks)crates/weaver-cli/Cargo.toml(1 hunks)crates/weaver-cli/src/tests/behaviour.rs(2 hunks)crates/weaver-cli/src/tests/support.rs(7 hunks)crates/weaver-cli/src/tests/unit.rs(7 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.rs: Clarity over cleverness: prefer explicit, readable Rust code over terse/obscure idioms
Use functions and composition; avoid repetition; prefer generators/comprehensions and declarative code when readable
Small, meaningful functions with single responsibility and command-query segregation
Name things precisely; boolean names should use is/has/should
Keep file size manageable: no single Rust file longer than 400 lines; split long switches/dispatch tables; move large test data to external files
Fix warnings emitted during tests in code; do not silence them
Extract helper functions when a function is too long, adhering to separation of concerns and CQRS
Group many parameters into meaningful structs when a function has too many parameters
When returning large errors, consider using Arc to reduce returned data size
Write unit and behavioural tests for new functionality and run before/after changes
Prefer immutable data; avoid unnecessary mut bindings
Handle errors with Result instead of panicking where feasible
Avoid unsafe code unless absolutely necessary; document any usage clearly
Place function attributes after doc comments
Do not use return in single-line functions
Use predicate functions for conditionals with more than two branches
Do not silence lints except as a last resort
Lint suppressions must be tightly scoped and include a clear reason
Prefer #[expect] over #[allow] for lint justifications
Prefer .expect() over .unwrap()
Use concat!() to combine long string literals rather than escaping newlines
Prefer single-line versions of trivial functions when appropriate
Use NewTypes to model domain values; consider newt-hype, tuple structs, the-newtype per context; implement appropriate traits and shims
Prefer semantic error enums deriving std::error::Error via thiserror for inspectable conditions
Files:
crates/weaver-cli/src/tests/support.rscrates/weaver-cli/src/tests/behaviour.rscrates/weaver-cli/src/tests/unit.rs
⚙️ CodeRabbit configuration file
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -yse / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Where code is only used by specific features, it must be conditionally compiled or a conditional expectation for unused_code applied.
Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Environment access (env::set_var and env::remove_var) are always unsafe in Rust 2024 and MUST be marked as such
- For testing of functionality depending upon environment variables, dependency injection and the
mockablecrate are the preferred option.- If mockable cannot be used, env mutations in...
Files:
crates/weaver-cli/src/tests/support.rscrates/weaver-cli/src/tests/behaviour.rscrates/weaver-cli/src/tests/unit.rs
**/*.{rs,md}
📄 CodeRabbit inference engine (AGENTS.md)
Use consistent en-GB-oxendict spelling/grammar in comments and documentation (except LICENSE naming)
Files:
crates/weaver-cli/src/tests/support.rscrates/weaver-cli/src/tests/behaviour.rscrates/weaver-cli/src/tests/unit.rs
**/src/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/src/**/*.rs: Illustrate functions with clear examples in documentation comments; omit redundant examples in test docs
Every module must begin with a module-level //! comment explaining its purpose
Document public APIs with Rustdoc comments (///) so cargo doc can generate docs
Files:
crates/weaver-cli/src/tests/support.rscrates/weaver-cli/src/tests/behaviour.rscrates/weaver-cli/src/tests/unit.rs
Cargo.toml
📄 CodeRabbit inference engine (AGENTS.md)
Cargo.toml: Use explicit version ranges in Cargo.toml and keep dependencies up to date
Mandate caret requirements for all dependencies (SemVer-compatible ^)
Prohibit wildcard (*) and >= requirements; use ~ only with documented reason
Files:
Cargo.toml
🧬 Code graph analysis (3)
crates/weaver-cli/src/tests/support.rs (2)
crates/weaver-cli/src/lib.rs (2)
run_with_loader(122-161)run(44-51)crates/weaver-config/src/socket.rs (1)
tcp(38-43)
crates/weaver-cli/src/tests/behaviour.rs (1)
crates/weaver-cli/src/tests/support.rs (4)
world(255-257)new(27-29)stdout_text(96-98)stderr_text(100-102)
crates/weaver-cli/src/tests/unit.rs (4)
crates/weaver-cli/src/tests/support.rs (4)
read_fixture(237-244)new(27-29)port(174-176)default_daemon_lines(246-252)crates/weaver-cli/src/lib.rs (1)
read_daemon_messages(183-234)crates/weaver-cli/src/transport.rs (1)
connect(60-91)crates/weaver-config/src/socket.rs (2)
tcp(38-43)unix(32-34)
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Sourcery review
- GitHub Check: build-test
🔇 Additional comments (6)
clippy.toml (1)
2-7: Tighten thresholds acknowledged; keep “expect in tests” allowed.Proceed with these stricter gates; they align with the repo guidelines’ stance on panics in tests vs production. No changes requested.
Cargo.toml (2)
91-93: Validate docs-gates before merge.
missing_docs = "deny"andmissing_crate_level_docs = "deny"will fail builds if any crate or public item lacks docs. Verify completeness.#!/bin/bash # Check crate-level docs and public items with no docs. # 1) Ensure each crate root has a crate-level //! doc. fd -a '^lib\.rs$' crates | xargs -I{} rg -n --trim '^\s*//!' {} -C0 # 2) Spot obvious public items without docs (heuristic). rg -nP --type=rust '^\s*pub\s+(struct|enum|fn|trait)\s' -g '!**/tests/**' | \ gawk 'BEGIN{FS=":"}{print $0}' | \ rg -nP -v '^\s*///'As per coding guidelines.
10-13: Pin toolchain to matchedition = "2024"andrust-version = "1.85".Ensure CI/tooling uses Rust 1.85 with edition 2024 to avoid lint/feature drift.
#!/bin/bash # Verify rust-toolchain manifests pin to 1.85. fd -a 'rust-toolchain(\.toml)?$' -HI | xargs -I{} sh -c 'echo ">>> {}"; cat "{}"'crates/weaver-cli/src/tests/support.rs (1)
48-58: Result-based test helpers: good propagation and context.Retain this pattern; it improves failure diagnostics and aligns with the repo’s error-handling guidance.
Also applies to: 68-81, 96-103, 104-112, 114-122, 124-137, 139-147, 178-189, 201-216, 218-226, 237-244
crates/weaver-cli/src/tests/behaviour.rs (1)
11-17: Adopt Result-returning steps across BDD suite.Keep this structure; it reduces panic-based flakiness and produces clearer errors.
Also applies to: 24-36, 38-45, 47-55, 57-63, 65-71, 73-85, 87-95, 97-101, 103-106
crates/weaver-cli/src/tests/unit.rs (1)
299-324: Solid test refactor: readable helpers, trait for cloneable streams, and Result flow.Proceed; helpers remove duplication and the trait abstracts stream cloning cleanly.
Also applies to: 326-332, 334-346, 348-355, 255-270, 272-297, 20-35, 92-102, 104-118, 120-128, 130-155, 157-220, 222-253
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
crates/weaver-cli/src/tests/support.rs(7 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.rs: Clarity over cleverness: prefer explicit, readable Rust code over terse/obscure idioms
Use functions and composition; avoid repetition; prefer generators/comprehensions and declarative code when readable
Small, meaningful functions with single responsibility and command-query segregation
Name things precisely; boolean names should use is/has/should
Keep file size manageable: no single Rust file longer than 400 lines; split long switches/dispatch tables; move large test data to external files
Fix warnings emitted during tests in code; do not silence them
Extract helper functions when a function is too long, adhering to separation of concerns and CQRS
Group many parameters into meaningful structs when a function has too many parameters
When returning large errors, consider using Arc to reduce returned data size
Write unit and behavioural tests for new functionality and run before/after changes
Prefer immutable data; avoid unnecessary mut bindings
Handle errors with Result instead of panicking where feasible
Avoid unsafe code unless absolutely necessary; document any usage clearly
Place function attributes after doc comments
Do not use return in single-line functions
Use predicate functions for conditionals with more than two branches
Do not silence lints except as a last resort
Lint suppressions must be tightly scoped and include a clear reason
Prefer #[expect] over #[allow] for lint justifications
Prefer .expect() over .unwrap()
Use concat!() to combine long string literals rather than escaping newlines
Prefer single-line versions of trivial functions when appropriate
Use NewTypes to model domain values; consider newt-hype, tuple structs, the-newtype per context; implement appropriate traits and shims
Prefer semantic error enums deriving std::error::Error via thiserror for inspectable conditions
Files:
crates/weaver-cli/src/tests/support.rs
⚙️ CodeRabbit configuration file
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -yse / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Where code is only used by specific features, it must be conditionally compiled or a conditional expectation for unused_code applied.
Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Environment access (env::set_var and env::remove_var) are always unsafe in Rust 2024 and MUST be marked as such
- For testing of functionality depending upon environment variables, dependency injection and the
mockablecrate are the preferred option.- If mockable cannot be used, env mutations in...
Files:
crates/weaver-cli/src/tests/support.rs
**/*.{rs,md}
📄 CodeRabbit inference engine (AGENTS.md)
Use consistent en-GB-oxendict spelling/grammar in comments and documentation (except LICENSE naming)
Files:
crates/weaver-cli/src/tests/support.rs
**/src/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/src/**/*.rs: Illustrate functions with clear examples in documentation comments; omit redundant examples in test docs
Every module must begin with a module-level //! comment explaining its purpose
Document public APIs with Rustdoc comments (///) so cargo doc can generate docs
Files:
crates/weaver-cli/src/tests/support.rs
🧬 Code graph analysis (1)
crates/weaver-cli/src/tests/support.rs (2)
crates/weaver-cli/src/lib.rs (2)
run_with_loader(122-161)run(44-51)crates/weaver-config/src/socket.rs (1)
tcp(38-43)
🔍 Remote MCP
Based on the repository documentation I've gathered, here's the relevant context for reviewing this pull request:
Relevant Context for PR #19 Review
Project Background
The weaver project is a code intelligence platform (written in Python, not Rust as suggested by the Cargo.toml files) that consists of three main components:
- weaver CLI - Lightweight client using
typerfor command-line interaction - weaverd daemon - Asyncio-based background service maintaining language server connections
- weaver_schemas - Shared data models using
msgspecfor RPC communication
However, there appears to be a component mismatch: The PR focuses on crates/weaver-cli/ suggesting a Rust implementation, but the repository documentation indicates a Python project. This may indicate the PR is for a different project or represents a language transition.
Development Philosophy Relevant to This PR
-
Strict Typing Requirements: [::Deepwiki_read_wiki_contents::] indicates the project uses
pyrightin strict mode with comprehensive type annotations. The transition toResult<()>error handling aligns with this philosophy. -
Error Handling Approach: The codebase emphasizes structured error objects (
SchemaError) and graceful error propagation rather than panics, which matches the PR's objective to "replace panics with propagated errors." -
Testing Standards: The documentation shows comprehensive testing infrastructure with unit tests, integration tests, and BDD features - critical for validating the test refactoring changes in this PR.
Specific Patterns in Documentation
- OODA Loop Organization: Commands are organized around Observe-Orient-Decide-Act framework, suggesting structured error handling is important for maintaining this abstraction
- Resource Management: The daemon emphasizes "graceful degradation" and "structured error responses" preventing daemon crashes
- Transient Edit System: Complex speculative analysis requires reliable error propagation to maintain correctness
Import and Configuration Standards
The documentation indicates the project enforces specific import patterns and has strict linting rules - the Clippy configuration changes in the PR (cognitive complexity thresholds, strictness levels) align with this existing quality-focused culture.,
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Sourcery review
🔇 Additional comments (10)
crates/weaver-cli/src/tests/support.rs (10)
10-11: LGTM!The new imports support the enhanced error handling (anyhow) and non-blocking daemon timeout logic (Duration, Instant, io, TcpListener, TcpStream).
Also applies to: 16-16, 19-19
50-59: LGTM!Clean error propagation from
FakeDaemon::spawnthrough the daemon startup methods.
69-82: LGTM!The method correctly propagates errors from
take_requests()and returnsResult<()>for fallible test operations.
97-103: LGTM!UTF-8 conversion can fail; wrapping in
Resultwith descriptive context is appropriate.
105-123: LGTM!Idiomatic use of
ensure!for test assertions with clear error messages. The error context propagation is sound.
125-148: LGTM!The golden-file and capabilities assertions provide clear error messages with expected vs actual output. Error propagation from
read_fixtureis correct.
182-193: LGTM!Correctly propagates errors from the daemon thread (catching panics) and from mutex locks.
221-236: LGTM!The request recording correctly handles stream cloning, reading, and mutex locking with appropriate error context.
238-246: LGTM!Socket write operations correctly propagate errors with descriptive context.
257-263: LGTM!The contextual error message includes the fixture path, which aids debugging when fixture loading fails.
|
@coderabbitai Have the following now been resolved? Prompt for AI Agents Please address the comments from this code review: Overall Comments
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 640 🏁 Script executed: Length of output: 1111 @leynos: Yes, all three review comments have been resolved:
The refactoring looks good! |
|
@coderabbitai Have the following now been resolved?
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 930 @leynos: Yes, all three review comments have been resolved:
The refactoring looks good! |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
crates/weaver-cli/src/tests/support.rs(6 hunks)crates/weaver-cli/src/tests/unit.rs(7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
⚙️ CodeRabbit configuration file
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -yse / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Where code is only used by specific features, it must be conditionally compiled or a conditional expectation for unused_code applied.
Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Environment access (env::set_var and env::remove_var) are always unsafe in Rust 2024 and MUST be marked as such
- For testing of functionality depending upon environment variables, dependency injection and the
mockablecrate are the preferred option.- If mockable cannot be used, env mutations in...
Files:
crates/weaver-cli/src/tests/support.rscrates/weaver-cli/src/tests/unit.rs
🔍 Remote MCP Deepwiki
Summary of additional repository context relevant to this PR review
-
Project is a Python client/daemon with strong testing, strict typing and linting culture; repository uses msgspec-based schemas and an RPC client-daemon pattern — changing test error flows touches canonical testing and IPC patterns.
-
Test infra expectations:
- Tests run under pytest with asyncio fixtures and a 30s timeout; integration/BDD tests spawn a daemon and exercise UNIX-socket RPC flows (so changing test signatures to fallible Results must preserve test harness semantics).
- CI and local commands referenced by PR (run formatting, lint, tests) align with repo tooling (ruff/pyright/pytest).
-
Relevant patterns/constraints that affect this PR:
- The project enforces strict linting/type rules and centralized tooling (pyproject.toml / ruff / pyright). The PR’s workspace-level lint tightening and added denies are consistent with repository emphasis on strict quality gates.
- Tests and helpers historically colocated; prior reviewer requested moving socket/stream helpers out of unit tests into support module — PR summary indicates helpers were moved to support.rs and made pub(super). Verify the final locations and visibilities to match that resolution.
-
Practical review touchpoints (what to check in this PR):
- Dependency changes: ensure workspace addition of anyhow (and workspace rust-version pin) is minimal and does not conflict with packaging/tooling. Confirm workspace rust-version pin (1.85) matches CI/tooling expectations for fallible tests.
- Public API/signature changes: many test-support APIs changed to return Result. Verify any callers outside tests are updated and exported visibility is appropriate (pub vs pub(super)).
- Helper placement & duplication: confirm TryCloneStream, decode_utf8 and socket helpers are only in support module (not duplicated in unit.rs) and have appropriate #[cfg(unix)] guards where needed.
- Error/context handling: ensure conversions to anyhow::Context preserve diagnostic messages used by BDD/integration assertions (golden fixtures, stderr matching).
- Lint thresholds: validate new clippy.toml thresholds (cognitive_complexity, too-many-args/lines, nesting) are achievable for existing code or that PR updates reconcile failures. Run make lint to confirm.
- Test harness compatibility: because tests now return Result<()>, confirm CI Rust toolchain (or pinned rust-version) used in CI matches to avoid false failures.
Citations
- Repository documentation and test/CI/tooling details:
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Sourcery review
🔇 Additional comments (8)
crates/weaver-cli/src/tests/support.rs (5)
53-85: Daemon lifecycle methods correctly propagate errors.The refactoring to return
Result<()>fromstart_daemon,start_daemon_with_lines, andrunaligns well with the PR objectives. The error propagation using?is clean, and the daemon request collection at line 81 properly handles the fallibletake_requestscall.
162-209: Past review comments on thread error handling comprehensively addressed.The implementation now stores the thread outcome in
Arc<Mutex<Option<Result<()>>>>(lines 169-176) and checks it intake_requests(lines 196-203), eliminating the panic-on-error pattern. The thread join at lines 192-194 catches panics explicitly. This is a robust solution.
211-236: Deadline optimisation correctly implemented.The deadline check now occurs only within the
WouldBlockmatch arms (lines 224, 228), avoiding unnecessaryInstant::now()calls on successful accepts. The dual pattern at lines 224 and 228 correctly distinguishes between "before deadline, sleep and retry" and "after deadline, exit cleanly". Well done.
269-325: Socket helper functions well-organised and appropriately abstracted.The
TryCloneStreamtrait (lines 304-325) provides a clean abstraction for TCP and Unix socket cloning, with proper#[cfg(unix)]guards. The helper functions (respond_to_request,write_lines,accept_tcp_connection,accept_unix_connection) are appropriately scoped withpub(super)visibility and eliminate duplication between test cases.
336-338: UTF-8 decoding helper successfully eliminates boilerplate.The
decode_utf8function centralises the repetitive.context(...)pattern for UTF-8 decoding, improving readability across the test suite. The consistent usage instdout_text,stderr_text, and throughoutunit.rsdemonstrates the value of this refactor.crates/weaver-cli/src/tests/unit.rs (3)
23-38: Test refactoring to fallible signature improves error clarity.Returning
Result<()>and using?for error propagation (lines 33, 34, 35) makes test failures more informative than the previous panic-based approach. The use ofdecode_utf8helper reduces boilerplate.
224-252: Generic test helper eliminates TCP/Unix duplication effectively.The
test_daemon_connectionfunction abstracts the connection lifecycle, allowing TCP (lines 255-269) and Unix socket (lines 273-296) tests to share the same verification logic. The closure-based setup pattern (line 226) is flexible, and thread panics are properly caught and converted to errors (lines 248-250).
255-296: Socket connection tests leverage the new helper infrastructure cleanly.Both
connect_successfully_establishes_tcp_connectionandconnect_supports_unix_socketsuse the helpers imported fromsupport(accept_tcp_connection,accept_unix_connection), confirming that the refactoring successfully moved shared logic out of test code. The Unix test is properly gated with#[cfg(unix)].
|
@coderabbitai pause |
✅ Actions performedReviews paused. |
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68fbfe4e32648322a04db1753cd58835
Summary by Sourcery
Tighten linting rules across the workspace and harden the CLI test suite by refactoring tests to use fallible helpers with anyhow, extracting shared networking logic, and replacing panics with propagated errors
Enhancements:
Build:
Tests: