Skip to content

fix(net): a resumed read asks upstream for a kept-out key no held copy knows - #9435

Merged
kixelated merged 12 commits into
mainfrom
quest/m1/resume-kept-out-reask
Nov 23, 2026
Merged

kixelated merged 12 commits into
mainfrom
quest/m1/resume-kept-out-reask

Conversation

@kixelated

@kixelated kixelated commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m1/resume-kept-out-reask.md.

Problem

A bounded resumed read owes a key that its local floor or cap keeps out under the serving copy's resume point until a copy declares it skipped. moq-dev/moq#9326 kept only the skipped start and end of each gap from copies it let go, so an interior skip known only to a let-go copy was lost. For example: copy A alone declared [2,3) skipped in gap [1,5) with the floor at 3, A was let go, and a later copy declared [1,2) and [3,5). Group 2 stayed owed, no copy knew it, nothing asked for it, and the read stayed pending.

Approach

The reader asks the serving route again instead of keeping skip history, per the cache rule. Rust (rs/moq-net/src/model/resume.rs) and JS (js/net/src/resume.ts) both get this:

  • Reader::accounts collects the kept-out keys that are neither recorded nor declared skipped by a held copy, and asks the serving route for their hull through the existing backfill path (Reader::ask). It polls a nested front's copy ready so its inner reader exists to answer.
  • Reader::asking (JS #asking) runs on every let-go. It returns the key where the ask starts, and replaces Reader::skipped with only the skipped run at the start of each kept-out run. That is at most two runs a gap, however many routes come and go, and it is written before the cache that answered can forget it (JS drop records expire after the pool's idle window).
  • let_go keeps one replaced copy: of the serving channel's copies asked for that key (Copy::asked_for), the one reaching furthest. A waiting reader therefore asks once instead of on every poll. Moving the window again and again still keeps one copy, because an ask from lower down covers the ones before it.
  • Removed: the let-go merge of every copy's skips and its start/end trim (JS #keepSkips, #lacking).

Impact

  • Public API: none. Wire: none.
  • Behavior: a bounded resumed read whose floor or cap keeps a key out now asks the serving route for it, so it ends when a single cursor would, instead of staying pending.

Decisions

  • Maintainer: owe it, ask upstream. A kept-out key stays owed by a bounded read, as on one cursor, and the reader asks upstream for it, so a single cursor and a resumed reader end the same read at the same time. Recorded in the quest before finishing it (2084774).
  • A bounded record, not none. I first tried keeping no history, but the JS split case then timed out: the serving copy's track forgot a skip it had answered once its drop record expired, and the deduplicated ask never repeated. The prefix record fixes that and stays bounded by the gaps.
  • One ask over the hull of the unknown kept-out keys, through backfill, rather than one subscription per run.
  • One retained ask. Review round 1 (Codex) found that keeping every asked copy that overlapped the owed keys could stack one copy per downward window move, past the budget. Only the copy asked furthest from the first owed key is kept now; the others go by Copy::retains and the budget.
  • Tests: a_skip_behind_an_inner_switch_ends_the_read is now language-agnostic, because JS ended without asking while its inner front still held the old copy. Both languages now end after the route's skip. Deleted a_skip_behind_an_inner_front_the_local_floor_keeps_out_ends_the_read, which is superseded by a_kept_out_key_is_asked_through_an_inner_front. Added the quest's case, the inner-front ask, and an asked-once/stays-owed case in both languages.
  • Merged main twice for conflicts (moq-dev/moq#9410, moq-dev/moq#9407). fix(net): a bounded read across a route switch waits for its backfill; the range table stalls the old route #9407 added Reader::owed (what only a fill may still deliver), so this PR's function is named asking, built on fix(net): a bounded read across a route switch waits for its backfill; the range table stalls the old route #9407's lacking. fix(net): a bounded read across a route switch waits for its backfill; the range table stalls the old route #9407's owed now sees the smaller record. A fill may therefore wait for its own answer on an admitted key that a let-go copy skipped at a gap's edge. That is bounded by the reader's budget, and the sweeps are unchanged.
  • Pullfrog's interior-skip finding is refuted for this PR. If the route answers [3,5) first and [1,3) only after the pool's expiry window, the read stays pending. One plain JS cursor does the same: with a 10-hour budget, it ends when both skips arrive together and stays pending when they arrive 60 s apart. The maintainer's rule is that a resumed reader ends a read when one cursor does, and it does. The track-level cause is the forgotten-skip-reask follow-up.

Validation

  • Reproduced before the fix: the quest's case stayed pending on main because the serving route was never asked for the kept-out key.
  • Rust: just rs test -p moq-net --features async filtered to resume and integration tests, 926 passed. JS: bun test on resume, track, and range-table, 592 passed. Both runs were after the last merge.
  • Mutation: with the asked-copy retention removed, a_kept_out_group_is_asked_once_and_stays_owed fails in both languages. The Rust case tracks the asked copy's lease, and the JS case counts subscribe calls.
  • The review finding was reproduced first. a_window_moved_down_under_the_local_floor_keeps_one_ask (Rust) and "a window moved down under the cursor keeps one ask" (JS) move a bounded window down 10 times over kept-out keys, then pass the budget. On the previous head, Rust kept 10 asked copies and JS kept 11 open route subscriptions. With the fix, Rust keeps 1 and JS keeps 2 (the serving copy and the ask). Rust resume and integration tests: 927 passed. JS: 593 passed.
  • Differential resume-model sweeps at MOQ_RESUME_CASES=4096:
    • Rust seeds 1-40: the branch and main (ceb5790) have the same failing seeds with the same messages (8, 19, 22, 28, 31, 33, 36, 37, 39). These are pre-existing and tracked by the resume-model-placement and resume-model-route-close quests.
    • JS seeds 1-12: the branch matches main (2, 9, 10). Seeds 4 and 7 had looked like regressions, but they also fail at the merge base; fix(js/net): an ended reader moves its open groups off a dying route #9410 fixed them on main.
    • Both sweeps were rerun after the review fix (34c3256), and both still match main exactly.
  • Real relays: just test relay-fill, 2 passed (range table through relays, and Rust peers through the JS relay).
  • just check: passes.
  • Not run: the TLA+ verify-resume model, which covers unbounded subscriptions, where this path never runs.

Caused by

No single PR: the case is as old as owing kept-out keys across route changes. moq-dev/moq#9326 bounded the record and deferred this case explicitly.

Follow-ups

  • quest/m1/js-kept-out-start-placement.md (M). When the local floor keeps out the group holding a window's time start and no copy has placed that start, JS reads the window from window.floor() ?? 0n. It then asks the serving route for [0,10) where Rust asks for [9,10), so it owes groups below the window that one cursor does not. This note first went into resume-model-placement.md, which moq-dev/moq#9389 deletes, so it moved to its own quest at the maintainer's request. No open decisions.
  • quest/m1/forgotten-skip-reask.md (L), from Pullfrog's finding on this head. A received track forgets a skip after the pool's expiry window. A bounded read whose kept-out keys are skipped in parts that straddle that window then stays pending for good, for one plain cursor too. It recommends asking upstream again for the forgotten verdict, per the cache rule, rather than pinning the runs. No open decisions.

Models

Size: L
Implementer: Claude Code, claude-opus-5-5, unknown effort
Implementer: Claude Code, claude-opus-5-5, unknown effort (iterate, L)

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: 329c12c

  • Base: origin/main at 52125fe

  • Risk: medium, This is a bug fix to the internal resume-reader logic in rs/moq-net and js/net that keeps the public API and wire format. What could break is a bounded read that now asks upstream for kept-out keys it used to owe silently, so consumers may see extra subscriptions or different end timing. A revert of this diff fully undoes it, so it is medium rather than high, and the quest plans and tests are low on their own.

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session 3f65b3cf-cf22-44d6-aab2-ab44092b0ee2

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

  • Session: 01a2055a-3d36-7180-b240-e7ae738c32db, round 4

  • Score: 10/10, The incremental diff only reorganizes and adds quest plans, with no runtime changes or new findings.

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

  • Findings: none

kixelated and others added 8 commits November 22, 2026 11:21
…y knows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the rest, in Rust and JS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…out-reask

# Conflicts:
#	js/net/src/resume.ts
…out-reask

# Conflicts:
#	rs/moq-net/src/model/resume.rs
…and ask upstream

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 resumed read asks upstream for a kept-out skip no copy still knows fix(net): a resumed read asks upstream for a kept-out key no held copy knows Nov 22, 2026
kixelated and others added 2 commits November 22, 2026 14:56
…indow moves

Every ask starts at the first kept-out key no copy declared skipped, so only the copy
asked furthest from there needs keeping; an ask from lower down covers the rest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the local floor

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 22, 2026 23:26
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Rust and JavaScript readers now track skip information for keys excluded by local bounds and request uncovered keys from the serving route. They retain an asked-for copy across route replacements. Tests cover partial skip declarations, returned groups, repeated window changes, and nested-front route switches. The change also adds two planning documents and removes one prior planning document.

Merge Risk: Minimal · up to 329c1

This change makes bounded resumed reads ask the serving route for kept-out keys that no held copy has declared skipped, so a resumed read can end when a single cursor would. No concrete defect was found in the reviewed change. The author reports one limitation: a read can stay pending when skip answers straddle the cache's expiry window, which matches plain cursor behavior and is tracked as a follow-up.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main fix: a resumed read asking upstream for a kept-out key that no held copy knows. The raw summary and PR objectives confirm the changes in resume.ts and resume.rs match this. Th…
Description check Passed The description explains the problem, the approach, impact, decisions, validation, and follow-ups. It relates directly to the changeset, which touches resume.ts, resume.rs, the test files, and the que…
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 main fix: a resumed read asking upstream for a kept-out key that no held copy knows. The raw summary and PR objectives confirm the changes in resume.ts and resume.rs match this. The title is specific and accurate, and the 'fix(net)' prefix fits the bug-fix nature of the change.

Full details: Description check

Explanation

The description explains the problem, the approach, impact, decisions, validation, and follow-ups. It relates directly to the changeset, which touches resume.ts, resume.rs, the test files, and the quest documents. It also references the deleted quest document and the new follow-up quests.

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: 922a694f-198f-41b9-8228-0de0fcff5d7f
Commits

Reviewing files that changed from the base of the PR and between ceb5790 and 329c12c.

Files selected for processing: 7

  • js/net/src/resume.test.ts
  • js/net/src/resume.ts
  • quest/m1/forgotten-skip-reask.md
  • quest/m1/js-kept-out-start-placement.md
  • quest/m1/resume-kept-out-reask.md
  • rs/moq-net/src/model/resume.rs
  • rs/moq-net/src/model/track.rs
Files with no reviewable changes: 1

  • quest/m1/resume-kept-out-reask.md

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

@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 blocking issues — one liveness edge worth a look inline.

Approach: sound. Asking the serving route again instead of keeping a growing skip history follows the cache rule, and keeping a single retained ask copy holds the bound under repeated window moves.

Reviewed changes

All 6 files at 0c61367, Rust and JS side by side.

  • Reader::accounts / #accounts asks upstream: it collects kept-out keys that neither the record nor a held copy declares skipped, then asks for their hull through the existing backfill dedup.
  • Reader::asking / #asking replaces the let-go merge: on every let-go, it rewrites skipped to the skipped prefix of each kept-out run and returns where the ask starts.
  • let_go / #letGo keeps one asked copy: this is the serving channel's copy reaching furthest past that key, so backfill's "a floor lowered again asks once" check holds the ask open without re-subscribing.
  • Copy::asked_for / copyAskedFor: a new predicate that both languages mirror.
  • Tests: the quest case, an inner-front ask, an asked-once/stays-owed case, and a window-moved-down bound, in both languages. The superseded inner-front test was removed.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread js/net/src/resume.ts Resolved
kixelated and others added 2 commits November 22, 2026 15:42
#9389 deletes resume-model-placement.md, so the note lives in
quest/m1/js-kept-out-start-placement.md instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pullfrog's finding on #9435: an interior skip split across the pool's
expiry window leaves a bounded read pending. One plain cursor fails the same way,
so it is the track's to fix, not the resumed reader's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Reviewed changes

Only quest planning notes changed since the prior pullfrog review; no runtime code.

  • Added forgotten-skip-reask.md: tracks the earlier expiry-window liveness edge as a follow-up quest.
  • Added js-kept-out-start-placement.md: moves the JS start-placement note into its own quest.

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

@kixelated
kixelated added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 7c77ec1 Nov 23, 2026
8 checks passed
@kixelated
kixelated deleted the quest/m1/resume-kept-out-reask branch November 23, 2026 04:50
kixelated added a commit that referenced this pull request Nov 23, 2026
Ports main's mid-group ends (#9402), answered joins past the end (#9311), the ietf
Oldest start (#9405), and the kept-out reask (#9435) onto per-range Live max ages.
Main's tests that leaned on a subscription-wide delay take a Live range now; two
that relied on a history range expiring let the replaced route fail instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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