Improve SessionRegistry active handle pruning#238
Conversation
|
Warning Rate limit exceeded@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 22 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📒 Files selected for processing (5)
Summary by CodeRabbit
WalkthroughRefactor the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant SessionRegistry
participant DashMap
Caller->>SessionRegistry: call active_handles()
SessionRegistry->>DashMap: retain (prune expired, collect live)
DashMap-->>SessionRegistry: pruned map, vector of live handles
SessionRegistry-->>Caller: return vector of live handles
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Possibly related PRs
Suggested reviewers
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. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Reviewer's GuideRefactored SessionRegistry.active_handles to consolidate pruning and handle collection into a single retain pass, and updated the outbound messaging design documentation to reflect this streamlined approach. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and found some issues that need to be addressed.
- Update the docs snippet to use PushHandle::from_arc(inner) (or the correct constructor) so it matches the Rust implementation.
- active_handles now mutates the registry by pruning stale entries—consider extracting that cleanup into its own method to keep handle collection side-effect free.
- Evaluate whether the retain-based pruning incurs higher contention or performance impact under concurrency compared to the previous remove_if approach.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Update the docs snippet to use PushHandle::from_arc(inner) (or the correct constructor) so it matches the Rust implementation.
- active_handles now mutates the registry by pruning stale entries—consider extracting that cleanup into its own method to keep handle collection side-effect free.
- Evaluate whether the retain-based pruning incurs higher contention or performance impact under concurrency compared to the previous remove_if approach.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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 (2)
docs/asynchronous-outbound-messaging-design.md(1 hunks)src/session.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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 / -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.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.
Files:
src/session.rs
**/*.md
⚙️ CodeRabbit Configuration File
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-GB-oxendict (-ize / -our) 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.
- Documents must start with a level 1 heading
- Headings must correctly increase or decrease by no more than one level at a time
- Use GitHub-flavoured Markdown style for footnotes and endnotes.
- Numbered footnotes must be numbered by order of appearance in the document.
Files:
docs/asynchronous-outbound-messaging-design.md
🧬 Code Graph Analysis (1)
src/session.rs (1)
src/push.rs (1)
from_arc(100-100)
🔇 Additional comments (2)
src/session.rs (1)
67-75: Excellent refactoring of active_handles method.The consolidation of pruning and collection into a single
retainoperation is a clean optimisation. The new implementation eliminates the need for separate iteration and explicit removal calls, making the code more efficient and easier to follow.The logic correctly retains live entries while collecting their handles, and removes dead entries in one pass.
docs/asynchronous-outbound-messaging-design.md (1)
436-445: Documentation correctly updated to match implementation.The documentation now accurately reflects the refactored
active_handlesmethod implementation. The consolidation of pruning and collection into a singleretainoperation is properly documented, maintaining consistency between the code and its specification.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🔭 Outside diff range comments (1)
docs/asynchronous-outbound-messaging-design.md (1)
419-445: Pre-allocatehandlesvector for efficiency (documentation code block).Mirror the optimisation suggested for the implementation so that the example
reflects best practice.- let mut handles = Vec::new(); + let mut handles = Vec::with_capacity(self.0.len());
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
README.md(2 hunks)docs/asynchronous-outbound-messaging-design.md(2 hunks)src/session.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.md
⚙️ CodeRabbit Configuration File
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-GB-oxendict (-ize / -our) 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.
- Documents must start with a level 1 heading
- Headings must correctly increase or decrease by no more than one level at a time
- Use GitHub-flavoured Markdown style for footnotes and endnotes.
- Numbered footnotes must be numbered by order of appearance in the document.
Files:
README.mddocs/asynchronous-outbound-messaging-design.md
**/*.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 / -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.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.
Files:
src/session.rs
🧬 Code Graph Analysis (1)
src/session.rs (1)
src/push.rs (1)
from_arc(100-100)
🪛 LanguageTool
README.md
[grammar] ~87-~87: Please add a punctuation mark at the end of paragraph.
Context: ...a binary protocol server. See the [full example](docs/rust-binary-router-library-design...
(PUNCTUATION_PARAGRAPH_END)
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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 (3)
README.md(2 hunks)docs/asynchronous-outbound-messaging-design.md(2 hunks)src/session.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.md
⚙️ CodeRabbit Configuration File
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-GB-oxendict (-ize / -our) 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.
- Documents must start with a level 1 heading
- Headings must correctly increase or decrease by no more than one level at a time
- Use GitHub-flavoured Markdown style for footnotes and endnotes.
- Numbered footnotes must be numbered by order of appearance in the document.
Files:
README.mddocs/asynchronous-outbound-messaging-design.md
**/*.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 / -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.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.
Files:
src/session.rs
🧠 Learnings (1)
📚 Learning: applies to docs/src/push.rs : sessionregistry must store weak references to pushhandleinner to avoid...
Learnt from: CR
PR: leynos/wireframe#0
File: docs/asynchronous-outbound-messaging-design.md:0-0
Timestamp: 2025-07-27T13:30:30.121Z
Learning: Applies to docs/src/push.rs : SessionRegistry must store Weak references to PushHandleInner to avoid memory leaks and provide methods to get, insert, remove, and enumerate active handles.
Applied to files:
README.md
🧬 Code Graph Analysis (1)
src/session.rs (1)
src/push.rs (1)
from_arc(100-100)
🪛 LanguageTool
README.md
[grammar] ~87-~87: Please add a punctuation mark at the end of paragraph.
Context: ...a binary protocol server. See the [full example](docs/rust-binary-router-library-design...
(PUNCTUATION_PARAGRAPH_END)
🔇 Additional comments (2)
src/session.rs (1)
61-65: Doc comment fulfils earlier request.The extra notes clearly explain the lock semantics and scope of
prune().README.md (1)
195-198: Documentation change looks good.Second-person pronouns have been removed and the guidance matches the updated API.
There was a problem hiding this comment.
Gates Failed
Enforce advisory code health rules
(1 file with Code Duplication)
Gates Passed
5 Quality Gates Passed
See analysis details in CodeScene
Reason for failure
| Enforce advisory code health rules | Violations | Code Health Impact | |
|---|---|---|---|
| session.rs | 1 advisory rule | 10.00 → 9.39 | Suppress |
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/hardening-wireframe-a-guide-to-production-resilience.md(1 hunks)src/session.rs(4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
docs/**/*.md
📄 CodeRabbit Inference Engine (docs/contents.md)
Conventions for writing project documentation as described in the documentation style guide
docs/**/*.md: Use British English based on the Oxford English Dictionary (en-oxendict) for documentation text.
The word "outwith" is acceptable in documentation.
Keep US spelling when used in an API, for examplecolor.
Use the Oxford comma in documentation text.
Treat company names as collective nouns in documentation (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 provide a language identifier for fenced code blocks; 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; avoid reference-style links like[foo][bar].
Ensure blank lines before and after bulleted lists and fenced blocks in Markdown.
Ensure tables have a delimiter line below the header row 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 sequentially numbered footnotes referenced with[^1]and place definitions at the end of the file.
Where it adds clarity, include Mermaid diagrams in documentation.
When embedding figures, useand provide concise alt text describing the content.
Add a brief description before each Mermaid diagram in documentation for screen readers.Document examples showing how to deprecate old message versions gracefully
Write the official documentation for the new features. Create separate guides for "Duplex Messaging & Pushes", "Streaming Responses", and "Message Fragmentation". Each guide must include runna...
Files:
docs/hardening-wireframe-a-guide-to-production-resilience.md
docs/**/*.{md,rs}
📄 CodeRabbit Inference Engine (docs/multi-packet-and-streaming-responses-design.md)
docs/**/*.{md,rs}: The official documentation and examples must exclusively use the declarativeResponsemodel for handler responses.
The async-stream pattern must be documented as the canonical approach for dynamic stream generation.
Files:
docs/hardening-wireframe-a-guide-to-production-resilience.md
**/*.md
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.md: Documentation must use en-GB-oxendict spelling and grammar. (EXCEPTION: the naming of the LICENSE file, which is to be left unchanged for community consistency.)
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks in Markdown files must be wrapped at 120 columns.
Tables and headings in Markdown files must not be wrapped.
Use dashes (-) for list bullets in Markdown files.
Use GitHub-flavoured Markdown footnotes ([^1]) for references and footnotes.
Files:
docs/hardening-wireframe-a-guide-to-production-resilience.md
⚙️ CodeRabbit Configuration File
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-GB-oxendict (-ize / -our) 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.
- Documents must start with a level 1 heading
- Headings must correctly increase or decrease by no more than one level at a time
- Use GitHub-flavoured Markdown style for footnotes and endnotes.
- Numbered footnotes must be numbered by order of appearance in the document.
Files:
docs/hardening-wireframe-a-guide-to-production-resilience.md
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: Function documentation must include clear examples demonstrating the usage and outcome of the function. Test documentation should omit examples where the example serves only to reiterate the test logic.
No single code file may be longer than 400 lines. Long switch statements or dispatch tables should be broken up by feature and constituents colocated with targets. Large blocks of test data should be moved to external data files.
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 using Arc to reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
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.
Prefer immutable data and avoid unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not use return in 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.
Prefer expect over allow.
Prefer .expect() over .unwrap().
Use concat!() to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums. Derive std::error::Error (via the thiserror crate) for any condition the caller might inspect, retry, or map to an HTTP status....
Files:
src/session.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 / -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.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.
Files:
src/session.rs
🧬 Code Graph Analysis (1)
src/session.rs (1)
src/push.rs (1)
from_arc(100-100)
🪛 GitHub Check: build-test
src/session.rs
[warning] 32-32:
Diff in /home/runner/work/wireframe/wireframe/src/session.rs
[warning] 24-24:
Diff in /home/runner/work/wireframe/wireframe/src/session.rs
[warning] 104-104:
Diff in /home/runner/work/wireframe/wireframe/src/session.rs
[warning] 87-87:
Diff in /home/runner/work/wireframe/wireframe/src/session.rs
🪛 GitHub Actions: CI
src/session.rs
[warning] 15-15: Prettier formatting check failed. Code style differences detected in function formatting; consider running 'cargo fmt --all' to fix.
[warning] 24-24: Prettier formatting check failed. Code style differences detected in function formatting; consider running 'cargo fmt --all' to fix.
[warning] 32-32: Prettier formatting check failed. Code style differences detected in function formatting; consider running 'cargo fmt --all' to fix.
[warning] 78-78: Prettier formatting check failed. Code style differences detected in function formatting; consider running 'cargo fmt --all' to fix.
[warning] 87-87: Prettier formatting check failed. Code style differences detected in function formatting; consider running 'cargo fmt --all' to fix.
[warning] 104-104: Prettier formatting check failed. Code style differences detected in function formatting; consider running 'cargo fmt --all' to fix.
🔇 Additional comments (5)
docs/hardening-wireframe-a-guide-to-production-resilience.md (1)
215-217: Documentation correctly reflects the new constructor pattern.The update from direct
PushHandle(...)construction toPushHandle::from_arcaligns with the refactored implementation and demonstrates the proper usage pattern for wrapping upgraded weak references.src/session.rs (4)
7-7: Import addition aligns with new functionality.Adding
Arcto the imports supports theretain_and_collecthelper method that works with upgradedArc<PushHandleInner<F>>references.
48-62: Excellent refactoring to eliminate code duplication.The
retain_and_collecthelper method consolidates the common pattern of pruning stale weak references whilst collecting data from live handles. The pre-allocated capacity and closure-based approach provide both efficiency and flexibility.
85-91: Well-documented concurrency behaviour.The enhanced documentation clearly explains that
pruneremoves stale references without returning handles and notes the locking implications ofDashMap::retain. This addresses previous concerns about concurrency semantics.
93-100: Successful refactoring with improved clarity.The method now leverages the
retain_and_collecthelper, eliminating code duplication whilst maintaining identical functionality. The updated documentation about per-bucket write locks helps users understand the performance characteristics.
There was a problem hiding this comment.
Actionable comments posted: 3
🔭 Outside diff range comments (1)
docs/asynchronous-outbound-messaging-design.md (1)
415-456: Code example accurately reflects implementation changes.The updated SessionRegistry example correctly shows the refactored implementation using
retain_and_collectpattern andPushHandle::from_arc. The documentation about locking behaviour provides valuable performance guidance.However, fix the hyphenation in the documentation:
-When a side-effect free snapshot is needed, `prune()` can be called +When a side effect free snapshot is needed, `prune()` can be called
♻️ Duplicate comments (1)
src/session.rs (1)
18-34: Fix formatting inconsistencies.Pipeline indicates these method definitions should use single-line format. Run
cargo fmt --allto ensure consistent code style.Expected format:
- fn from(value: u64) -> Self { - Self(value) - } + fn from(value: u64) -> Self { Self(value) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
README.md(2 hunks)docs/asynchronous-outbound-messaging-design.md(7 hunks)src/session.rs(4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: Function documentation must include clear examples demonstrating the usage and outcome of the function. Test documentation should omit examples where the example serves only to reiterate the test logic.
No single code file may be longer than 400 lines. Long switch statements or dispatch tables should be broken up by feature and constituents colocated with targets. Large blocks of test data should be moved to external data files.
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 using Arc to reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
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.
Prefer immutable data and avoid unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not use return in 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.
Prefer expect over allow.
Prefer .expect() over .unwrap().
Use concat!() to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums. Derive std::error::Error (via the thiserror crate) for any condition the caller might inspect, retry, or map to an HTTP status....
Files:
src/session.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 / -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.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.
Files:
src/session.rs
**/*.md
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.md: Documentation must use en-GB-oxendict spelling and grammar. (EXCEPTION: the naming of the LICENSE file, which is to be left unchanged for community consistency.)
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks in Markdown files must be wrapped at 120 columns.
Tables and headings in Markdown files must not be wrapped.
Use dashes (-) for list bullets in Markdown files.
Use GitHub-flavoured Markdown footnotes ([^1]) for references and footnotes.
Files:
README.mddocs/asynchronous-outbound-messaging-design.md
⚙️ CodeRabbit Configuration File
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-GB-oxendict (-ize / -our) 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.
- Documents must start with a level 1 heading
- Headings must correctly increase or decrease by no more than one level at a time
- Use GitHub-flavoured Markdown style for footnotes and endnotes.
- Numbered footnotes must be numbered by order of appearance in the document.
Files:
README.mddocs/asynchronous-outbound-messaging-design.md
docs/**/*.md
📄 CodeRabbit Inference Engine (docs/contents.md)
Conventions for writing project documentation as described in the documentation style guide
docs/**/*.md: Use British English based on the Oxford English Dictionary (en-oxendict) for documentation text.
The word "outwith" is acceptable in documentation.
Keep US spelling when used in an API, for examplecolor.
Use the Oxford comma in documentation text.
Treat company names as collective nouns in documentation (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 provide a language identifier for fenced code blocks; 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; avoid reference-style links like[foo][bar].
Ensure blank lines before and after bulleted lists and fenced blocks in Markdown.
Ensure tables have a delimiter line below the header row 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 sequentially numbered footnotes referenced with[^1]and place definitions at the end of the file.
Where it adds clarity, include Mermaid diagrams in documentation.
When embedding figures, useand provide concise alt text describing the content.
Add a brief description before each Mermaid diagram in documentation for screen readers.Document examples showing how to deprecate old message versions gracefully
Write the official documentation for the new features. Create separate guides for "Duplex Messaging & Pushes", "Streaming Responses", and "Message Fragmentation". Each guide must include runna...
Files:
docs/asynchronous-outbound-messaging-design.md
docs/**/*.{md,rs}
📄 CodeRabbit Inference Engine (docs/multi-packet-and-streaming-responses-design.md)
docs/**/*.{md,rs}: The official documentation and examples must exclusively use the declarativeResponsemodel for handler responses.
The async-stream pattern must be documented as the canonical approach for dynamic stream generation.
Files:
docs/asynchronous-outbound-messaging-design.md
🧠 Learnings (1)
📚 Learning: applies to docs/src/push.rs : sessionregistry must store weak references to pushhandleinner to avoid...
Learnt from: CR
PR: leynos/wireframe#0
File: docs/asynchronous-outbound-messaging-design.md:0-0
Timestamp: 2025-07-27T13:30:30.121Z
Learning: Applies to docs/src/push.rs : SessionRegistry must store Weak references to PushHandleInner to avoid memory leaks and provide methods to get, insert, remove, and enumerate active handles.
Applied to files:
README.md
🧬 Code Graph Analysis (1)
src/session.rs (1)
src/push.rs (1)
from_arc(100-100)
🪛 GitHub Check: build-test
src/session.rs
[warning] 32-32:
Diff in /home/runner/work/wireframe/wireframe/src/session.rs
[warning] 24-24:
Diff in /home/runner/work/wireframe/wireframe/src/session.rs
[warning] 106-106:
Diff in /home/runner/work/wireframe/wireframe/src/session.rs
[warning] 87-87:
Diff in /home/runner/work/wireframe/wireframe/src/session.rs
🪛 GitHub Actions: CI
src/session.rs
[warning] 15-15: Prettier formatting check failed. Function bodies should be in single-line format.
[warning] 24-24: Prettier formatting check failed. Function bodies should be in single-line format.
[warning] 32-32: Prettier formatting check failed. Function bodies should be in single-line format.
[warning] 78-78: Prettier formatting check failed. Function bodies should be in single-line format.
[warning] 87-87: Prettier formatting check failed. Function bodies should be in single-line format.
[warning] 106-106: Prettier formatting check failed. Function bodies should be in single-line format.
🪛 LanguageTool
README.md
[grammar] ~87-~87: Please add a punctuation mark at the end of paragraph.
Context: ...a binary protocol server. See the [full example](docs/rust-binary-router-library-design...
(PUNCTUATION_PARAGRAPH_END)
docs/asynchronous-outbound-messaging-design.md
[uncategorized] ~73-~73: Loose punctuation mark.
Context: ...low_priority_push_rx: mpsc::Receiver`: For standard, non-urgent background ...
(UNLIKELY_OPENING_PUNCTUATION)
[misspelling] ~452-~452: Did you mean “side effect” (=adverse effect, unintended consequence)? Open compounds are not hyphenated.
Context: ...ects the remaining live handles. When a side-effect free snapshot is needed, prune() can ...
(AFFECT_EFFECT)
🔇 Additional comments (7)
README.md (1)
195-199: LGTM!The documentation accurately reflects the SessionRegistry implementation changes, clearly explaining the pruning behaviour and introducing the explicit
prune()method. The note about locking contention provides valuable performance guidance.docs/asynchronous-outbound-messaging-design.md (3)
42-48: LGTM!Table formatting has been improved for better readability whilst preserving all content.
73-100: LGTM!Numbering sequence has been corrected for proper list formatting.
165-165: LGTM!Blank line addition improves document formatting and follows Markdown best practices.
src/session.rs (3)
7-7: LGTM!Arc import addition is necessary for the new
retain_and_collecthelper method.
48-62: Excellent refactoring eliminates code duplication.The
retain_and_collecthelper method consolidates the common pruning pattern used by bothactive_handlesandactive_ids. The implementation correctly handles weak reference upgrades, pre-allocates capacity for efficiency, and uses a closure parameter for flexible data collection.
93-101: LGTM!The refactored implementation using
retain_and_collectis more efficient and eliminates potential race conditions. The atomic pruning and collection in a single pass is a significant improvement over the previous two-step approach.
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 (1)
README.md(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.md
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.md: Documentation must use en-GB-oxendict spelling and grammar. (EXCEPTION: the naming of the LICENSE file, which is to be left unchanged for community consistency.)
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks in Markdown files must be wrapped at 120 columns.
Tables and headings in Markdown files must not be wrapped.
Use dashes (-) for list bullets in Markdown files.
Use GitHub-flavoured Markdown footnotes ([^1]) for references and footnotes.
Files:
README.md
⚙️ CodeRabbit Configuration File
**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")
- Use en-GB-oxendict (-ize / -our) 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.
- Documents must start with a level 1 heading
- Headings must correctly increase or decrease by no more than one level at a time
- Use GitHub-flavoured Markdown style for footnotes and endnotes.
- Numbered footnotes must be numbered by order of appearance in the document.
Files:
README.md
🧠 Learnings (2)
📚 Learning: applies to docs/src/push.rs : sessionregistry must store weak references to pushhandleinner to avoid...
Learnt from: CR
PR: leynos/wireframe#0
File: docs/asynchronous-outbound-messaging-design.md:0-0
Timestamp: 2025-07-27T13:30:30.121Z
Learning: Applies to docs/src/push.rs : SessionRegistry must store Weak references to PushHandleInner to avoid memory leaks and provide methods to get, insert, remove, and enumerate active handles.
Applied to files:
README.md
📚 Learning: applies to docs/src/push.rs : sessionregistry must not leak memory when connections are terminated; ...
Learnt from: CR
PR: leynos/wireframe#0
File: docs/asynchronous-outbound-messaging-design.md:0-0
Timestamp: 2025-07-27T13:30:30.121Z
Learning: Applies to docs/src/push.rs : SessionRegistry must not leak memory when connections are terminated; entries whose handles have been dropped should be removed lazily.
Applied to files:
README.md
🔇 Additional comments (1)
README.md (1)
194-198: Session-registry wording update reads clearly and follows style guide.The revised paragraph removes second-person pronouns, adds the required note about
retainlock contention, and keeps line lengths within the documented limits. No further changes needed.
df28eac to
1380c16
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
active_handlesto prune and collect in a singleretainpassTesting
make lintmake testmake markdownlinthttps://chatgpt.com/codex/tasks/task_e_688bf5ee5c1883229baf94a4eec8b09d
Summary by Sourcery
Streamline SessionRegistry.active_handles by consolidating pruning and handle collection into a single retain operation and align documentation with the new approach.
Enhancements:
Documentation: