Skip to content

refactor(net): one delivery_start answer names SUBSCRIBE_START - #9641

Merged
kixelated merged 5 commits into
mainfrom
quest/m1/cursor-start-group
Nov 25, 2026
Merged

kixelated merged 5 commits into
mainfrom
quest/m1/cursor-start-group

Conversation

@kixelated

@kixelated kixelated commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Since moq-dev/moq#9529 an arrival read serves held groups newest first, so the first group out is no longer the lowest and the lite publisher has to work out where SUBSCRIBE_START points. That answer was rebuilt from parts in three places: Rust TrackRun::start (two loops over lowest_unread + servable), the JS publisher (hooks.lowestUnread / hooks.heldAt + skipped), and the fronts merging copies (lowestUnread / heldAt). Each fix had to land in all three.

Approach

  • Rust: track::Subscriber::delivery_start(track::Opening { first, source, given_up, serves }) holds the whole walk: the lowest held group it serves below first, lowered to the source's feed start, then stepped past runs given up and held groups it can't serve. TrackRun::start is one call. lowest_unread drops to pub(super) as the building block (the front's forget_past also reads it).
  • JS: hooks.deliveryStart(track, { first, source, givenUp }) does the same in track.ts. hooks.lowestUnread and hooks.heldAt are replaced by one per-copy primitive, hooks.lowestHeld(sub, from, below, servable) → { key, servable }, which the front (resume.ts) merges: of the copies holding the lowest group, servable if any can serve it. The lowest servable group is one forward scan per copy, and the walk asks only exact keys.
  • Twin property tests (delivery_starts_at_the_first_group_it_can_serve in Rust with proptest, delivery starts at the first group it can serve in JS with fast-check) check the answer over random held, headless, and given-up groups and sources against a declarative reference: from min(source, lowest servable held), the first key neither given up nor held unservable, capped at first. A mutation (ignoring unservable held groups) fails the JS one.

Choices made without asking, from the quest Plan's recommendations:

  • delivery_start takes the source start instead of the publisher taking min(source, answer) afterwards: the walk past given-up runs starts from the source, so taking the min outside would name a skipped group (held_first_group_starts_past_a_skipped_head).
  • Rust passes serves as a &dyn Fn inside Opening: the Rust track subscriber doesn't know the frames asked (the publisher's Frames), unlike the JS one (hooks.wholeGroups). Moving Frames into the model was more churn than this refactor warranted.
  • servable stays in the Rust publisher as the one definition position_group and serves share.
  • The differential test checks against a declarative reference rather than the old reconstruction: the walk moved verbatim, so comparing against its old copy would only test itself.

Impact

  • Public API: none. Wire: none. Behavior: none intended (all existing START tests unchanged and passing).

Compatibility with open work

  • moq-dev/moq#9626 (lite-07 Previous Delta, removes SUBSCRIBE_SKIP) holds only a claim commit so far. It will touch Start::Unresolved::skipped; that map now reaches the start answer only as Opening::given_up, so its rework changes one argument.
  • moq-dev/moq#9564 / moq-dev/moq#9577 touch resume.rs / resume.ts; this PR changes only the front's held-group merge there (lowestHeld in JS; Rust's lowest_unread unchanged).

Alternatives

  • A per-group frame map on the Rust track subscriber (as JS's wholeGroups) so delivery_start judges serving itself: symmetric with JS but moves publisher state into the model and needs syncing on SUBSCRIBE_UPDATE.

Validation

  • just check (rs, test rs, js, test js, rs_cross, and the rest) passed; biome formatting fixed after.
  • cargo test -p moq-net --lib --features async: 3857 passed.
  • JS track, lite publisher, resume, and resume model suites: 758 passed; just check passed on the head.

Follow-ups

None.

Models

  • Size: M
  • Implementer: Claude Code, claude-opus-5-5, unknown

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: 2169f73

  • Base: origin/main at 64c69c2

  • Risk: medium, A mistake in the new `delivery_start` could pick the wrong SUBSCRIBE_START group in the Rust and JS lite publishers, so a subscriber would miss or wait for groups, but the change keeps the public API and wire format, it reaches users only through the next release cut, and a revert fully undoes it; the quest plan deletion is low-risk documentation.

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session 6090852a-43f3-4867-a6da-57feef417271

  • Risk file: bb7b1c0de60b

  • Reviewer: Codex, gpt-6.2-sol, high effort

  • Session: 01a214e7-709c-77e1-9916-33b1fab4ef22, round 2

  • Score: 10/10, The START lookup now scans each route copy once for the lowest servable group, and the follow-up review found no regressions.

  • Rounds: 2; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0

  • Findings: none

  • The last round's findings, at 27db1e4:

    • Fixed: medium, js/net/src/track.ts:5577: Find the lowest servable group in one pass per copy; js/net/src/resume.ts:2489 takes the minimum across one forward scan per copy, and js/net/src/track.ts:5581 bounds each subsequent lookup to a single group key.

kixelated and others added 4 commits November 25, 2026 13:52
…s SUBSCRIBE_START

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… over random holdings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title A subscriber reports where its delivery starts refactor(net): one delivery_start answer names SUBSCRIBE_START Nov 25, 2026
… pass per copy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 25, 2026 23:04
@kixelated
kixelated added this pull request to the merge queue Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

JavaScript and Rust now centralize delivery-start selection in subscriber logic. The selection considers held groups, source starts, given-up ranges, and whether groups are servable. Both publisher paths use the selected start. Property-based tests cover the selection logic in both languages.

Merge Risk: Minimal · up to 2169f

This refactor moves SUBSCRIBE_START selection into shared subscriber logic in Rust and JavaScript without changing the wire format or public API. No concrete defect was established, and property tests plus the reported test suites cover the changed selection logic. It looks safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the refactor of SUBSCRIBE_START selection into a single delivery_start answer, which is the main change in the changeset: the Rust and JS publisher delivery-start logic now routes thro…
Description check Passed The description explains the problem (delivery-start logic duplicated across Rust publisher, JS publisher, and fronts), the new approach (Rust delivery_start, JS hooks.deliveryStart, lowestHeld replac…
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 refactor of SUBSCRIBE_START selection into a single delivery_start answer, which is the main change in the changeset: the Rust and JS publisher delivery-start logic now routes through track delivery_start/hooks.deliveryStart, and the front merge uses lowestHeld. The title is specific and matches the objectives, though 'one delivery_start answer names SUBSCRIBE_START' is terse and somewhat jargon-heavy.

Full details: Description check

Explanation

The description explains the problem (delivery-start logic duplicated across Rust publisher, JS publisher, and fronts), the new approach (Rust delivery_start, JS hooks.deliveryStart, lowestHeld replacing lowestUnread/heldAt), validation, compatibility with open PRs, and alternatives. It is directly related to the changeset.

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: 8f8fafc3-405f-406c-b3ff-119c527a1e95
Commits

Reviewing files that changed from the base of the PR and between b7701d3 and 2169f73.

Files selected for processing: 9

  • js/net/src/internal.ts
  • js/net/src/lite/publisher.test.ts
  • js/net/src/lite/publisher.ts
  • js/net/src/resume.ts
  • js/net/src/track.test.ts
  • js/net/src/track.ts
  • quest/m1/cursor-start-group.md
  • rs/moq-net/src/lite/publisher.rs
  • rs/moq-net/src/model/track.rs
Files with no reviewable changes: 1

  • quest/m1/cursor-start-group.md

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

Merged via the queue into main with commit 7de1816 Nov 25, 2026
9 checks passed
@kixelated
kixelated deleted the quest/m1/cursor-start-group branch November 25, 2026 23:13
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