Skip to content

fix(moq-net): a resumed read ends with the track and keeps its range's end across a backfill - #8859

Merged
kixelated merged 1 commit into
mainfrom
fix/resume-bound-reopen
Nov 16, 2026
Merged

kixelated merged 1 commit into
mainfrom
fix/resume-bound-reopen

Conversation

@kixelated

@kixelated kixelated commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The scheduled Nightly's test resume-model job failed on main (run 43724172821, MOQ_RESUME_SEED=1648062584). The seed hits two separate defects in rs/moq-net/src/model/resume.rs. The model and the TLA+ spec are right in both cases.

  1. A reader whose local bounds leave nothing in its range (range 3..4, bounds 0..1) never ended once the track finished after a route switch. bound_at_end bounded the replaced copy through Copy::update, which since feat(moq-net)!: address groups by their start #8638 calls reopen(). That cleared the done the same poll had just recorded, let_go then judged the copy Wait (its unread group 3 sits past the local cap), and the read parked with nothing left to wake it. ResumeReader.tla's BoundAtEnd never resets done, so the code had drifted from the spec.
  2. Once the first defect was fixed, the same seed found a second one. After a route switch and the old route failing, a reader that narrowed its ranges to 6..9 never got group 8. The backfill copy, capped at 7, resolved the range's time end against its own capped wire, and Reader::window took that capped end (7) as the reader's window end. The serving copy's group 8 was then skipped as outside the window.

Approach

  • New Copy::bound(until, reader) sets the bound and since and sends the narrowed wire without reopen(). observe and bound_at_end use it. A bound only narrows what a copy may deliver, so a copy that ran out stays out. update (ranges, budget, bounds changes) still reopens.
  • In Reader::window, a capped copy's resolved end at or past its cap is dropped. The end then comes from the reader's own anchor, or from an uncapped copy, matching how the existing filter already ignores a cap that empties the start.
  • One regressions() case per defect, each as the sweep shrank it.

The JS reader needs no change: its #bound never resets done, and it has no per-reader window resolved from capped copies.

Impact

None on the public API or wire. Behavior change inside the relay's resume reader only.

Caused by

  • moq-dev/moq#8638: added reopen() to Copy::update, which bounding also calls, and resolved time-addressed ranges through copies whose cap shortens the resolved end. Found by the Nightly resume-model check. Both cases pass at its parent 466f2f6c81 and fail at 7d1bee79cb.

Validation

  • Both new regressions() cases failed before the fix (the first: track end None, the second: missing groups [8]) and pass after it.
  • just test resume-model (Rust sweep plus the JS model) with the Nightly seed 1648062584 (4096 cases) passes. Fresh seeds 826245900 and 1601925091 also pass.
  • All 179 model::resume* tests pass. quest gate just check passes (12810 tests).
  • TLC not rerun: ResumeReader.tla already describes bounding without reopening, and range resolution is outside what it models.

Alternatives

  • Make has_unread_group in Copy::retains respect the local cap. Rejected because the copy had already drained, and reopening it was the actual mistake. The cap is ignored there on purpose, so a rising cap finds the group again.
  • Skip capped copies in Reader::window entirely. Rejected because a capped copy's start resolution is still sound, and it can be the only ready copy.

Follow-ups

  • Another fresh seed, 849441640, fails on an independent defect. It predates feat(moq-net)!: address groups by their start #8638 (it also fails at 466f2f6c81). An ordered reader on a fresh copy of a route that gave up group 8 (drop_groups) parks at 8 and never reads 9 to 11, but only when an earlier reader subscribed before the drop. Case: Join{0, unordered}, Write{i0 s0 g8 1}, Up{i0 s2}, Write{i0 s2 None 1}, GiveUp{i0 s2 g8}, Join{1, ordered}, finish: false. This PR leaves it alone: it lives in the ordered cursor or in drop propagation to a later subscriber, not in the code changed here.

Models

Size: S
Implementer: Claude, claude-opus-5-5, unknown effort

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 45b38a0

  • Base: origin/main at 698ce5a

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1e046-ae46-7000-9f5c-ff12f6496406, round 1

  • Score: 9/10, The changes preserve exhausted-copy state when narrowing bounds and prevent a backfill cap from truncating the reader’s range; source review found no actionable defects, with builds and tests intentionally not run.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

…s end across a backfill

Bounding a replaced copy at the serving copy's first group or the track's end
no longer reopens a copy that already ran out, so a reader whose local bounds
leave nothing in its range ends with the track instead of parking forever. A
capped copy's resolution of a range's end no longer sets the reader's window
end, so a backfill's cap cannot drop groups the reader's range still covers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 15, 2026 17:36

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

This review covers both fixes to the resume reader in rs/moq-net/src/model/resume.rs and the two regression cases added for them.

  • Copy::bound no longer reopens a drained copy: observe and bound_at_end now set until and since and send the narrowed wire without calling reopen(). As a result, the replaced copy keeps its done, and let_go no longer waits on a copy that has nothing left to send. update still reopens when ranges, budget, or bounds change, which is the case where reopening is needed.
  • A capped copy's resolved end no longer sets the window end: In Reader::window, a resolved end at or past a copy's failover cap is now dropped. resolve then uses the reader's own anchor instead. I checked that this fallback is exact: Window::new(.., &Placed) turns a raw Anchor::Time(t) end into t + 1 through window.rs's end(), and group keys are times. The start filter, which ignores a copy whose cap empties the range, is unchanged.
  • Regression cases: regressions() gets one shrunk case per defect.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Replaced-copy bounding now updates the copy's subscription using the reader's ranges. Reader.window adjusts resolved range metadata when a failover cap applies. Two regression cases cover track-end bounding and capped backfill behavior.

Merge Risk: Minimal · up to 45b38

This change fixes two resume-reader defects: a reader parked after the track ended, and a reader skipping a group after a backfill. It has no public API or wire impact. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two defects fixed: a resumed read ending with the track, and keeping the range end across a backfill. Both match the changeset in rs/moq-net/src/model/resume.rs and the new regress…
Description check Passed The description explains the two defects, the approach (Copy::bound and the Reader::window change), the regression cases, validation, and alternatives. It matches the changeset in resume.rs and resume…
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: Title check

Explanation

The title names the two defects fixed: a resumed read ending with the track, and keeping the range end across a backfill. Both match the changeset in rs/moq-net/src/model/resume.rs and the new regression cases. The title is long (92 characters), but it describes the main change.

Full details: Description check

Explanation

The description explains the two defects, the approach (Copy::bound and the Reader::window change), the regression cases, validation, and alternatives. It matches the changeset in resume.rs and resume_model.rs.

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c853a4e-d510-4dd5-994e-5e856dbf4e37
Commits

Reviewing files that changed from the base of the PR and between 698ce5a and 45b38a0.

Files selected for processing: 2

  • rs/moq-net/src/model/resume.rs
  • rs/moq-net/src/model/resume_model.rs

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

@kixelated
kixelated added this pull request to the merge queue Nov 16, 2026
@kixelated
kixelated removed this pull request from the merge queue due to a manual request Nov 16, 2026
@moq-bot

moq-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

quest land watch: the merge queue removed this pull request at 45b38a0 because kixelated removed it (manual).

A person's removal ends the pick: the watcher leaves this pull request alone until a maintainer enqueues it again.

(written by quest land watch)

@kixelated
kixelated added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 60f728b Nov 16, 2026
7 checks passed
@kixelated
kixelated deleted the fix/resume-bound-reopen branch November 16, 2026 10:10
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