Skip to content

fix(net): the JS resume model's routes are received copies, and a finished group buffered at abort reads on - #9396

Merged
kixelated merged 5 commits into
mainfrom
quest/m1/js-resume-model-received
Nov 22, 2026
Merged

kixelated merged 5 commits into
mainfrom
quest/m1/js-resume-model-received

Conversation

@kixelated

@kixelated kixelated commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Completes quest/m1/js-resume-model-received.md.

Summary

The JS resume model (js/net/src/resume.model.test.ts) now builds each route as a received copy, matching the Rust model::resume_model. Before, every route was a local publisher. Doing this exposed a real JS bug in track.ts: a short, finished group that was still buffered when its copy aborted could not be continued from another copy.

Changes

  • js/net/src/track.ts: when a track closes, it now releases only the unfinished buffered groups. A finished group stays readable, so if a front takes it after the abort, recovery can continue it from another copy. Previously such a group was released (#released), and #continues refused to continue it.
  • js/net/src/resume.model.test.ts: changes to how each route is built (up):
    • receiveTrack + dropAnchors: a received copy whose wire reports no start for a range. This is the JS counterpart of Rust's bare received() (Anchors::Refused).
    • An inert cache.Pool: Rust's route pools are never swept, so idle groups there never expire.
    • The two existing local-track regressions keep their local publishers behind a new local: true flag.
    • Four regressions added. Each one fails without its change:
      • Seeds 3/11 and seed 10 fail without dropAnchors.
      • Seed 12 (route give-up outlives an expiry) fails without the inert pool.
      • The up/close-down shape, where an ordered read takes the short group from the failed copy and reads on, fails without the track.ts fix.
  • js/net/src/resume.test.ts: "a short group on a failed route waits for the next one" now covers the group being taken both before and after the abort. The "after" case fails without the track.ts fix.
  • rs/moq-net/src/model/resume_model.rs: rewords one comment. A received route waits below a group that lands past its range; the old comment said it passes it.

Decisions

Each of these was my call while the user was away. All can be undone in review.

  • receiveTrack + dropAnchors, not the Plan's bare receiveTrack. In JS, bare receiveTrack is the lite-07 Wire mode (Rust received().anchored()), and it broke time-start placement in seeds 3, 10 and 11. Adding dropAnchors gives Rust's Anchors::Refused, which is what the Rust model's bare received() uses.
  • Inert pools on model routes. A JS BroadcastProducer pool expires idle groups after 30s on its own timer. Nothing drives a standalone Rust pool, so the two models disagreed on seed 12 and regression 27. Giving each route a new cache.Pool() without that timer makes them agree. Production code is unchanged.
  • The track.ts fix keeps finished buffered groups readable after an abort. An unfinished group still ends with the track. A finished one is complete: it can't be truncated, and a recovering front can continue it from another copy.
  • The local-track regressions stay as model cases behind local: true. I did not port them to unit tests, because JS has no test hook to force drop forgetting.
  • Two failure classes moved to follow-ups instead of this PR, because they mean reworking resume.ts, which moq-dev/moq#9316 and moq-dev/moq#9289 are also changing:
    • An ended reader that keeps following its route (seeds 4, 7, 10; 7 fails on main too).
    • A group continued onto a shorter failed copy (seed 9).
  • No Rust regressions. None of these cases reaches code the two languages share, and the Rust model already passes each one.

Validation

  • JS sweep, MOQ_RESUME_SEED=1..24 at 4096 cases each, run on this branch and on origin/main:
    • main fails seeds 2, 7, 14.
    • This branch fails seeds 2, 4, 7, 9, 10, 14.
    • Seeds 3, 11 and 12, plus regression 27 under received routes, failed before these fixes and pass now.
    • Seeds 2 and 14 are route-close shapes that Rust's sweep fails too; the in-flight resume-model-route-close quest owns them.
    • Seeds 4, 7, 10 and 9 are the two follow-up classes above. Seed 7 is pre-existing. Seeds 4, 10 and 9 are now reachable because routes are received copies: they are JS gaps that were already there, not regressions.
  • Each new regression and the "after" unit case was checked to fail with its fix reverted.
  • just check passed on the branch (Rust workspace tests and JS checks). The full js/net suite passes.

Public API and wire

Public API: none. Wire: none. track.ts changes behavior only: a finished group buffered at track abort stays readable.

Caused by

No single PR. Releasing every buffered sink group at track close predates recovery; it has been there since the JS core. moq-dev/moq#9277 made a short group on a failed route read on, but only for a group taken before the abort (found by check: the JS resume sweep with received routes).

Follow-ups

Models

Size: L
Implementer: Claude Code, 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: 8d204c3

  • Base: origin/main at 75b1af5

  • Risk: medium, The only shipped-code change is `js/net/src/track.ts`, where a closed producer now keeps finished groups readable instead of releasing them, a behavior fix for JS consumers that keeps the API and wire format, so a revert fully undoes it; the Rust change and the JS test edits are test-only and the quest plan files are docs, so nothing published breaks.

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session b9625fe8-19bb-4c52-8cfd-ec668f0dbf22

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

  • Session: 01a20313-1d0a-7412-9238-7e8c57cdfc12, round 1

  • Score: 8/10, Source review found no actionable defects and coherent regression coverage, but builds and tests were not run.

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

  • Findings: none

kixelated and others added 5 commits November 22, 2026 02:32
Checkpoint: the sweep still fails; see the PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…odel routes mirror Rust's

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… ended-reader and short-continuation cases

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title The JS resume model's routes are received copies, as Rust's are fix(net): the JS resume model's routes are received copies, and a finished group buffered at abort reads on Nov 22, 2026
@kixelated
kixelated marked this pull request as ready for review November 22, 2026 11:49
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

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: bed40941-8f50-4405-8689-2b8247a3345c
Commits

Reviewing files that changed from the base of the PR and between 142769f and 8d204c3.

Files selected for processing: 7

  • js/net/src/resume.model.test.ts
  • js/net/src/resume.test.ts
  • js/net/src/track.ts
  • quest/m0/nightly/js-ended-reader-routed.md
  • quest/m0/nightly/js-resume-short-continuation.md
  • quest/m1/js-resume-model-received.md
  • rs/moq-net/src/model/resume_model.rs
  • 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

@kixelated
kixelated enabled auto-merge November 22, 2026 11:50

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

Approach: sound. The fix targets the cause: #continues refuses a #released reader, so a finished group still buffered in a sink lost its recovery when the track closed. The fix stops releasing those groups. It does not special-case the front.

Reviewed changes

Reviewed the track.ts close-path change, traced against group.ts (#release, #continues, Producer.#end, #failHeld, mirror), plus the model and unit test changes.

  • Producer.#close keeps finished buffered mirrors readable. At this point, open cache entries have already been unlinked from every sink by #unlink. #detached and cached groups have been aborted with groupError. So the groupFate(...)() !== undefined check releases exactly the failed mirrors and leaves the closed === null ones alone. A plain consumer without #recover still drains a kept mirror and then ends cleanly. Only a front's recovery gains the ability to continue it.
  • JS resume model routes are received copies. Routes now use poolTrack with an inert cache.Pool, plus receiveTrack and dropAnchors. This matches Rust's never-swept route pools and Anchors::Refused. The two local-track regressions keep their old shape behind local: true.
  • New regressions and the before/after unit case. Four model regressions are added, and "a short group on a failed route waits for the next one" now runs with the group taken both before and after the abort.
  • Rust model comment. Reworded to say that a received route waits below a later group instead of passing it. There is no code change.
  • Follow-up quests. Two gaps are split out into their own quests: ended-reader routing (seeds 4, 7, 10) and short continuation onto a failed copy (seed 9).

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

@kixelated
kixelated added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 88c9d4b Nov 22, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m1/js-resume-model-received branch November 22, 2026 13:16
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