Conversation
Reviewer's GuideImplements typed protocol error handling by adding a handle_error hook to the WireframeProtocol trait and ProtocolHooks, updating ConnectionActor to distinguish and propagate protocol vs I/O errors, enhancing documentation for WireframeError, and extending tests accordingly. Sequence diagram for protocol error handling in ConnectionActorsequenceDiagram
participant ConnectionActor
participant ProtocolHooks
participant WireframeProtocol
participant Context as ConnectionContext
ConnectionActor->>ProtocolHooks: handle_response(Some(Err(WireframeError::Protocol(e))))
ProtocolHooks->>WireframeProtocol: handle_error(e, &mut Context)
WireframeProtocol-->>ProtocolHooks: (custom error handling)
ProtocolHooks->>ConnectionActor: (returns)
ConnectionActor->>ProtocolHooks: on_command_end(&mut Context)
ProtocolHooks-->>ConnectionActor: (returns)
Note over ConnectionActor: Protocol error handled, actor continues
Entity relationship diagram for ProtocolHooks and WireframeProtocolerDiagram
WIREFRAME_PROTOCOL ||--o{ PROTOCOL_HOOKS : "implements"
PROTOCOL_HOOKS {
on_connection_setup Option
before_send Option
on_command_end Option
handle_error Option
}
WIREFRAME_PROTOCOL {
Frame
ProtocolError
}
Class diagram for updated protocol error handlingclassDiagram
class WireframeProtocol {
+on_connection_setup(PushHandle<Frame>, &mut ConnectionContext)
+before_send(&mut Frame, &mut ConnectionContext)
+on_command_end(&mut ConnectionContext)
+handle_error(ProtocolError, &mut ConnectionContext)
<<trait>>
type Frame
type ProtocolError
}
class ProtocolHooks {
+on_connection_setup: Option<OnConnectionSetupHook<F>>
+before_send: Option<BeforeSendHook<F>>
+on_command_end: Option<OnCommandEndHook>
+handle_error: Option<HandleErrorHook<E>>
+on_connection_setup(PushHandle<F>, &mut ConnectionContext)
+before_send(&mut F, &mut ConnectionContext)
+on_command_end(&mut ConnectionContext)
+handle_error(E, &mut ConnectionContext)
+from_protocol(protocol: Arc<P>)
<<generic<F, E>>
}
class ConnectionActor {
-hooks: ProtocolHooks<F, E>
+run(&mut self, out: &mut Vec<F>) -> Result<(), WireframeError<E>>
+handle_response(res: Option<Result<F, WireframeError<E>>>, out: &mut Vec<F>, state: &mut State) -> Result<(), WireframeError<E>>
<<generic<F, E>>
}
WireframeProtocol <|.. ProtocolHooks : uses
ProtocolHooks <|-- ConnectionActor : member
class WireframeError {
<<enum<E=()>>
+Protocol(E)
+Io(std::io::Error)
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThe changes introduce a generic error parameter to the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ConnectionActor
participant ProtocolHooks
participant Protocol
Client->>ConnectionActor: Send/receive frames
ConnectionActor->>ProtocolHooks: before_send / on_command_end
ConnectionActor->>Protocol: Process frame
Protocol-->>ConnectionActor: Result or ProtocolError
alt ProtocolError
ConnectionActor->>ProtocolHooks: handle_error(error, ctx)
ProtocolHooks-->>ConnectionActor: (handled, continue)
else IO Error
ConnectionActor-->>Client: Return WireframeError (terminates)
end
Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/connection.rs:368` </location>
<code_context>
out.push(frame);
}
+ Some(Err(WireframeError::Protocol(e))) => {
+ self.hooks.handle_error(e, &mut self.ctx);
+ state.mark_closed();
+ self.hooks.on_command_end(&mut self.ctx);
</code_context>
<issue_to_address>
Do not consume protocol errors silently; ensure they are logged or observable for debugging.
Currently, protocol errors are passed to the `handle_error` hook and then the command is ended, but there is no guarantee that the error is logged or otherwise made observable. This could make debugging difficult if the hook is a no-op. Consider at least logging the error or providing a default observable behavior.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| out.push(frame); | ||
| } | ||
| Some(Err(WireframeError::Protocol(e))) => { | ||
| self.hooks.handle_error(e, &mut self.ctx); |
There was a problem hiding this comment.
issue (review_instructions): Do not consume protocol errors silently; ensure they are logged or observable for debugging.
Currently, protocol errors are passed to the handle_error hook and then the command is ended, but there is no guarantee that the error is logged or otherwise made observable. This could make debugging difficult if the hook is a no-op. Consider at least logging the error or providing a default observable behavior.
Review instructions:
Path patterns: **/*
Instructions:
Create code-review comments for ALL issues. Avoid making general observations or non-specific feedback if at all possible.
Don't hold back. Review changes as if your life depends upon it.
Use the imperative mood when writing pull request review feedback.
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 (5)
src/app.rs(1 hunks)src/connection.rs(6 hunks)src/hooks.rs(4 hunks)src/response.rs(1 hunks)tests/connection_actor.rs(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
src/response.rssrc/app.rstests/connection_actor.rssrc/connection.rssrc/hooks.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.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 must use en-GB-oxendict 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.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/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
src/response.rssrc/app.rstests/connection_actor.rssrc/connection.rssrc/hooks.rs
🧬 Code Graph Analysis (2)
tests/connection_actor.rs (2)
src/connection.rs (4)
new(101-114)new(444-453)default(50-55)with_hooks(118-138)src/hooks.rs (1)
default(81-88)
src/connection.rs (1)
src/hooks.rs (1)
default(81-88)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build-test
- GitHub Check: Analyze (actions)
🔇 Additional comments (10)
src/response.rs (1)
75-90: Documentation looks good!The examples clearly demonstrate both protocol error conversion and I/O error creation patterns, which will help users understand how to work with the
WireframeErrortype.src/app.rs (1)
409-409: Type signature correctly updated.The addition of the
()error type parameter aligns with the protocol configuration on line 84 whereProtocolError = ().tests/connection_actor.rs (3)
122-143: Test correctly validates protocol error handling.The test properly verifies that:
- Protocol errors invoke the
handle_errorcallback exactly once- Frames before the error are still processed and output
- The connection continues to process remaining frames
Good use of atomics to track callback invocations in the test.
145-162: New test properly verifies I/O error behaviour.The test correctly validates that I/O errors:
- Propagate and terminate the connection
- Return as
Err(WireframeError::Io(_))- Still allow frames before the error to be processed
This complements the protocol error test nicely, demonstrating the different handling paths.
224-224: Generic parameters correctly specified.The explicit type parameters
<u8, ()>are necessary for the updatedProtocolHookstype and ensure proper type inference.Also applies to: 254-254
src/hooks.rs (2)
65-87: Struct changes follow established patterns.The new
handle_errorfield and its type alias follow the same conventions as the existing hooks, maintaining consistency in the codebase.
113-117: Implementation correctly integrates the error handler.The
handle_errormethod and its integration infrom_protocolfollow the established patterns for hook methods, properly managing the optional callback.Also applies to: 139-148
src/connection.rs (3)
76-76: Type updates correctly propagate the error parameter.The changes properly thread the error type
Ethrough theConnectionActorand its constructors, maintaining type safety.Also applies to: 107-113, 123-123
156-156: Documentation clearly explains error handling behaviour.The updates effectively communicate that protocol errors are handled internally via hooks whilst I/O errors propagate to the caller.
Also applies to: 353-355
367-372: Error handling correctly implements the design.The implementation properly:
- Invokes the error handler for protocol errors
- Marks the response as closed
- Calls the command end hook for cleanup
- Propagates I/O errors to maintain connection termination semantics
This provides a clean separation between recoverable protocol errors and fatal I/O errors.
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 (3)
src/connection.rs(7 hunks)src/hooks.rs(4 hunks)tests/connection_actor.rs(4 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
tests/connection_actor.rssrc/hooks.rssrc/connection.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.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 must use en-GB-oxendict 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.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/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
tests/connection_actor.rssrc/hooks.rssrc/connection.rs
🧬 Code Graph Analysis (2)
tests/connection_actor.rs (2)
src/connection.rs (5)
new(102-115)new(446-455)default(50-55)with_hooks(119-139)shutdown_token(149-149)src/hooks.rs (1)
default(83-90)
src/connection.rs (2)
src/response.rs (2)
fmt(56-63)fmt(110-115)src/hooks.rs (1)
default(83-90)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build-test
🔇 Additional comments (5)
tests/connection_actor.rs (3)
122-143: LGTM! Well-structured test for error handler invocation.The test correctly verifies that protocol errors trigger the error handler exactly once and that frame processing continues up to the error point.
145-163: LGTM! Good test coverage for logging behaviour.The test properly verifies that protocol errors generate warning logs with appropriate content.
164-181: LGTM! Comprehensive test for I/O error handling.The test correctly verifies that I/O errors terminate the connection and are propagated to the caller.
src/hooks.rs (1)
39-53: Documentation example is clear and focused.The example effectively demonstrates the
handle_errormethod usage without unnecessary complexity. The past review comment appears to have been addressed.src/connection.rs (1)
354-382: LGTM! Robust error handling implementation.The differentiated error handling correctly:
- Logs protocol errors as warnings (addressing the past review comment about observability)
- Invokes the error handler for custom handling
- Allows the actor to continue after protocol errors
- Propagates I/O errors to terminate the connection
| /// Handle to the global logger with exclusive access. | ||
| struct LoggerHandle { | ||
| guard: std::sync::MutexGuard<'static, Logger>, | ||
| } | ||
|
|
||
| impl LoggerHandle { | ||
| fn new() -> Self { | ||
| static LOGGER: OnceLock<Mutex<Logger>> = OnceLock::new(); | ||
|
|
||
| let logger = LOGGER.get_or_init(|| Mutex::new(Logger::start())); | ||
| let guard = logger | ||
| .lock() | ||
| .expect("failed to acquire global logger lock; a previous test may still hold it"); | ||
|
|
||
| Self { guard } | ||
| } | ||
| } | ||
|
|
||
| impl std::ops::Deref for LoggerHandle { | ||
| type Target = Logger; | ||
|
|
||
| fn deref(&self) -> &Self::Target { &self.guard } | ||
| } | ||
|
|
||
| impl std::ops::DerefMut for LoggerHandle { | ||
| fn deref_mut(&mut self) -> &mut Self::Target { &mut self.guard } | ||
| } | ||
|
|
||
| #[allow(unused_braces)] | ||
| #[fixture] | ||
| fn logger() -> LoggerHandle { LoggerHandle::new() } |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Consider test serialisation to prevent flaky parallel test execution.
The global logger with mutex could cause test failures if tests run in parallel and one panics while holding the lock. Consider using the serial_test crate to ensure these tests run sequentially.
Add the serial_test dependency to Cargo.toml:
[dev-dependencies]
serial_test = "3.1"Then annotate tests using the logger with #[serial]:
+use serial_test::serial;
#[rstest]
#[tokio::test]
+#[serial]
async fn protocol_error_logs_warning(🤖 Prompt for AI Agents
In tests/connection_actor.rs around lines 234 to 264, the global logger uses a
mutex which can cause flaky test failures if tests run in parallel and one
panics while holding the lock. To fix this, add the serial_test crate as a
dev-dependency in Cargo.toml with version 3.1, then annotate all tests that use
the logger with #[serial] to ensure they run sequentially and avoid concurrent
access issues.
There was a problem hiding this comment.
Gates Passed
6 Quality Gates Passed
See analysis details in CodeScene
Quality Gate Profile: Pay Down Tech Debt
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
There was a problem hiding this comment.
Gates Passed
6 Quality Gates Passed
See analysis details in CodeScene
Quality Gate Profile: Pay Down Tech Debt
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
docs/asynchronous-outbound-messaging-design.md(1 hunks)docs/asynchronous-outbound-messaging-roadmap.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
`docs/**/*.md`: Documentation must use en-GB-oxendict spelling and grammar (with the exception of "license" which is to be left unchanged for community consistency).
docs/**/*.md: Documentation must use en-GB-oxendict spelling and grammar (with the exception of "license" which is to be left unchanged for community consistency).
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/asynchronous-outbound-messaging-design.md
`**/*.md`: Validate Markdown files using `markdownlint *.md **/*.md`. Run `mdfor...
**/*.md: Validate Markdown files usingmarkdownlint *.md **/*.md.
Runmdformat-allafter any documentation changes to format all Markdown files and fix table markup.
Validate Markdown Mermaid diagrams using thenixieCLI. The tool is already installed; runnixie *.md **/*.mddirectly instead of usingnpx.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks must be wrapped at 120 columns.
Tables and headings must not be wrapped.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/asynchronous-outbound-messaging-design.md
`docs/**/*.md`: Provide user guides and examples demonstrating server-initiated messaging.
docs/**/*.md: Provide user guides and examples demonstrating server-initiated messaging.
📄 Source: CodeRabbit Inference Engine (docs/asynchronous-outbound-messaging-roadmap.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/asynchronous-outbound-messaging-design.md
`docs/**/*.md`: Conventions for writing project documentation should follow the rules outlined in the documentation style guide.
docs/**/*.md: Conventions for writing project documentation should follow the rules outlined in the documentation style guide.
📄 Source: CodeRabbit Inference Engine (docs/contents.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/asynchronous-outbound-messaging-design.md
`docs/**/*.md`: Use British English based on the Oxford English Dictionary (en-o...
docs/**/*.md: Use British English based on the Oxford English Dictionary (en-oxendict) for documentation.
The word "outwith" is acceptable in documentation.
Keep US spelling when used in an API, for examplecolor.
Use the Oxford comma in documentation.
Company names are treated as collective nouns (e.g., "Lille Industries are expanding").
Write headings in sentence case in documentation.
Use Markdown headings (#,##,###, etc.) in order without skipping levels.
Follow markdownlint recommendations for Markdown files.
Provide code blocks and lists using standard Markdown syntax.
Always use fenced code blocks with a language identifier; useplaintextfor non-code text.
Use-as the first level bullet and renumber lists when items change.
Prefer inline links using[text](url)or angle brackets around the URL in Markdown.
Expand any uncommon acronym on first use, for example, Continuous Integration (CI).
Wrap paragraphs at 80 columns in documentation.
Wrap code at 120 columns in documentation.
Do not wrap tables in documentation.
Use footnotes referenced with[^label]in documentation.
Include Mermaid diagrams in documentation where it adds clarity.
When embedding figures in documentation, useand provide concise alt text describing the content.
Add a short description before each Mermaid diagram in documentation so screen readers can understand it.
📄 Source: CodeRabbit Inference Engine (docs/documentation-style-guide.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/asynchronous-outbound-messaging-design.md
`docs/**/*.md`: Write the official documentation for the new features. Create se...
docs/**/*.md: Write the official documentation for the new features. Create separate guides for "Duplex Messaging & Pushes", "Streaming Responses", and "Message Fragmentation". Each guide must include runnable examples and explain the relevant concepts and APIs.
📄 Source: CodeRabbit Inference Engine (docs/wireframe-1-0-detailed-development-roadmap.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/asynchronous-outbound-messaging-design.md
`**/*.md`: * Avoid 2nd person or 1st person pronouns ("I", "you", "we") * Use en...
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-oxendic spelling and grammar.
- Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
- Code blocks should be wrapped to 120 columns.
- Headings must not be wrapped.
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-roadmap.mddocs/asynchronous-outbound-messaging-design.md
🪛 LanguageTool
docs/asynchronous-outbound-messaging-design.md
[uncategorized] ~605-~605: Do not mix variants of the same word (‘serialise’ and ‘serialize’) within a single text.
Context: ...s allows the protocol implementation to serialise a domain-specific error frame before th...
(EN_WORD_COHERENCY)
⏰ Context from checks skipped due to timeout of 240000ms (1)
- GitHub Check: build-test
| - [x] **Typed `WireframeError`** for recoverable protocol errors | ||
| ([Design §5][design-errors]). |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Enforce roadmap checkbox & line-wrap consistency
The newly-checked item mixes lowercase [x] with an earlier uppercase [X], and the bullet now exceeds the mandated 80-column wrap limit. Align the checkbox style and wrap the link on a new indented line:
- - [x] **Typed `WireframeError`** for recoverable protocol errors ([Design §5][design-errors]).
+ - [x] **Typed `WireframeError`** for recoverable protocol errors
+ ([Design §5][design-errors]).This keeps the bullet under 80 columns and preserves list readability.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In docs/asynchronous-outbound-messaging-roadmap.md around lines 43 to 44, the
checklist item uses a lowercase [x] instead of the uppercase [X] used earlier,
and the line exceeds the 80-column limit. Change the checkbox to uppercase [X]
for consistency and wrap the link onto a new indented line so the bullet point
stays within 80 columns, improving readability and maintaining style
consistency.
There was a problem hiding this comment.
Gates Passed
6 Quality Gates Passed
See analysis details in CodeScene
Quality Gate Profile: Pay Down Tech Debt
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 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 (3)
Cargo.toml(1 hunks)docs/asynchronous-outbound-messaging-design.md(1 hunks)tests/connection_actor.rs(4 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
`Cargo.toml`: Use explicit version ranges in `Cargo.toml` and keep dependencies up-to-date.
Cargo.toml: Use explicit version ranges inCargo.tomland keep dependencies up-to-date.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
Cargo.toml
`**/*.rs`: Comment why, not what. Explain assumptions, edge cases, trade-offs, o...
**/*.rs: Comment why, not what. Explain assumptions, edge cases, trade-offs, or complexity. Don't echo the obvious.
Comments must use en-GB-oxendict spelling and grammar.
Function documentation must include clear examples.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
tests/connection_actor.rs
`**/*.rs`: * Seek to keep the cyclomatic complexity of functions no more than 12...
**/*.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 must use en-GB-oxendict 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.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/
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
tests/connection_actor.rs
`docs/**/*.md`: Documentation must use en-GB-oxendict spelling and grammar (with the exception of "license" which is to be left unchanged for community consistency).
docs/**/*.md: Documentation must use en-GB-oxendict spelling and grammar (with the exception of "license" which is to be left unchanged for community consistency).
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-design.md
`**/*.md`: Validate Markdown files using `markdownlint *.md **/*.md`. Run `mdfor...
**/*.md: Validate Markdown files usingmarkdownlint *.md **/*.md.
Runmdformat-allafter any documentation changes to format all Markdown files and fix table markup.
Validate Markdown Mermaid diagrams using thenixieCLI. The tool is already installed; runnixie *.md **/*.mddirectly instead of usingnpx.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks must be wrapped at 120 columns.
Tables and headings must not be wrapped.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-design.md
`docs/**/*.md`: Provide user guides and examples demonstrating server-initiated messaging.
docs/**/*.md: Provide user guides and examples demonstrating server-initiated messaging.
📄 Source: CodeRabbit Inference Engine (docs/asynchronous-outbound-messaging-roadmap.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-design.md
`docs/**/*.md`: Conventions for writing project documentation should follow the rules outlined in the documentation style guide.
docs/**/*.md: Conventions for writing project documentation should follow the rules outlined in the documentation style guide.
📄 Source: CodeRabbit Inference Engine (docs/contents.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-design.md
`docs/**/*.md`: Use British English based on the Oxford English Dictionary (en-o...
docs/**/*.md: Use British English based on the Oxford English Dictionary (en-oxendict) for documentation.
The word "outwith" is acceptable in documentation.
Keep US spelling when used in an API, for examplecolor.
Use the Oxford comma in documentation.
Company names are treated as collective nouns (e.g., "Lille Industries are expanding").
Write headings in sentence case in documentation.
Use Markdown headings (#,##,###, etc.) in order without skipping levels.
Follow markdownlint recommendations for Markdown files.
Provide code blocks and lists using standard Markdown syntax.
Always use fenced code blocks with a language identifier; useplaintextfor non-code text.
Use-as the first level bullet and renumber lists when items change.
Prefer inline links using[text](url)or angle brackets around the URL in Markdown.
Expand any uncommon acronym on first use, for example, Continuous Integration (CI).
Wrap paragraphs at 80 columns in documentation.
Wrap code at 120 columns in documentation.
Do not wrap tables in documentation.
Use footnotes referenced with[^label]in documentation.
Include Mermaid diagrams in documentation where it adds clarity.
When embedding figures in documentation, useand provide concise alt text describing the content.
Add a short description before each Mermaid diagram in documentation so screen readers can understand it.
📄 Source: CodeRabbit Inference Engine (docs/documentation-style-guide.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-design.md
`docs/**/*.md`: Write the official documentation for the new features. Create se...
docs/**/*.md: Write the official documentation for the new features. Create separate guides for "Duplex Messaging & Pushes", "Streaming Responses", and "Message Fragmentation". Each guide must include runnable examples and explain the relevant concepts and APIs.
📄 Source: CodeRabbit Inference Engine (docs/wireframe-1-0-detailed-development-roadmap.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-design.md
`**/*.md`: * Avoid 2nd person or 1st person pronouns ("I", "you", "we") * Use en...
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-oxendic spelling and grammar.
- Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
- Code blocks should be wrapped to 120 columns.
- Headings must not be wrapped.
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-design.md
⏰ Context from checks skipped due to timeout of 240000ms (1)
- GitHub Check: build-test
🔇 Additional comments (7)
tests/connection_actor.rs (6)
122-143: Excellent test coverage for protocol error handling.The test effectively verifies that protocol errors invoke the error handler exactly once and that frames before the error are output whilst the connection remains active. The use of
Arc<AtomicUsize>for tracking error handler invocations is a clean approach.
145-163: Good test implementation following past review guidance.The test correctly uses the
#[serial]attribute to prevent concurrent logger access issues as recommended in the past review comments. The test effectively verifies that protocol errors generate warning logs without terminating the connection.
165-182: Comprehensive verification of I/O error behaviour.The test correctly demonstrates that I/O errors terminate the connection and return an error, in contrast to protocol errors which are handled internally. This provides clear behavioural distinction between the two error types.
236-266: Well-designed logger infrastructure with proper concurrency handling.The
LoggerHandlestruct provides exclusive access to the global logger through RAII, preventing the mutex issues identified in past reviews. The use ofOnceLockfor lazy initialisation and clear error messaging for lock acquisition failures demonstrates good defensive programming.
280-280: Correctly updated for new generic type signature.The addition of
<u8, ()>type parameters aligns with the updatedProtocolHookssignature that now includes an error type parameter.
310-310: Correctly updated for new generic type signature.The addition of
<u8, ()>type parameters aligns with the updatedProtocolHookssignature that now includes an error type parameter.docs/asynchronous-outbound-messaging-design.md (1)
600-668: Excellent documentation for typed protocol error handling.The new section provides comprehensive coverage of the typed protocol error feature with clear explanations, appropriate diagrams, and good technical detail. The documentation correctly follows sentence case for headings and uses consistent OED spelling. The class and sequence diagrams effectively illustrate the error handling flow and the distinction between protocol errors (handled internally) and I/O errors (which terminate connections).
| proptest = "^1.0" | ||
| loom = "^0.7" | ||
| async-stream = "0.3" | ||
| serial_test = "3.1" |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Use explicit version range for better dependency management.
The coding guidelines require explicit version ranges in Cargo.toml. Consider using a more specific version range instead of "3.1".
Apply this diff for better version specificity:
-serial_test = "3.1"
+serial_test = "3.1.0"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| serial_test = "3.1" | |
| serial_test = "3.1.0" |
🤖 Prompt for AI Agents
In Cargo.toml at line 25, replace the dependency version "3.1" for serial_test
with an explicit version range such as "^3.1" or ">=3.1, <4.0" to comply with
coding guidelines and improve dependency management by specifying compatible
versions more clearly.
Summary
WireframeProtocolwithhandle_errorfor recoverable protocol errorsProtocolHooksandConnectionActorWireframeErrorusage and new trait methodTesting
cargo fmt --allcargo clippy --all-targets --all-features -- -D warningscargo testmarkdownlint *.md docs/**/*.mdmdformat-all README.md docs/**/*.mdhttps://chatgpt.com/codex/tasks/task_e_68685a3ed63c8322959c5f1c33da81ac
Summary by Sourcery
Implement typed protocol error handling by extending the protocol trait with an error hook, updating the hooks and actor to support a generic error type, and ensuring protocol errors are handled gracefully while I/O errors propagate.
New Features:
handle_errormethod toWireframeProtocoltraitProtocolHooksandConnectionActorEnhancements:
ConnectionActorwhile propagating I/O errorsProtocolHooksover an error type and invoke error hooksprotocol_hooksand hook construction to include typed error handlerDocumentation:
WireframeErrorusage and examples inresponse.rshandle_errorhook documentation and example inhooks.rsTests: