Repository navigation
refactor(net): one delivery_start answer names SUBSCRIBE_START - #9641
Conversation
Quest-Claim: a0609f6a9dc03137
…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>
… pass per copy Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. WalkthroughJavaScript 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:
|
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 overlowest_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
track::Subscriber::delivery_start(track::Opening { first, source, given_up, serves })holds the whole walk: the lowest held group it serves belowfirst, lowered to the source's feed start, then stepped past runs given up and held groups it can't serve.TrackRun::startis one call.lowest_unreaddrops topub(super)as the building block (the front'sforget_pastalso reads it).hooks.deliveryStart(track, { first, source, givenUp })does the same intrack.ts.hooks.lowestUnreadandhooks.heldAtare 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.delivery_starts_at_the_first_group_it_can_servein Rust with proptest,delivery starts at the first group it can servein JS with fast-check) check the answer over random held, headless, and given-up groups and sources against a declarative reference: frommin(source, lowest servable held), the first key neither given up nor held unservable, capped atfirst. A mutation (ignoring unservable held groups) fails the JS one.Choices made without asking, from the quest Plan's recommendations:
delivery_starttakes the source start instead of the publisher takingmin(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).servesas a&dyn FninsideOpening: the Rust track subscriber doesn't know the frames asked (the publisher'sFrames), unlike the JS one (hooks.wholeGroups). MovingFramesinto the model was more churn than this refactor warranted.servablestays in the Rust publisher as the one definitionposition_groupandservesshare.Impact
Compatibility with open work
Start::Unresolved::skipped; that map now reaches the start answer only asOpening::given_up, so its rework changes one argument.resume.rs/resume.ts; this PR changes only the front's held-group merge there (lowestHeldin JS; Rust'slowest_unreadunchanged).Alternatives
wholeGroups) sodelivery_startjudges 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.just checkpassed on the head.Follow-ups
None.
Models
(Written by Claude Opus 5.5)
Review
Rewritten by
quest reviewafter 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-57feef417271Risk file: bb7b1c0de60b
Reviewer: Codex, gpt-6.2-sol, high effort
Session:
01a214e7-709c-77e1-9916-33b1fab4ef22, round 2Score: 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:
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.