Skip to content

fix(ingress): stabilize non-finite limiter key and count once - #73

Merged
rmems merged 2 commits into
mainfrom
cursor/ingress-p2-limiter-count-3f17
Sep 30, 2026
Merged

rmems merged 2 commits into
mainfrom
cursor/ingress-p2-limiter-count-3f17

Conversation

@rmems

@rmems rmems commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

User description

Follow-up to #72 (merged while this review-fix was in flight) for the two actionable Codex P2 comments on issue #66.

Changes

  1. Stable limiter key (discussion): record_non_finite_rejection keys diagnostics.non_finite on the fixed category rejected non-finite ingress instead of hashing the formatted warning. The warning text still includes the offending index; an alternating-index NaN source can no longer reset OccurrenceLimiter.

  2. Count already-rejected non-finite packets once (discussion): after the existing rejected_batches increment, an already-rejected packet that also carries a non-finite payload is dropped (not admitted) so the drained-packet gate cannot increment the counter again. Finite rejected packets still admit and tick.

Intentional #72 design is unchanged: drained-gate early return (TickSucceeded + no network.step) for direct BoundedIngress enqueue of non-finite packets.

Tests

  • non_finite_limiter_is_stable_across_alternating_indices
  • already_rejected_non_finite_packet_is_counted_once
  • already_rejected_finite_packet_is_counted_once_and_still_ticks

Local gate: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo test --locked (146 passed / 1 ignored). --all-features clippy + test with CC=gcc CXX=g++ (161 unit + 9 integration passed / 1 ignored).

Replies posted as Fixed on both Codex threads on #72. Do not merge this until CI is green.

Open in Web Open in Cursor 

Devin Review

Summary by cubic

Stabilizes non-finite ingress rejection accounting so an alternating-index NaN source can no longer bypass the diagnostic limiter, and already-rejected packets are no longer double-counted.

  • Keys the non-finite diagnostic limiter on a fixed category instead of the hashed warning text, which included the offending index and reset OccurrenceLimiter on every index change.
  • Drops already-rejected packets that also carry a non-finite payload after the initial rejected_batches increment so the drained-packet gate cannot count them again; these packets also no longer refresh input_freshness. Finite rejected packets still admit and tick unchanged.
  • Adds tests covering stable limiter behavior across alternating indices, single-counting of rejected non-finite and finite packets, tick continuity, and freshness handling.

Written for commit 3c0e7af. Summary will update on new commits.

Review in cubic

Release qualification tracking — 2026-09-30

This existing follow-up is part of 02 — v0.3.0 release qualification. Authoritative acceptance and release dependency: LIM-1322; delivered core implementation remains #66 / PR #72. No duplicate implementation assignment is needed.

PR #73 remains open at d941383504dbe39e7c109e6391dcefd76a5afca1. Its functional CI passes. CodeScene fails its run_tick complexity gate; DeepSource is skipped for quota, and cubic is neutral for its review limit. No claim that every check passed or every review is resolved.

The freshness review and CodeScene review are unresolved. Record fixes or explicit dispositions and final regression/CI evidence before closing the canonical qualification issue. This tracking update does not resolve reviews, merge this PR or authorize publication.


CodeAnt-AI Description

Prevent duplicate handling of rejected non-finite ingress and stabilize warnings

What Changed

  • Rejected packets containing NaN or infinity are dropped without being admitted or counted twice.
  • Rejected non-finite packets no longer refresh input freshness, while finite rejected packets continue normal tick processing and freshness updates.
  • Non-finite warnings now share one stable category, so changing the offending input position cannot bypass warning rate limits.

Impact

✅ Accurate rejected-packet counts
✅ No stale non-finite input marked as fresh
✅ Controlled non-finite warning volume

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Key the non-finite diagnostic limiter by a fixed error category so an
alternating-index NaN source cannot reset OccurrenceLimiter. Drop
already-rejected packets that also carry a non-finite payload so the
drained-packet gate cannot increment rejected_batches twice.

Co-authored-by: Raul Cardenas Montoya <montoyaraul34@gmail.com>
@codeant-ai

codeant-ai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Incremental review completed 3c0e7af Sep 30, 2026 · 21:28 21:29
✅ Reviewed your PR d941383 Sep 30, 2026 · 04:05 04:08

@codeant-ai

codeant-ai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T04:07:33.419930Z d941383 PR opened
🔒 Security Review ✅ Completed 2026-09-30T04:08:43.462186Z d941383 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Essentials

Run ID: 5d97753b-58e4-4e5c-b741-07c3caaae0e5

📥 Commits

Reviewing files that changed from the base of the PR and between d941383 and 3c0e7af.

📒 Files selected for processing (1)
  • src/daemon.rs
 ______________________________
< AI vs. bugs. Round 1. Fight! >
 ------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Non-finite packet warnings are now rate-limited consistently, even when the offending data changes position, reducing repeated diagnostic noise.
    • Rejected non-finite packets no longer trigger additional ingress processing. Rejected finite packets continue to follow the existing ingress admission behavior.

Walkthrough

The daemon now uses a stable rate-limiter key for non-finite ingress warnings. It also admits already-rejected packets only when their payload is finite, with tests covering rejection counts and continued tick processing.

Changes

Ingress rejection handling

Layer / File(s) Summary
Stable non-finite warning limiting
src/daemon.rs
Non-finite warning limits use a stable category instead of the formatted message. A test alternates the NaN index and checks the resulting diagnostics and suppressions.
Admission of already-rejected packets
src/daemon.rs
Already-rejected packets are admitted only when their payload is finite. Tests check that non-finite packets are counted once and dropped, while finite rejected packets remain rejected and ticks continue.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: 🔵 Low · up to d9413

Discarded non-finite input can incorrectly appear fresh in health reporting. The change is otherwise mergeable with awareness of this bounded issue; exclude these packets from the freshness update.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the two main changes: stabilizing the non-finite limiter key and preventing duplicate rejection counts.
Description check ✅ Passed The description directly explains the limiter-key fix, single-count rejection behavior, preserved finite-packet ticking, added tests, and validation results.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR

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

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Sep 30, 2026

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The changes correctly implement the two fixes described in the PR:

  1. Stable limiter key (lines 748, 841): Uses NON_FINITE_DIAGNOSTIC_CATEGORY constant instead of hashing the formatted message, preventing alternating-index NaN sources from bypassing rate limiting.

  2. Count once (lines 960-965): Already-rejected non-finite packets are now dropped before admission, preventing double-counting by the drained-packet gate while finite rejected packets continue to be admitted.

Both fixes are well-tested with three new comprehensive test cases covering alternating indices and various rejection scenarios. The implementation maintains the existing behavior for finite rejected packets and includes clear inline documentation explaining the logic.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

codescene-access[bot]

This comment was marked as outdated.

@codacy-production

codacy-production Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 14 complexity · 6 duplication

Metric Results
Complexity 14
Duplication 6

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@codeant-ai

codeant-ai Bot commented Sep 30, 2026

Copy link
Copy Markdown

CodeAnt Nitpicks

1 code suggestion

1. Stimulus and modulator failures share one limiter key, so a newly occurring failure type can be suppressed and never emit its first diagnostic.

Api mismatch · src/daemon.rs:839-841

coderabbitai[bot]

This comment was marked as resolved.

Extract observes_ingress and account_and_admit_backend_packet so
already-rejected NaN/Inf packets do not refresh input_freshness and
run_tick does not gain cyclomatic complexity from the double-count drop.

Co-authored-by: Raul Cardenas Montoya <montoyaraul34@gmail.com>
Comment thread src/daemon.rs
Comment on lines +936 to +938
// `rejected_batches` accounting below and is not admitted when it also
// carries a non-finite payload, so the drained-packet gate cannot count
// it a second time. Finite inputs are untouched.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 3c0e7af. The extra first_non_finite branch is now in account_and_admit_backend_packet, and freshness uses observes_ingress, so run_tick does not gain cyclomatic complexity from this follow-up. Fail-closed drained-gate early return is unchanged.

@rmems

rmems commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

Dismissed: a single non-finite limiter category is the intended P2 fix. Splitting stimulus vs modulator keys would reintroduce OccurrenceLimiter resets when a source alternates failure types — the same class of bypass the stable-key change closed. The warning text still names the offender; only the limiter identity is shared.

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Health Improved (1 files improve in Code Health)

Gates Passed
6 Quality Gates Passed

See analysis details in CodeScene

View Improvements
File Code Health Impact Categories Improved
daemon.rs 5.76 → 6.04 Complex Method, Large Method, Bumpy Road Ahead

Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@rmems
rmems merged commit 1dab1cd into main Sep 30, 2026
12 of 13 checks passed
@linear-code

linear-code Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

LIM-1482

LIM-1322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants