Skip to content

Clarify backend failure error field format - #23

Merged
leynos merged 4 commits into
mainfrom
codex/unify-error-field-formatting
Oct 30, 2025
Merged

leynos merged 4 commits into
mainfrom
codex/unify-error-field-formatting

Conversation

@leynos

@leynos leynos commented Oct 29, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • document that the backend failure health event emits the error via Display to match the schema used for bootstrap failures

Testing

  • make check-fmt

https://chatgpt.com/codex/tasks/task_e_6902932286c48322b49d2decf8c5cb97

Summary by Sourcery

Documentation:

  • Add comment explaining that backend_failed uses Display for its error field format

@sourcery-ai

sourcery-ai Bot commented Oct 29, 2025 •

Copy link
Copy Markdown

🧙 Sourcery has finished reviewing your pull request!


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Oct 29, 2025 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 58 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a59fc33 and 30cfbcf.

📒 Files selected for processing (1)
  • crates/weaverd/src/health.rs (3 hunks)

Summary by CodeRabbit

  • Refactor
    • Improved error handling consistency in the health check module.

Walkthrough

Summarise the change: add use std::fmt;, introduce a private helper display_error returning tracing::field::DisplayValue, and replace %error with display_error(error) in bootstrap_failed and backend_failed. No public APIs or control flow changed.

Changes

Cohort / File(s) Summary
Health module changes
crates/weaverd/src/health.rs
Add use std::fmt;; introduce private helper display_error that wraps a Display reference into tracing::field::DisplayValue; replace previous %error formatting in bootstrap_failed and backend_failed with display_error(error); add clarifying comment.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify display_error uses correct lifetimes and returns the expected tracing::field::DisplayValue.
  • Confirm logging output remains consistent and no public signatures changed.

Poem

A tiny helper slips in neat,
Errors now spoken clear and sweet,
Imports trimmed and lines aligned,
Logs still truthful, neatly signed —
Small craft, precise and fleet. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Clarify backend failure error field format" directly relates to the changeset's primary objective. The raw summary shows that the pull request introduces a display_error helper function and updates backend_failed to format errors consistently using Display, which aligns precisely with clarifying the backend failure error field format. The title is concise, specific, and communicates the main change clearly enough that a colleague scanning the history would understand the purpose of the modification.
Description Check ✅ Passed The pull request description is demonstrably related to the changeset. It documents the objective of clarifying that the backend failure health event emits errors via Display to match the bootstrap failure schema, which directly corresponds to the implementation changes shown in the raw summary. The description includes testing information and references an external task, all of which substantiate the pull request's purpose and remain on-topic with respect to the actual code modifications.

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Convert the inline comment into a /// doc comment on the backend_failed method so the format guidance is included in generated docs.
  • Consider extracting the common error‐formatting logic for backend_failed and bootstrap_failed into a shared helper to avoid duplication.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Convert the inline comment into a `///` doc comment on the `backend_failed` method so the format guidance is included in generated docs.
- Consider extracting the common error‐formatting logic for `backend_failed` and `bootstrap_failed` into a shared helper to avoid duplication.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7706a1b and 3565244.

📒 Files selected for processing (1)
  • crates/weaverd/src/health.rs (3 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/weaverd/src/health.rs

⚙️ CodeRabbit configuration file

**/*.rs: * Seek to keep the cognitive complexity of functions no more than 9.

  • Adhere to single responsibility and CQRS
  • Place function attributes after doc comments.
  • Do not use return in single-line functions.
  • Move conditionals with >2 branches into a predicate function.
  • Avoid unsafe unless 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 rstest fixtures for shared setup and to avoid repetition between tests.
  • Replace duplicated tests with #[rstest(...)] parameterised cases.
  • Prefer mockall for mocks/stubs.
  • Prefer .expect() over .unwrap() in tests.
  • .expect() and .unwrap() are forbidden outside of tests. Errors must be propagated.
  • 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...

Files:

  • crates/weaverd/src/health.rs
**/*.{rs,md}

📄 CodeRabbit inference engine (AGENTS.md)

Use consistent en-GB-oxendict spelling/grammar in comments and documentation (except LICENSE naming)

Files:

  • crates/weaverd/src/health.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/weaverd/src/health.rs
🧬 Code graph analysis (1)
crates/weaverd/src/health.rs (2)
crates/weaverd/src/backends.rs (2)
  • fmt (28-35)
  • message (109-111)
crates/weaverd/src/tests/support/reporter.rs (1)
  • backend_failed (76-81)
🔍 Remote MCP Deepwiki

Based on my exploration of the leynos/weaver repository documentation, I can now provide you with relevant context for reviewing the pull request about clarifying backend failure error field format.

Summary of Relevant Context for PR #23 Review

Context from Repository

The weaver codebase is a Python-based code intelligence platform using a client-daemon architecture. The repository uses a monorepo structure with three main packages: weaver (CLI), weaverd (daemon), and weaver_schemas (data models).

Key Technical Context:

  1. Data Schema System: The project uses msgspec for serialization with frozen structs and type discriminator fields. All schemas must follow specific patterns for JSONL streaming and type safety.

  2. Error Handling Architecture: The system uses structured error reporting through SchemaError objects that ensure errors are properly serialized and transmitted across RPC boundaries without crashing the daemon.

  3. Health Status Monitoring: The daemon includes a project-status RPC handler that reports system health. Error formatting in logging uses structured field representations through the tracing library with DisplayValue types.

  4. Code Organization Standards: The codebase enforces type safety through pyright strict mode and uses consistent formatting via ruff. All logging and error reporting should maintain consistency across the system.

Relevance to PR Changes

The PR modifies crates/weaverd/src/health.rs to standardize error field formatting using the Display trait. This aligns with the repository's broader design principle of maintaining consistent data contracts and structured error reporting across RPC communication boundaries.

The changes (adding display_error() helper and updating bootstrap_failed and backend_failed functions) ensure that both health event failures emit errors in the same Display format, supporting the schema consistency requirements inherent in weaver's msgspec-based data model system.

Note: The Deepwiki documentation search revealed the codebase is primarily Python-based, but references a Rust implementation (crates/weaverd/src/) that appears to be an alternative implementation or related component. The health monitoring and error formatting patterns documented for the Python daemon are likely applicable to reviewing these Rust changes.

⏰ 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 (4)
crates/weaverd/src/health.rs (4)

6-7: Import addition is appropriate.

The std::fmt import is necessary for the Display trait bound in the new helper function.


78-78: Display formatting is now explicit and consistent.

Using the display_error helper makes the formatting choice clear and provides a single point of change for error field formatting.


91-92: Documentation clearly explains the formatting choice.

The comment appropriately documents the implementation-specific detail (Display formatting) and explains the rationale (schema consistency with bootstrap_failed). Placement on the impl method rather than the trait is correct, as this is implementation detail.


99-99: Consistent error formatting across health events.

The change achieves the PR objective: both bootstrap_failed and backend_failed now explicitly use Display formatting via the helper.

Comment thread crates/weaverd/src/health.rs Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3565244 and a59fc33.

📒 Files selected for processing (1)
  • crates/weaverd/src/health.rs (3 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/weaverd/src/health.rs

⚙️ CodeRabbit configuration file

**/*.rs: * Seek to keep the cognitive complexity of functions no more than 9.

  • Adhere to single responsibility and CQRS
  • Place function attributes after doc comments.
  • Do not use return in single-line functions.
  • Move conditionals with >2 branches into a predicate function.
  • Avoid unsafe unless 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 rstest fixtures for shared setup and to avoid repetition between tests.
  • Replace duplicated tests with #[rstest(...)] parameterised cases.
  • Prefer mockall for mocks/stubs.
  • Prefer .expect() over .unwrap() in tests.
  • .expect() and .unwrap() are forbidden outside of tests. Errors must be propagated.
  • 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...

Files:

  • crates/weaverd/src/health.rs
**/*.{rs,md}

📄 CodeRabbit inference engine (AGENTS.md)

Use consistent en-GB-oxendict spelling/grammar in comments and documentation (except LICENSE naming)

Files:

  • crates/weaverd/src/health.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/weaverd/src/health.rs
🧬 Code graph analysis (1)
crates/weaverd/src/health.rs (2)
crates/weaverd/src/backends.rs (2)
  • fmt (28-35)
  • message (109-111)
crates/weaverd/src/tests/support/reporter.rs (1)
  • backend_failed (76-81)
⏰ 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 (3)
crates/weaverd/src/health.rs (3)

6-7: Import addition is correct and necessary.

The std::fmt import is required for the fmt::Display trait bound in the helper function and follows standard import organisation.


78-78: Explicit error formatting improves consistency.

The change from %error to display_error(error) makes the Display formatting choice explicit and aligns with the unified error field format documented in the PR objectives.


91-99: Documentation clarifies formatting rationale.

The doc comment clearly explains the Display formatting choice and the implementation now matches bootstrap_failed consistently. The change achieves the PR's stated objective.

Comment thread crates/weaverd/src/health.rs Resolved
@leynos
leynos merged commit 28182c6 into main Oct 30, 2025
@leynos
leynos deleted the codex/unify-error-field-formatting branch October 30, 2025 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant