Skip to content

fix(net): read lower buffered groups across route copies - #6019

Merged
kixelated merged 7 commits into
mainfrom
quest/m1/resume-ordered
Oct 20, 2026
Merged

kixelated merged 7 commits into
mainfrom
quest/m1/resume-ordered

Conversation

@kixelated

@kixelated kixelated commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A resumed Rust track reads the serving route first. If an old copy buffers group 1 and its replacement buffers group 2, sequence reads drop group 1 and arrival reads return 2 before 1.

Approach

Peek each ready copy with the existing floor, cap and drift checks, then take its lowest next group, mirroring JS Reader.#lowest. Ties favor newer copies so their first delivery still bounds replaced copies. Reserve the exact consumer and cursor position: eviction may abort that group, but cannot substitute a later group. Nested selection pins its chosen route copy with the existing lease. Local bounds invalidate reservations. Genuine lower groups arriving later remain deliverable in arrival order.

This finishes /quest/m1/resume-ordered.md, so the quest and its three references are deleted.

Decisions

Which group does a resumed arrival read offer first when copies disagree? (old copy holds [3, 1] in arrival order, serving copy offers [2])

  1. ✅ Lowest next deliverable head across copies (recommended): compare each copy's next group, preserving Rust's within-copy arrival order. The quest Plan already specified this shape ("peek each live copy's next deliverable group ... take from the copy with the lowest one"), and it is exactly JS Reader.#lowest; JS only differs because its per-copy buffer is sequence-sorted. Offers 2 first.
  2. Lowest buffered sequence anywhere across copies: follows the quest Goal's literal wording, but makes a resumed Rust arrival read reorder within a copy, unlike a direct Rust arrival read. Offers 1 first.

Declined Codex finding r4321978659: selection does not wait on a copy whose SUBSCRIBE is still pending. It holds no reader-visible group, and waiting would block live delivery on a replaced peer; this is unchanged from serving-first selection.

Picked by an unattended iterate round with no maintainer input; it is behavior only, with no API shape or wire impact.

Impact

  • Public API: behavior only. A resumed reader now selects the lowest next deliverable head across route copies, in both orders, while preserving Rust within-copy arrival order. No exported items or signature changes.
  • Wire: none.

Alternatives

Serving-first reads lose a buffered lower group in sequence order. Sharing peek/read cursor rules avoids a second bounds/drift implementation. A reusable reservation-slot trial showed no consistent timing gain (median 1.011x the retained implementation across 30 shapes), so it was dropped.

Validation

  • Before fix: regressions returned [2] (sequence) and [2, 1] (arrival), instead of [1, 2].
  • A deterministic adversarial test reproduced group 3 substituting for peeked group 1 after eviction in the first implementation. Exact reservations now pass eviction, changed bounds, and nested route replacement in both orders.
  • Merged origin/main twice. moq-dev/moq#5924 merged cleanly. moq-dev/moq#5929 replaced parked groups with ranges a widening owes; the reservation now sits on top of it: a peek leaves an owed group owed, and only a taking read consumes it (peeking_keeps_a_re_offered_group_owed, which returns group 2 on the second peek without the fix).
  • just check passes on the merged head: 7,692 native tests plus the minimal, capture/playback and play suites. One earlier run hit ietf::publisher::tests::a_draft_16_cancel_ahead_of_the_answer_ends_only_its_request, new on main from moq-dev/moq#6051. It fails 1 in 30 runs locally, and it exercises namespace announcements, not track reads.

The existing overlap benchmark now measures both orders across readers {1, 8, 32, 256}, buffered groups {1, 64, 1024}, and copies {1, 2, 8, 32}: 30 measured shapes, including single-copy cases. Same harness and CPU/worker bounds against baseline cdff3c8f9; 10 samples, 0.2s target measurement, 0.1s warmup. Whole-drain medians:

Order Readers/groups/copies Baseline After
Arrival 1/64/1 46.145 us 62.671 us
Arrival 1/64/2 100.410 us 140.420 us
Arrival 1/64/8 344.770 us 493.130 us
Arrival 1/64/32 1.2962 ms 2.2720 ms
Sequence 1/64/32 1.2954 ms 1.6914 ms
Sequence 32/64/8 10.991 ms 14.478 ms

This is a measured correctness cost, not a speedup: selection examines competing copies and reserves exact candidates. The cost is per handed-out group (about 1 us per group per reader in the single-copy case), not per frame. These sequential short runs share a host with other bounded builds; timing differences are indicative only.

Follow-ups

  • A single live copy could skip the peek-then-take round trip if the per-group cost ever shows up in a relay profile.

Resume-reorder moq-dev/moq#6003 is independent and is not incorporated.

Originally written by GPT-6.1-Sol.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

kixelated and others added 4 commits October 19, 2026 16:27
Co-Authored-By: GPT-6.1-Sol <noreply@openai.com>
Co-Authored-By: GPT-6.1-Sol <noreply@openai.com>
Co-Authored-By: GPT-6.1-Sol <noreply@openai.com>
Co-Authored-By: GPT-6.1-Sol <noreply@openai.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Checkpoint: source c2d3b0fe4 passed full just check, all 348 scoped model tests, and the 30-shape measured overlap sweep. Final 5f5399c81 restores only the unchanged original quest/reference metadata; all non-quest source is verified identical to the tested source. Baseline/after timings and shared-host limits are in the body; the correctness change costs more than serving-first selection.

The quest remains unfinished on one explicit maintainer decision: compare the lowest next deliverable head across copies (implemented, recommended to preserve Rust direct arrival order), or select the lowest buffered sequence anywhere, as the literal Goal/JS wording suggests. The old-copy [3, 1], serving-copy [2] example distinguishes them. Kept draft and preserved the original quest; no merges or auto-merge.

(written by GPT-6.1-Sol)

@kixelated
kixelated marked this pull request as ready for review October 20, 2026 06:04
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 64ff8b45-ffbc-46c0-b13e-7dfbcbee5dac
📥 Commits

Reviewing files that changed from the base of the PR and between 697441d and 48127c6.

📒 Files selected for processing: 7
  • quest/m1/README.md
  • quest/m1/resume-closed.md
  • quest/m1/resume-in-flight.md
  • quest/m1/resume-ordered.md
  • rs/moq-net/benches/origin.rs
  • rs/moq-net/src/model/resume.rs
  • rs/moq-net/src/model/track.rs
💤 Files with no reviewable changes: 4
  • quest/m1/README.md
  • quest/m1/resume-in-flight.md
  • quest/m1/resume-ordered.md
  • quest/m1/resume-closed.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

Walkthrough

Subscriber cursors now support non-consuming peeks for arrival-order and sequence-order reads. Resumed readers use peeks to select and retain the lowest deliverable group across route copies, then consume that reserved group. The changes add regression tests and benchmarks for both reader modes. The quest milestone and its related documentation links were removed.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 48127

Resumed track reads now deliver the lowest buffered group across route copies in both sequence and arrival order, rather than whatever the serving copy offers first. This fixes the reported cases where a lower group was skipped or delivered after a higher one. The change costs some extra selection work. No outstanding defects were found, so the change looks ready to merge once its tests pass.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 2 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely summarizes the main change: reading lower buffered groups across route copies.
Description check Passed The description is directly related to the changeset and explains the problem, implementation, behavior decisions, validation, and performance impact.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 2 files. (1 skipped: 1 too large.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-10-20T09:12:12.404588Z 48127c6 New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a1e506d5a

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread rs/moq-net/src/model/resume.rs
Port the peek/take reservation onto per-subscriber ranges (#5929): a
widening's owed group stays owed until a taking read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit 9f1fc92 Oct 20, 2026
6 checks passed
@kixelated
kixelated deleted the quest/m1/resume-ordered branch October 20, 2026 15:51
kixelated added a commit that referenced this pull request Oct 20, 2026
The peek-aware next_owed from #6019 keeps returning a group::Handle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant