Repository navigation
fix(net): a JS switch before any group drops the replaced copies as Rust does - #9436
Conversation
Quest-Claim: 67ac71c05d96d123
…ust does A switch with nothing held nor handed out keeps only the incumbent's copy, and the serving copy's first delivery (when the Rust front splices it) drops that one too instead of capping it below the delivered group. Ports `a_switch_before_any_group_drops_the_replaced_copy` and deletes the JS no-boundary incumbent test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…undary-parity # Conflicts: # quest/m0/nightly/js-ended-reader-routed.md
|
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 10 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. |
There was a problem hiding this comment.
Important
The no-boundary drop keys on route.incumbent, which Route.park() clears. So a park then serve switch now drops the parked copy before the new route delivers. That is the "drop at Route.serve" divergence the PR's Decisions section rejects.
Approach: sound in shape. Treating the serving copy's first delivery as the JS splice moment, and keeping only the incumbent at the switch, is the right mapping onto the Rust front. But the "who is the incumbent" test misses the between-routes path.
Reviewed changes
The full diff at 26672ff was reviewed against main, along with Route (serve/park/revert/resubscribe), #joinIncumbent, #observe, #revert, and the Rust Reader::sync/park/origin splice path.
Reader.syncno-boundary branch: drops every copy whose source isn'troute.incumbent, after#learnEnd, instead of leaving them uncapped.#delivering: on the serving copy's first delivery with nothing handed out and no other copy holding a group, it drops uncapped replaced copies instead of capping them below the delivered group.#dropCopies: a new helper that learns a declared end before letting copies go, mirroring Rust'slearn_endbeforecopies.clear().- Tests: the Rust no-boundary test is ported, an A→B→C test checks that the never-delivered middle copy is dropped, and the JS incumbent no-boundary test is deleted.
claude-opus-5-5 | 𝕏
A no-boundary switch after Route.park() dropped the parked copy at once, since park cleared the incumbent. Park now holds the serving source as a replacement would, so the copy stays until the next route delivers and #revert still falls back to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound. The fix at the root in Route.park keeps the JS switch aligned with Rust, where the old copy keeps serving until the replacement splices.
Reviewed changes
Reviewed the delta since 26672ff (commit 2d4e2e9).
Route.parkholds the serving source as incumbent: a park is now a switch to no route that keeps the serving copy as the incumbent, so the no-boundary rule keeps it until the next route delivers and#revertcan still fall back to it. This resolves the earlier thread on the park→serve drop.- Tests: added "a switch before any group after a park keeps the parked copy until the new route delivers" and "a replacement after a park that aborts before any group leaves the parked copy serving".
claude-sonnet-5-5 | 𝕏

Closes the gap moq-dev/moq#9276 left open on purpose: a route switch that finds nothing held and nothing handed out (no boundary) now drops the replaced copies in
@moq/netasrs/moq-netdoes, so the same route change delivers the same groups in both. Finishes and deletesquest/m1/switch-no-boundary-parity.md.Changes
The Rust and JS switches happen at different moments. The Rust origin splices a replacement only once it delivers a group (or the old copy ends), so a Rust reader keeps reading the old copy until then, and only that delivery reaches
Reader::sync, which then drops every replaced copy if there is no boundary. The JSRouteswitches as soon as the replacement answers and covers the gap withroute.incumbent. So the JS equivalent of the Rustsyncis the serving copy's first delivery, notRoute.serve. A plain drop in#syncchanges nothing, because#joinIncumbentre-subscribes the incumbent right away (I tried it: every test still passed, behavior unchanged).js/net/src/resume.ts:#syncwith no boundary keeps only the copy ofroute.incumbent, uncapped, and drops the rest: copies of routes replaced before they delivered, which the Rust front never splices for a reader.Route.parknow holds the serving source as the incumbent, asservedoes, instead of clearing it. A park is a switch to no route, so after park → serve(B) the parked copy stays until B delivers, and#revertstill falls back to it if B fails first (found by Pullfrog). A reader that joins after park → serve(B), before B delivers, now reads the parked source too, as Rust keeps the old copy until the replacement splices.#delivering: when the serving copy delivers (first hand-out in#observe, or already holding a group in#joinIncumbent) with nothing handed out and no other copy holding a group, it drops the uncapped replaced copies instead of capping them just below the delivered group. That matches the Rustsyncwith no boundary at splice time. With a boundary, the existing cap is unchanged.#dropCopieslearns any declared end before dropping, as Rust'slearn_enddoes beforecopies.clear().#observeand#boundaryupdated.Tests:
a_switch_before_any_group_drops_the_replaced_copyas "a switch before any group drops the replaced copy once the new route delivers": with a long latency budget and a received (late-landing) old route, a group landing on the old route after the new one delivered is not read, and the old route is unsubscribed.The plan asked to check that
#joinIncumbentstill covers a reader joining before the new copy delivers: it does. "a reader joining before the replacement delivers keeps the incumbent when the replacement aborts" and "a replacement that aborts before any group was held leaves the incumbent serving" still pass, because the incumbent's copy is kept until the serving copy delivers.Impact
Public API: none. Wire: none. Behavior: in
@moq/net, a group that lands on the old route after the new route delivered first is no longer read when the reader had nothing yet (the new route, asked from the reader's own start, serves it if it has it), and a route replaced before it delivered stops being read at the next switch.Decisions
Taken without asking (a later review can undo them):
Route.serve. Dropping atRoute.servewould leave a JS reader reading nothing during the handover, where a Rust reader keeps the old copy, and#revertwould lose the copy it falls back to. That would be a different divergence, not parity.#joinIncumbentre-subscribe: same groups, without a resubscribe per switch.Validation
bun test src/injs/net: 3638 pass, 0 fail.resume.tsand pass on the new one (checked by swapping the file).resume.model.test.ts(random route flips, failures, joins, checked against one plain cursor) withMOQ_RESUME_CASES=1000on seeds 11, 22, 33, 44: all pass. Instrumented once to confirm coverage: in 300 cases the first-delivery drop fired 30 times and the switch drop 10 times.just check: everything passed (11224 Rust tests, JS check, biome, dead code) exceptcheck quest, which ran with a stalequest(eaee1d5) in my shell that still expects the skill stubs moq-dev/moq#9421 removed.nix develop --command quest checkwith the pinned quest a88c65b reports "516 documents ok".quest/m0/nightly/js-ended-reader-routed.md, the one file that linked this quest):bun test src/3642 pass, 0 fail.just checkpassed except the same stale-shellcheck quest, plus 4moq-mux jitter::teststhat timed out at 60s together under the full-suite load. This branch doesn't touchmoq-mux, and all 64 jitter tests pass alone in 3.4s (sh/rs/nextest.sh cargo nextest run -p moq-mux --all-features -E 'test(/jitter::tests::/)').main, and pass on the fixed head. After the fix,bun test src/passes 3644, and the model sweep (seeds 11, 22, 33, 44 × 1000 cases) passes. Coverage gap: instrumenting showed the model sweep never reachesRoute.park(its up/down steps never resolve a route of the same instance without a front), which is how this got past it. I didn't add it, because that would change how the model drives the origin.Reader::syncand the models are unchanged; this aligns JS to the shape ResumeReader'sSyncalready models.Caused by
No single PR: the JS incumbent-until-delivery design predates the Rust drop, and moq-dev/moq#9276 kept the split on purpose and deferred it to this quest.
Follow-ups
None.
Models
Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm B)
Implementer: Claude Code, claude-opus-5-5, unknown effort (iterate, M, arm B)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 2d4e2e9
Base: origin/main at 4e7205c
Risk: medium,
What could break: `@moq/net` switch behavior changes, since a route switch before any group now drops replaced copies immediately, and a parked copy stays incumbent until the next route delivers, so JS consumers of the resume reader may see different groups during failover; the API, wire format, and Rust code (a doc-comment-only change) are unchanged, and a revert fully undoes it, so this is a fix to shipped code, not a high-tier break.Classified: medium by Claude Code, claude-haiku-5-5, low effort, session
b9c36a10-75f1-4766-b218-8e7f17edb3bfReviewer: Codex, gpt-6.1-sol, high effort
Session:
01a204cf-0964-7671-b6fc-bbbfe3231a63, round 3Score: 8/10,
The incremental change preserves the parked incumbent through replacement delivery or failure, with focused regression coverage and no actionable findings; builds and tests were not run as instructed.Rounds: 3; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none