Skip to content

Improve WireframeProtocol docs and fragment tests header#452

Merged
leynos merged 2 commits intomainfrom
docs-fix-wireframeprotocol-fragment-tests-v0xtck
Feb 9, 2026
Merged

Improve WireframeProtocol docs and fragment tests header#452
leynos merged 2 commits intomainfrom
docs-fix-wireframeprotocol-fragment-tests-v0xtck

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Feb 5, 2026

Summary

  • Improves documentation for WireframeProtocol and its usage in with_protocol
  • Adds descriptive header for fragmentation tests in fragment/tests.rs

Changes

Documentation

  • src/hooks.rs: Expanded WireframeProtocol documentation to explain that while a custom ProtocolError type is allowed, WireframeApp::with_protocol currently requires ProtocolError = () to enable dynamic dispatch with a uniform interface across connections. Includes note about potential future relaxation.
  • src/app/builder_protocol.rs: Updated with_protocol method docs to clearly state the current constraint of ProtocolError = () and the rationale for keeping the error type uniform and safe for the builder API.
  • src/fragment/tests.rs: Added module-level documentation describing the fragmentation/reassembly test scope and coverage (e.g., FragmentHeader access, FragmentSeries ordering/validation, Fragmenter splitting and IDs, and Reassembler assembly with limits/expiry).

Tests

  • No functional changes; documentation-focused updates only.

Test plan

  • cargo test to ensure builds/tests are unaffected
  • cargo doc to verify documentation compiles cleanly

◳ Generated by DevBoxer


ℹ️ Tag @devboxerhub to ask questions and address PR feedback

📎 Task: https://www.devboxer.com/task/96d25cd1-2470-49fd-a839-d9c46ff4608c

📝 Closes #435

Summary by Sourcery

Document current ProtocolError = () constraint for pluggable protocols and clarify fragmentation test coverage.

Enhancements:

  • Clarify WireframeProtocol documentation around use of custom ProtocolError and the current ProtocolError = () requirement when used with WireframeApp::with_protocol.
  • Update WireframeApp::with_protocol builder docs to explain the rationale for enforcing a unit ProtocolError for dynamic dispatch and a uniform interface.
  • Document the scope and behavior covered by fragmentation and reassembly tests in fragment/tests.rs without changing test logic.

Documentation:

  • Expand protocol-related API documentation to better describe error type constraints and fragmentation test responsibilities.

Added detailed comments to `WireframeApp::with_protocol` and the `WireframeProtocol` trait explaining that currently `ProtocolError` must be `()`. This ensures a uniform interface for dynamic dispatch and prevents leaking application-specific errors. Also added unit test module documentation for fragmentation and reassembly.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Feb 5, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Improves internal documentation around WireframeProtocol error type constraints and clarifies the scope of fragmentation/reassembly tests, without changing runtime behavior.

Class diagram for WireframeProtocol and WireframeApp with_protocol documentation constraint

classDiagram
    class WireframeProtocol {
        <<trait>>
        +type Frame
        +type ProtocolError
        +on_connect(ctx: ConnectionContext) void
        +before_send_frame(frame: Frame, ctx: ConnectionContext) void
        +on_frame(frame: Frame, ctx: ConnectionContext) void
        +on_command_complete(ctx: ConnectionContext) void
        +handle_error(error: ProtocolError, ctx: ConnectionContext) void
        +on_eof(error: EofError, partial_data: bytes, ctx: ConnectionContext) void
    }

    class WireframeApp {
        +builder() WireframeAppBuilder
    }

    class WireframeAppBuilder {
        +with_protocol(protocol: P) WireframeAppBuilder
    }

    WireframeAppBuilder --> WireframeApp : builds
    WireframeAppBuilder ..> WireframeProtocol : with_protocol<P>

    note for WireframeProtocol "When installed via WireframeApp.with_protocol, ProtocolError must currently be () for dynamic dispatch and a uniform interface across connections"
Loading

File-Level Changes

Change Details Files
Clarify WireframeProtocol error type usage and examples to match current WireframeApp::with_protocol constraints.
  • Expanded WireframeProtocol trait docs to explain that WireframeApp::with_protocol currently requires ProtocolError = () for dynamic dispatch and a uniform interface.
  • Added note that the ProtocolError constraint may be relaxed in a future release.
  • Updated documentation examples to use ProtocolError = () instead of a custom error type.
src/hooks.rs
Clarify builder with_protocol API constraints and rationale for ProtocolError = () requirement.
  • Augmented with_protocol method documentation to state that protocols must use ProtocolError = ().
  • Explained safety and API design reasons for keeping error types uniform and not exposing application-specific errors via the builder.
src/app/builder_protocol.rs
Document the scope and coverage of fragmentation and reassembly tests.
  • Added module-level documentation describing what fragmentation tests cover, including FragmentHeader access, FragmentSeries ordering/validation, Fragmenter splitting/IDs, and Reassembler assembly with limits/expiry.
src/fragment/tests.rs

Assessment against linked issues

Issue Objective Addressed Explanation
#435 Clarify and correct documentation around WireframeProtocol and WireframeApp::with_protocol so that the documented ProtocolError behavior matches the actual constraint (ProtocolError = ()) or the code is generalized to support arbitrary protocol error types.
#435 Add appropriate module-level //! documentation to src/fragment/tests.rs describing the fragmentation/reassembly test module’s purpose and coverage.

Possibly linked issues


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
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 5, 2026

Summary by CodeRabbit

  • Documentation
    • Clarified protocol builder docs and updated examples to show the required unit-style error type for dynamic dispatch.
    • Expanded test module documentation covering fragmentation, reassembly, ID handling, size and expiry behaviours.

Walkthrough

State that documentation-only changes were applied: add a doc comment to with_protocol clarifying the ProtocolError = () requirement for dynamic dispatch, update WireframeProtocol-related docs and examples to use ProtocolError = (), and add module-level documentation to fragmentation tests. No public signatures or behaviour changed.

Changes

Cohort / File(s) Summary
Protocol documentation
src/app/builder_protocol.rs, src/hooks.rs
Added and updated documentation and examples to clarify that when using dynamic dispatch the protocol error type must be (). No API signature or behavioural changes.
Test module documentation
src/fragment/tests.rs
Added module-level //! documentation describing the fragmentation and reassembly test coverage and intent. No test logic changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

✨ Docs aligned, the comments sing tonight,
Declare the error empty, tidy and bright,
Tests now framed with a guiding line,
Keep the interfaces neat and fine,
Ship the clarity — let the code take flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main changes: improving WireframeProtocol documentation and adding fragmentation test module documentation.
Description check ✅ Passed The description clearly relates to the changeset, detailing documentation improvements to hooks.rs, builder_protocol.rs, and tests.rs with specific rationale for each change.
Linked Issues check ✅ Passed The PR fully addresses both objectives from issue #435: clarifying WireframeProtocol documentation regarding ProtocolError = () constraint [#435], and adding module-level documentation to fragment/tests.rs [#435].
Out of Scope Changes check ✅ Passed All changes directly address the objectives from #435; documentation additions to hooks.rs, builder_protocol.rs, and fragment/tests.rs are entirely within scope with no extraneous modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs-fix-wireframeprotocol-fragment-tests-v0xtck

No actionable comments were generated in the recent review. 🎉


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

@leynos leynos marked this pull request as ready for review February 5, 2026 23:13
sourcery-ai[bot]

This comment was marked as resolved.

In the WireframeProtocol trait example, changed the handle_error function to remove the unused `error` parameter and updated the logging statement accordingly to avoid unused variable warnings and improve clarity.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Feb 9, 2026

@coderabbitai Have the following now been resolved?

Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/hooks.rs:57-59` </location>
<code_context>
     /// impl WireframeProtocol for MyProtocol {
     ///     type Frame = Vec<u8>;
-    ///     type ProtocolError = String;
+    ///     type ProtocolError = ();
     ///
     ///     fn handle_error(&self, error: Self::ProtocolError, _ctx: &mut ConnectionContext) {
     ///         tracing::error!(error = %error, "protocol error");
</code_context>

<issue_to_address>
**issue (bug_risk):** The example using `ProtocolError = ()` conflicts with logging the error value.

With `type ProtocolError = ()`, the `error` parameter is always unit, so `tracing::error!(error = %error, ...)` is misleading and won’t compile because `()` doesn’t implement `Display`. To keep the example realistic and compilable, either:

* Use a concrete printable error type again (e.g. `String`) and add a brief note that `with_protocol` currently requires `ProtocolError = ()`, or
* Keep `ProtocolError = ()` but change the handler to log only a static message (without `%error`).
</issue_to_address>

@coderabbitai

This comment was marked as resolved.

@leynos leynos merged commit a3e5da5 into main Feb 9, 2026
6 checks passed
@leynos leynos deleted the docs-fix-wireframeprotocol-fragment-tests-v0xtck branch February 9, 2026 01:46
leynos added a commit that referenced this pull request Feb 9, 2026
* docs(protocol): add docs clarifying that ProtocolError must be ()

Added detailed comments to `WireframeApp::with_protocol` and the `WireframeProtocol` trait explaining that currently `ProtocolError` must be `()`. This ensures a uniform interface for dynamic dispatch and prevents leaking application-specific errors. Also added unit test module documentation for fragmentation and reassembly.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>

* docs(hooks): simplify example by removing unused error variable

In the WireframeProtocol trait example, changed the handle_error function to remove the unused `error` parameter and updated the logging statement accordingly to avoid unused variable warnings and improve clarity.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>

---------

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
leynos added a commit that referenced this pull request Feb 9, 2026
* docs(migration): add migration guide for v0.1.0 to v0.2.0

- Introduces v0.1.0 to v0.2.0 migration guide detailing breaking changes
- Notes removal of deprecated payload() methods in favor of into_payload()
- Updates existing docs for minor formatting improvements
- Removes deprecated payload accessor methods from PacketParts and FragmentParts

These changes improve developer experience by documenting required migration steps and cleaning up deprecated APIs.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>

* Split preamble tests into modules

Move preamble tests into grouped modules under tests/preamble/\nwith shared helpers to keep file sizes under the limit.\n\nAdd a Makefile typecheck target to match the commit gates.

* Refine preamble tests and docs

Address review feedback by clarifying the migration guide intro and\nkeeping payload-accessor documentation neutral.\n\nRefactor preamble tests to avoid excessive nesting and add helper\nRustdoc examples for shared test utilities.

* Address review fixes and docs updates

Propagate response send errors and tidy logging output.
Update client builder docs and buffer sizing constant.
Refactor extractor errors/docs and server config tests to align
with fixture guidance.
Refresh migration guide wording and payload accessor example.

* Deduplicate lifecycle builder rebuild

Reuse a shared helper when changing connection state types.
This keeps lifecycle builder reconstruction aligned with the core
builder and removes the ad hoc OnceCell instantiation.

* test(server/config): improve backoff configuration tests with multiple scenarios

Expanded and diversified the backoff configuration tests for WireframeServer to cover multiple edge cases and delay configurations. Added parameterized tests using rstest, verifying initial and max delay clamping, swapping, and defaults for better test coverage and robustness.

Also:
- Cleaned up unused test utility functions and redundant assertions.
- Enhanced diagnostics in test assertions with scenario descriptions.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>

* Refine frame handling test fixtures

Ensure rstest fixtures avoid clippy lint issues by adding\nexplicit harness assertions and applying rustfmt-friendly layout\nfor test setup helpers.

* Refine frame handling test harness

Adjust response logging and public doc comments in frame handling,\nand reuse a shared framed harness with client/server endpoints\nfor response tests. Also normalize message docs to use\nOxford -ize spelling.

* Refactor frame handling tests

Combine send_response_payload cases with a shared harness that\nincludes both client and server framed endpoints, reducing\nduplicate setup while preserving payload assertions.

* refactor(tests): simplify codec recovery tests and improve server config tests

- Remove unused rstest fixtures in codec recovery tests and initialize variables directly within test functions
- Add helper assert_local_addr_matches_listener function in server config tests to reduce duplication
- Refactor server config tests to use the new helper for clearer, more concise assertions

Additionally:
- Fix client codec initialization in frame_handling tests for clarity
- Minor wording improvement in migration guide docs

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>

* Improve WireframeProtocol docs and fragment tests header (#452)

* docs(protocol): add docs clarifying that ProtocolError must be ()

Added detailed comments to `WireframeApp::with_protocol` and the `WireframeProtocol` trait explaining that currently `ProtocolError` must be `()`. This ensures a uniform interface for dynamic dispatch and prevents leaking application-specific errors. Also added unit test module documentation for fragmentation and reassembly.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>

* docs(hooks): simplify example by removing unused error variable

In the WireframeProtocol trait example, changed the handle_error function to remove the unused `error` parameter and updated the logging statement accordingly to avoid unused variable warnings and improve clarity.

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>

---------

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>

* Fix PR review regressions in response handling

Restore non-fatal handling for response fragmentation and codec encoding
errors in frame handling so handler payload mistakes do not disconnect
healthy client connections.

Keep transport failures fatal by propagating non-encoding send errors.
Also restore public visibility for MessageRequest.app_data to avoid a
breaking API change and remove the panicking rstest fixture pattern in
frame-handling tests.

* Split codec recovery tests into dedicated module

Move recovery tests out of src/codec/recovery.rs into
src/codec/recovery/tests.rs so the production module stays under
the 400-line file-size limit.

Add rstest fixtures for DefaultRecoveryPolicy and CodecErrorContext
and reuse them in tests that previously duplicated setup.

* Split extractor module and refine frame-handling tests

Decompose extractor into a submodule layout by moving concrete
extractor implementations into src/extractor/extractors.rs and
converting extractor to directory module layout.

This keeps src/extractor/mod.rs below the 400-line threshold while
preserving the public extractor API via re-exports.

Update frame-handling tests to add the required module-level //! docs,
introduce an rstest harness fixture, and inject it into both tests to
remove duplicated setup.

---------

Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix documentation inconsistencies and missing module docs

1 participant