Skip to content

Add fairness counter for low-priority queue#145

Merged
leynos merged 5 commits intomainfrom
codex/implement-fairness-counter-for-queue-management
Jun 28, 2025
Merged

Add fairness counter for low-priority queue#145
leynos merged 5 commits intomainfrom
codex/implement-fairness-counter-for-queue-management

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jun 28, 2025

Summary

  • implement fairness counter to yield to low-priority queue
  • allow configuring fairness behaviour
  • test fairness counter
  • mark roadmap item complete

Testing

  • make lint
  • make test

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

Summary by Sourcery

Introduce a configurable fairness counter in ConnectionActor to balance processing between high- and low-priority queues, add corresponding tests, and update documentation.

New Features:

  • Introduce FairnessConfig to parameterize low-priority queue yielding behavior
  • Integrate fairness logic into ConnectionActor to pause high-priority bursts and serve low-priority frames
  • Expose set_fairness method on ConnectionActor to customize fairness settings

Documentation:

  • Mark the fairness counter item as complete in the asynchronous outbound messaging roadmap

Tests:

  • Add a test verifying that low-priority frames are yielded to after a burst of high-priority frames

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 28, 2025

Reviewer's Guide

Adds a configurable fairness counter to ConnectionActor so that after a burst of high-priority frames or an optional time slice, a low-priority frame is yielded; includes configuration struct, state tracking, integration in the select loop, helper methods, a dedicated test, and docs update.

Sequence diagram for fairness counter yielding to low-priority queue

sequenceDiagram
    participant ConnectionActor
    participant HighPriorityQueue
    participant LowPriorityQueue
    participant Outbound

    loop Process high-priority frames
        ConnectionActor->>HighPriorityQueue: recv_push()
        alt Frame received
            ConnectionActor->>Outbound: handle_push()
            ConnectionActor->>ConnectionActor: after_high()
            alt Fairness threshold or time slice hit
                ConnectionActor->>LowPriorityQueue: try_recv()
                alt Frame available
                    ConnectionActor->>Outbound: before_send()
                    ConnectionActor->>Outbound: push(frame)
                    ConnectionActor->>ConnectionActor: after_low()
                else Queue empty or disconnected
                end
            else Continue high-priority
            end
        else No frame
            ConnectionActor->>ConnectionActor: reset_high_counter()
        end
    end
Loading

Class diagram for FairnessConfig and ConnectionActor changes

classDiagram
    class FairnessConfig {
        +usize max_high_before_low
        +Option<Duration> time_slice
        +default()
    }
    class ConnectionActor {
        -PushQueues<F> queues
        -Option<FrameStream<F, E>> response
        -CancellationToken shutdown
        -ProtocolHooks<F> hooks
        -FairnessConfig fairness
        -usize high_counter
        -Option<Instant> high_start
        +set_fairness(fairness: FairnessConfig)
        +after_high(out: &mut Vec<F>, low_closed: &mut bool)
        +after_low()
        +reset_high_counter()
    }
    ConnectionActor --> FairnessConfig : uses
Loading

File-Level Changes

Change Details Files
Introduce fairness configuration and state tracking
  • Added FairnessConfig struct with max_high_before_low and time_slice fields
  • Derived Default impl for FairnessConfig
  • Added fairness, high_counter, and high_start fields to ConnectionActor
  • Initialized new fields in the constructor
src/connection.rs
Expose a setter for custom fairness configuration
  • Added set_fairness method to ConnectionActor to replace the fairness config
src/connection.rs
Integrate fairness logic into the select loop
  • Tracked a processed flag in high, low, and response branches
  • Called after_high when a high-priority frame is processed
  • Called after_low for low-priority and response frames
  • Reset high counter when no frame was processed
src/connection.rs
Implement helper methods for fairness enforcement
  • Added after_high to check burst and time thresholds and try one low-priority frame
  • Added after_low and reset_high_counter to clear counters
src/connection.rs
Add unit test for fairness behavior
  • Created fairness_yields_low_after_burst test using max_high_before_low = 2
  • Verified low-priority frame is injected after the configured high-priority burst
tests/connection_actor.rs
Update roadmap documentation
  • Marked the fairness counter roadmap item as complete
