Repository navigation
fix(moq-net): a resumed reader takes groups landing late on a drained copy - #9103
Conversation
Quest-Claim: cd22f356cdf0dbdb
… copy A copy whose channel ran out cleanly stayed done for the rest of the read, so a group still in flight below the end its session settled was lost when it landed while a replaced copy held the read open. A drained copy now reopens once a group arrives on it after it ran out. A late group under the serving copy's resume point asks its route again, since the backfill that wanted it may have run out and been let go. The resume TLA+ model lands groups after a session settles its end (Settle) and checks a clean end carried every group each live track landed. JS mirrors the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/resume-range-reader
A copy's clean drain now holds the arrivals it saw in its done state, in Rust and JS, instead of a separate field beside it. The resume model's sync commit names the PR's base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 8 minutes. View limit details
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. |
|
Decisions from the maintainer:
(Written by Claude Opus 5.5 with high) |
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound. The fix targets the real cause, a cleanly drained copy that stayed done for the rest of the read, rather than the quest's guessed range logic. It reopens on a plain arrival counter, so a drained copy costs one compare per poll.
Reviewed changes
I reviewed the full diff: the Rust and JS reader changes, the new arrival hooks, the TLA+ model extension, the regressions, and the quest bookkeeping.
- Arrival count on a clean drain —
Copy::donenow carriesResult<usize>in Rust andError | numberin JS. It recordsTrackState::next_arrival(or the JS sink'sarrived) as of the drain.track::Consumer::arrivedandpoll_arrivedare crate-private and park the reader's idle waiter, so a late landing wakes the read. - Reopen in
poll_lowest— a drained copy that is notspentand has new arrivals is read again. The re-drain loop compares against a snapshot taken before the read, so a group landing during the read is not missed. Each extra pass needs a fresh arrival, so the loop is bounded. - Re-backfill on the serving copy — when the serving copy (not
replaced, has afloor, current generation) reopens, the reader is markedresumedagain. Backfill copies arereplaced: true, so they never trigger this. ReturningNonehands control back to the caller's loop, which rerunsbackfill_gapswith the same(None, [])value thatsyncalready uses when ranges change. - JS mirror —
#reopen()runs before#backfillGapsintryGroup. I also probed the separate async clean-end path (sub.closed.then→#conclude) with a fresh serving route and a late group under its floor:- If the group lands before the replaced copy fails, it is delivered.
- If it lands after, the read ends cleanly, which
Carriedallows.
ResumeReader.tla— addsSettle(late landings after a settled end), reopening inScan, a recursivePassfor re-backfill, and a strongerCleanEndIsComplete(Carried).- Regressions and tests — two
regressions()cases (ranged and unranged) and two unit tests per language. TheCopy::donepattern matches atend_error,bound_at_endandreopenare updated toSome(Ok(_)).
claude-opus-5-5 | 𝕏

Claims quest/m1/precut-fixes/resume-range-reader.md.
Problem
The resume model's sweep fails on
mainat seed 3 (MOQ_RESUME_SEED=3 MOQ_RESUME_CASES=50000): a reader resumed across routes misses a group of the logical track. The quest expected range logic inReader::window. The failure is not range-specific. A copy whose channel ran out cleanly (done = Some(Ok(()))) stayed done for the rest of the read. A received copy whose session settled its end at its live edge is complete at once, yet groups still in flight below that end may land on it afterwards (create_groupbelow the end is allowed). If a replaced copy holds the read open meanwhile, those groups are never read. The unranged regression inresume_model.rsshows the same loss without a range.TLC found a second ordering on the first fix: a late group under the serving copy's resume point is lost after the backfill that asked for it drained the complete track and was let go.
Approach
track::Consumer::arrived/poll_arrived(crate-private) count the groups that arrived on a copy, fromTrackState::next_arrival, and wake a waiter once another lands.resume::Copyrecordsdrained, the arrivals when its channel last ran out cleanly.poll_lowestreopens a drained copy once a group arrives after that, while the copy's span is not yet spent, and rechecks right after draining so a group landing during the read is not missed.resumedagain, sobackfill_gapsasks its route for it once more.hooks.arrivedcount kept bytrack.ts,Copy.drained, and#reopen()before#backfillGapsintryGroup.ResumeReader.tlalands groups on a track after its session settled (Settle), reopens a drained copy inScan, re-runs backfill on a late group (Pass), andCleanEndIsCompletenow also requires every group each live track carried (Carried).Impact
Alternatives
Validation
mainat 4f3ba33. Two newregressions()cases (ranged and unranged) and two unit tests (a_late_group_on_a_drained_serving_copy_is_read,a_late_group_under_the_resume_point_is_backfilled_again) fail without the fix and pass with it.CleanEndIsCompleteviolation within a second. With the fix it passes: main config 19,871,459 distinct states in 4m53s,ThreeRoutes.cfg7,384,328 in 1m12s.moq-netlib tests pass.quest gate just checkpasses.group 0 outside ranges, with or without this PR. moq-dev/moq#9027 introduced it (it passes on its parent), so Nightly'stest/resume-model.shfails on the JS side until resume-js-window lands.Caused by
Decisions
Reader::window) was wrong. This PR fixes the actual loss and leavesReader::windowunchanged.Reader::windowmutants the quest planned to kill move to a follow-up, resume-window-mutants, with the analysis of each.owes_belowguard ported into JS#lowest.Follow-ups
Models
Size: M
Implementer: Claude, claude-opus-5-5, high effort
(Written by Claude Opus 5.5 with high)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 86fb205
Base: origin/main at b6c248c
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, high effort
Session:
01a1f06e-aaea-7880-b1a1-19667f95ca41, round 2Score: 10/10,
Both findings are fixed, and inspection of the incremental changes found no new issues; no builds or tests were run.Rounds: 2; first round 2 (medium 1, low 1); findings 2 (medium 1, low 1): fixed 2, refuted 0, open 0
Findings: none
The last round's findings, at b723596:
js/net/src/resume.ts:348:Carry the arrival snapshot inside the drained state;JS and Rust now carry the arrival snapshot inside the clean done variant, and reopening reads it directly at js/net/src/resume.ts:997 and rs/moq-net/src/model/resume.rs:1697..claude/skills/verify-resume/SKILL.md:43:Anchor model coverage to the PR base;.claude/skills/verify-resume/SKILL.md:43 now anchors both references to the updated PR base 8c939bc9d05e and identifies this PR.