docs/asynchronous-outbound-messaging-roadmap.md

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 Jun 28, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a fairness mechanism to balance processing between high-priority and low-priority message queues, preventing low-priority tasks from being starved during heavy high-priority traffic.
  • Documentation

    • Updated roadmap to mark the fairness counter feature as complete.
    • Revised design documentation to clarify fairness configuration defaults and behaviour, and added a new sequence diagram illustrating the fairness mechanism.
    • Reformatted contents and introductory text for improved clarity and consistency.
  • Tests

    • Added a test to verify that the fairness mechanism correctly yields to low-priority items after a set number of high-priority items.

Summary by CodeRabbit

  • New Features

    • Introduced a fairness mechanism to balance processing between high-priority and low-priority queues, preventing starvation of low-priority tasks.
    • Added configuration options for fairness, including thresholds based on count and time.
  • Documentation

    • Updated roadmap to mark the "Fairness counter" feature as complete.
    • Clarified fairness configuration behaviour and added a sequence diagram illustrating the fairness mechanism.
    • Reformatted documentation contents for consistency and improved readability.
  • Tests

    • Added a test to verify that the fairness mechanism correctly yields to low-priority tasks after a burst of high-priority items.

Walkthrough

A fairness mechanism was added to the ConnectionActor to balance processing between high- and low-priority push queues, using a configurable counter and optional time slice. Documentation was updated to mark the "Fairness counter" feature as complete, and a new test verifies the fairness logic.

Changes

File(s) Change Summary
docs/asynchronous-outbound-messaging-roadmap.md Marked the "Fairness counter" feature as complete in the roadmap checklist.
docs/asynchronous-outbound-messaging-design.md Clarified fairness configuration behaviour and added a Mermaid sequence diagram illustrating the fairness mechanism.
docs/contents.md Reformatted introductory text and markdown list items for formatting consistency.
src/connection.rs Added FairnessConfig struct, fairness logic, related fields and methods to ConnectionActor, refactored polling loop.
tests/connection_actor.rs Added asynchronous test verifying fairness yields low-priority frames after bursts of high-priority frames.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ConnectionActor
    participant HighQueue
    participant LowQueue

    loop While processing frames
        ConnectionActor->>HighQueue: Poll high-priority frame
        alt High-priority frame received
            ConnectionActor->>ConnectionActor: after_high()
            alt Max high before low or time slice reached
                ConnectionActor->>LowQueue: Try receive low-priority frame
                alt Low-priority frame available
                    ConnectionActor->>ConnectionActor: after_low()
                end
            end
        else No high-priority frame
            ConnectionActor->>ConnectionActor: reset_high_counter()
        end
    end
Loading

Possibly related issues

Possibly related PRs

Poem

In queues where priorities vie for the lead,
The fairness counter balances each need.
Highs and lows now take their turn,
No more will the lowly yearn.
With code and care, the test agrees—
Fairness flows with gentle ease!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 168c305 and 4000d61.

📒 Files selected for processing (3)
  • docs/asynchronous-outbound-messaging-design.md (2 hunks)
  • docs/contents.md (1 hunks)
  • src/connection.rs (6 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
`docs/**/*.md`: Use the markdown files within the `docs/` directory as a knowled...

docs/**/*.md: Use the markdown files within the docs/ directory as a knowledge base and source of truth for project requirements, dependency choices, and architectural decisions.
Proactively update the relevant file(s) in the docs/ directory to reflect the latest state when new decisions are made, requirements change, libraries are added/removed, or architectural patterns evolve.
Documentation in the docs/ directory must use en-GB-oxendict spelling and grammar, except for the word 'license'.

📄 Source: CodeRabbit Inference Engine (AGENTS.md)

List of files the instruction was applied to:

  • docs/contents.md
  • docs/asynchronous-outbound-messaging-design.md
`**/*.md`: Validate Markdown files using `markdownlint *.md **/*.md`. Run `mdfor...

**/*.md: Validate Markdown files using markdownlint *.md **/*.md.
Run mdformat-all after any documentation changes to format all Markdown files and fix table markup.
Validate Markdown Mermaid diagrams using the nixie CLI by running nixie *.md **/*.md.
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.

📄 Source: CodeRabbit Inference Engine (AGENTS.md)

List of files the instruction was applied to:

  • docs/contents.md
  • docs/asynchronous-outbound-messaging-design.md
`docs/*.md`: Each file in the docs/ directory is a documentation markdown file s...

docs/*.md: Each file in the docs/ directory is a documentation markdown file summarizing a specific aspect of the project's design, architecture, testing, operations, or reference material.

📄 Source: CodeRabbit Inference Engine (docs/contents.md)

List of files the instruction was applied to:

  • docs/contents.md
  • docs/asynchronous-outbound-messaging-design.md
`docs/**/*.md`: Use British English spelling based on the Oxford English Diction...

docs/**/*.md: Use British English spelling based on the Oxford English Dictionary, except retain US spelling in API names (e.g., 'color').
Use the Oxford comma in lists.
Write headings in sentence case and use Markdown heading levels in order without skipping.
Follow markdownlint recommendations for Markdown formatting.
Always use fenced code blocks with a language identifier; use 'plaintext' for non-code text.
Use '-' as the first level bullet and renumber lists when items change.
Prefer inline links using 'text' or angle brackets around the URL.
Expand any uncommon acronym on first use, e.g., Continuous Integration (CI).
Wrap paragraphs at 80 columns, code at 120 columns, and do not wrap tables.
Use footnotes referenced with '[^label]'.
When embedding figures, use 'alt text' and provide concise alt text describing the content.
Add a short description before each Mermaid diagram for screen readers.

📄 Source: CodeRabbit Inference Engine (docs/documentation-style-guide.md)

List of files the instruction was applied to:

  • docs/contents.md
  • docs/asynchronous-outbound-messaging-design.md
`docs/**/asynchronous-outbound-messaging-design.md`: Document and reference desi...

docs/**/asynchronous-outbound-messaging-design.md: Document and reference design details for features such as actor state management, optional dead letter queue, error handling and resilience, fairness for low-priority frames, configuration via the WireframeProtocol trait, the PushHandle, prioritised message queues, the SessionRegistry, and use cases.

📄 Source: CodeRabbit Inference Engine (docs/asynchronous-outbound-messaging-roadmap.md)

List of files the instruction was applied to:

  • docs/asynchronous-outbound-messaging-design.md
`**/*.rs`: Every Rust module must begin with a module level (`//!`) comment expl...

**/*.rs: Every Rust module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public Rust APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.

📄 Source: CodeRabbit Inference Engine (AGENTS.md)

List of files the instruction was applied to:

  • src/connection.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-test
🔇 Additional comments (10)
docs/contents.md (2)

3-4: Approve the consolidated introduction.

The consolidation of the introductory text into a concise, single-paragraph format improves readability whilst maintaining all the essential information.


8-45: Approve the streamlined formatting.

Moving the descriptive text to the same lines as the markdown links creates a cleaner, more compact layout that's easier to scan. This addresses the previous concern about unnecessary trailing backslashes.

src/connection.rs (6)

21-32: Approve the well-documented FairnessConfig.

The configuration struct is properly documented with clear explanations of both the counter threshold and time slice mechanisms. The documentation correctly explains that setting the counter to zero disables threshold logic whilst relying solely on the time slice.


34-41: Approve the improved default configuration.

The default value of 8 for max_high_before_low provides better balance than the previous value of 16, addressing the earlier concern about fairness for low-priority messages.


156-194: Approve the refactored processing methods.

The separation of polling logic into dedicated methods (process_shutdown, process_high, process_low, process_response) significantly improves code organisation and readability whilst making the fairness logic more manageable.


215-233: Approve the fairness yielding logic.

The after_high method correctly implements the fairness mechanism by tracking consecutive high-priority frames and yielding to low-priority frames when thresholds are met. The non-blocking try_recv ensures the actor doesn't stall when the low-priority queue is empty.


235-244: Approve the efficient threshold checking.

The should_yield_to_low_priority method elegantly combines both threshold conditions using modern Rust idioms. The use of is_some_and provides clean, readable logic for the time slice check.


246-251: Approve the DRY principle implementation.

The refactoring eliminates code duplication by having after_low call reset_high_counter, properly following the DRY principle as suggested in previous reviews.

docs/asynchronous-outbound-messaging-design.md (2)

149-152: Approve the accurate configuration documentation.

The updated documentation correctly reflects the implementation changes, including the default value of 8 and the behaviour when the counter is set to zero. This maintains consistency between code and documentation.


185-208: Approve the informative sequence diagram.

The new Mermaid sequence diagram effectively illustrates the runtime behaviour of the fairness mechanism, showing the interaction between high-priority processing, threshold checking, and low-priority yielding. This visual aid complements the existing flowchart and enhances understanding of the dynamic behaviour.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch codex/implement-fairness-counter-for-queue-management

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Choose a reason for hiding this comment

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

Gates Failed
Enforce critical code health rules (1 file with Bumpy Road Ahead)
Enforce advisory code health rules (1 file with Complex Method)

Gates Passed
4 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
Enforce critical code health rules Violations Code Health Impact
connection.rs 1 critical rule 10.00 → 9.54 Suppress
Enforce advisory code health rules Violations Code Health Impact
connection.rs 1 advisory rule 10.00 → 9.54 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.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

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:197` </location>
<code_context>
+            self.high_start = Some(Instant::now());
+        }
+
+        let threshold_hit = self.fairness.max_high_before_low > 0
+            && self.high_counter >= self.fairness.max_high_before_low;
+        let time_hit =
</code_context>

<issue_to_address>
Zero value for max_high_before_low disables threshold logic.

If this is intended, please document that setting max_high_before_low to zero disables the threshold logic and relies solely on the time slice for fairness.
</issue_to_address>

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

Comment thread src/connection.rs Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ba0b89 and 2839caf.

📒 Files selected for processing (3)
  • docs/asynchronous-outbound-messaging-roadmap.md (1 hunks)
  • src/connection.rs (6 hunks)
  • tests/connection_actor.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
`docs/**/*.md`: Use the markdown files within the `docs/` directory as a knowled...

docs/**/*.md: Use the markdown files within the docs/ directory as a knowledge base and source of truth for project requirements, dependency choices, and architectural decisions.
Proactively update the relevant file(s) in the docs/ directory to reflect the latest state when new decisions are made, requirements change, libraries are added/removed, or architectural patterns evolve.
Documentation in the docs/ directory must use en-GB-oxendict spelling and grammar, except for the word 'license'.

📄 Source: CodeRabbit Inference Engine (AGENTS.md)

List of files the instruction was applied to:

  • docs/asynchronous-outbound-messaging-roadmap.md
`**/*.md`: Validate Markdown files using `markdownlint *.md **/*.md`. Run `mdfor...

**/*.md: Validate Markdown files using markdownlint *.md **/*.md.
Run mdformat-all after any documentation changes to format all Markdown files and fix table markup.
Validate Markdown Mermaid diagrams using the nixie CLI by running nixie *.md **/*.md.
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.

📄 Source: CodeRabbit Inference Engine (AGENTS.md)

List of files the instruction was applied to:

  • docs/asynchronous-outbound-messaging-roadmap.md
`docs/*.md`: Each file in the docs/ directory is a documentation markdown file s...

docs/*.md: Each file in the docs/ directory is a documentation markdown file summarizing a specific aspect of the project's design, architecture, testing, operations, or reference material.

📄 Source: CodeRabbit Inference Engine (docs/contents.md)

List of files the instruction was applied to:

  • docs/asynchronous-outbound-messaging-roadmap.md
`docs/**/*.md`: Use British English spelling based on the Oxford English Diction...

docs/**/*.md: Use British English spelling based on the Oxford English Dictionary, except retain US spelling in API names (e.g., 'color').
Use the Oxford comma in lists.
Write headings in sentence case and use Markdown heading levels in order without skipping.
Follow markdownlint recommendations for Markdown formatting.
Always use fenced code blocks with a language identifier; use 'plaintext' for non-code text.
Use '-' as the first level bullet and renumber lists when items change.
Prefer inline links using 'text' or angle brackets around the URL.
Expand any uncommon acronym on first use, e.g., Continuous Integration (CI).
Wrap paragraphs at 80 columns, code at 120 columns, and do not wrap tables.
Use footnotes referenced with '[^label]'.
When embedding figures, use 'alt text' and provide concise alt text describing the content.
Add a short description before each Mermaid diagram for screen readers.

📄 Source: CodeRabbit Inference Engine (docs/documentation-style-guide.md)

List of files the instruction was applied to:

  • docs/asynchronous-outbound-messaging-roadmap.md
`**/*.rs`: Every Rust module must begin with a module level (`//!`) comment expl...

**/*.rs: Every Rust module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public Rust APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.

📄 Source: CodeRabbit Inference Engine (AGENTS.md)

List of files the instruction was applied to:

  • tests/connection_actor.rs
  • src/connection.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-test
🔇 Additional comments (5)
src/connection.rs (3)

47-82: Well-structured fairness tracking implementation.

The addition of fairness tracking fields and their proper initialisation in both constructors is clean and follows the existing patterns in the codebase.


140-163: Correct integration of fairness logic into the polling loop.

The fairness mechanism is properly integrated, with high-priority frames incrementing the counter and both low-priority and response frames resetting it. This ensures the fairness counter accurately tracks consecutive high-priority frame processing.


191-218: Robust fairness enforcement implementation.

The after_high method correctly implements both count-based and time-based fairness thresholds. The use of try_recv for non-blocking low-priority queue checking is appropriate, and all error cases are properly handled.

tests/connection_actor.rs (1)

47-71: Well-designed test for fairness mechanism.

The test correctly validates that the fairness counter yields to the low-priority queue after processing the configured number of high-priority frames. The expected output [1, 2, 99, 3, 4, 5] properly demonstrates the fairness behavior.

docs/asynchronous-outbound-messaging-roadmap.md (1)

16-17: Documentation correctly updated to reflect feature completion.

The fairness counter checkbox has been appropriately marked as complete, aligning with the implementation delivered in this PR.

Comment thread src/connection.rs
Comment thread src/connection.rs Outdated
Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Choose a reason for hiding this comment

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

Gates Failed
Enforce critical code health rules (1 file with Bumpy Road Ahead)
Enforce advisory code health rules (1 file with Complex Method)

Gates Passed
4 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
Enforce critical code health rules Violations Code Health Impact
connection.rs 1 critical rule 10.00 → 9.54 Suppress
Enforce advisory code health rules Violations Code Health Impact
connection.rs 1 advisory rule 10.00 → 9.54 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (2)
src/connection.rs (2)

244-249: Address code duplication between after_low and reset_high_counter.

Both methods have identical implementations, violating the DRY principle.

 fn after_low(&mut self) {
-    self.high_counter = 0;
-    self.high_start = None;
+    self.reset_high_counter();
 }

 fn reset_high_counter(&mut self) {
     self.high_counter = 0;
     self.high_start = None;
 }

221-222: Document the zero value behaviour for max_high_before_low.

Setting max_high_before_low to zero disables the threshold logic and relies solely on time_slice for fairness. This should be clearly documented in the code.

 let threshold_hit = self.fairness.max_high_before_low > 0
     && self.high_counter >= self.fairness.max_high_before_low;
+// Note: Setting max_high_before_low to zero disables threshold logic
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2839caf and 168c305.

📒 Files selected for processing (3)
  • docs/asynchronous-outbound-messaging-design.md (2 hunks)
  • docs/contents.md (1 hunks)
  • src/connection.rs (6 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
`docs/**/*.md`: Use the markdown files within the `docs/` directory as a knowled...

docs/**/*.md: Use the markdown files within the docs/ directory as a knowledge base and source of truth for project requirements, dependency choices, and architectural decisions.
Proactively update the relevant file(s) in the docs/ directory to reflect the latest state when new decisions are made, requirements change, libraries are added/removed, or architectural patterns evolve.
Documentation in the docs/ directory must use en-GB-oxendict spelling and grammar, except for the word 'license'.

📄 Source: CodeRabbit Inference Engine (AGENTS.md)

List of files the instruction was applied to:

  • docs/contents.md
  • docs/asynchronous-outbound-messaging-design.md
`**/*.md`: Validate Markdown files using `markdownlint *.md **/*.md`. Run `mdfor...

**/*.md: Validate Markdown files using markdownlint *.md **/*.md.
Run mdformat-all after any documentation changes to format all Markdown files and fix table markup.
Validate Markdown Mermaid diagrams using the nixie CLI by running nixie *.md **/*.md.
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.

📄 Source: CodeRabbit Inference Engine (AGENTS.md)

List of files the instruction was applied to:

  • docs/contents.md
  • docs/asynchronous-outbound-messaging-design.md
`docs/*.md`: Each file in the docs/ directory is a documentation markdown file s...

docs/*.md: Each file in the docs/ directory is a documentation markdown file summarizing a specific aspect of the project's design, architecture, testing, operations, or reference material.

📄 Source: CodeRabbit Inference Engine (docs/contents.md)

List of files the instruction was applied to:

  • docs/contents.md
  • docs/asynchronous-outbound-messaging-design.md
`docs/**/*.md`: Use British English spelling based on the Oxford English Diction...

docs/**/*.md: Use British English spelling based on the Oxford English Dictionary, except retain US spelling in API names (e.g., 'color').
Use the Oxford comma in lists.
Write headings in sentence case and use Markdown heading levels in order without skipping.
Follow markdownlint recommendations for Markdown formatting.
Always use fenced code blocks with a language identifier; use 'plaintext' for non-code text.
Use '-' as the first level bullet and renumber lists when items change.
Prefer inline links using 'text' or angle brackets around the URL.
Expand any uncommon acronym on first use, e.g., Continuous Integration (CI).
Wrap paragraphs at 80 columns, code at 120 columns, and do not wrap tables.
Use footnotes referenced with '[^label]'.
When embedding figures, use 'alt text' and provide concise alt text describing the content.
Add a short description before each Mermaid diagram for screen readers.

📄 Source: CodeRabbit Inference Engine (docs/documentation-style-guide.md)

List of files the instruction was applied to:

  • docs/contents.md
  • docs/asynchronous-outbound-messaging-design.md
`docs/**/asynchronous-outbound-messaging-design.md`: Document and reference desi...

docs/**/asynchronous-outbound-messaging-design.md: Document and reference design details for features such as actor state management, optional dead letter queue, error handling and resilience, fairness for low-priority frames, configuration via the WireframeProtocol trait, the PushHandle, prioritised message queues, the SessionRegistry, and use cases.

📄 Source: CodeRabbit Inference Engine (docs/asynchronous-outbound-messaging-roadmap.md)

List of files the instruction was applied to:

  • docs/asynchronous-outbound-messaging-design.md
`**/*.rs`: Every Rust module must begin with a module level (`//!`) comment expl...

**/*.rs: Every Rust module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public Rust APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Place function attributes after doc comments.

📄 Source: CodeRabbit Inference Engine (AGENTS.md)

List of files the instruction was applied to:

  • src/connection.rs
🪛 LanguageTool
docs/contents.md

[duplication] ~12-~12: Possible typo: you repeated a word.
Context: ...embling messages. - Streaming response design\ Design for handling multi-packet and streaming...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~33-~33: Possible typo: you repeated a word.
Context: ... High-level development roadmap. - 1.0 philosophy\ Philosophy and feature set for Wireframe 1.0. ## ...

(ENGLISH_WORD_REPEAT_RULE)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-test
🔇 Additional comments (6)
src/connection.rs (1)

21-32: Document the misplaced comment issue has been resolved.

The documentation placement issue from the previous review has been properly addressed. The FairnessConfig now has appropriate documentation describing its purpose and fields.

docs/asynchronous-outbound-messaging-design.md (3)

150-152: Excellent clarification of zero value behaviour.

The updated documentation clearly explains that setting the counter to zero disables threshold logic and relies solely on time_slice for fairness. This addresses the previous concerns about documenting this behaviour.


185-208: Well-structured sequence diagram enhances understanding.

The new Mermaid sequence diagram effectively illustrates the runtime behaviour of the fairness mechanism, showing the interaction between the ConnectionActor and the queues. The diagram complements the existing flowchart nicely.


185-185: Minor grammar improvement needed.

The text should use "behaviour" (British English) consistently.

-The following sequence diagram illustrates the runtime behaviour:
+The following sequence diagram illustrates the runtime behaviour:

Wait, this is already correct. The documentation is properly using British English spelling.

docs/contents.md (2)

3-4: Approve text consolidation for better readability.

The consolidation of the introductory text into a single line improves readability without changing the meaning.


12-12: False positive from static analysis tool.

The LanguageTool warning about "word repetition" appears to be incorrectly flagging the filename multi-packet-and-streaming-responses-design.md. This is a false positive as the repetition is in a legitimate filename, not duplicated words in prose.

Comment thread src/connection.rs
Comment thread src/connection.rs
Comment thread docs/contents.md Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant