Skip to content

fix(net): lite-07 fetches come back whole under load - #9768

Merged
kixelated merged 6 commits into
mainfrom
quest/m0/test-flakes-5/stream-credit-fetch-under-load
Nov 27, 2026
Merged

kixelated merged 6 commits into
mainfrom
quest/m0/test-flakes-5/stream-credit-fetch-under-load

Conversation

@kixelated

@kixelated kixelated commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/test-flakes-5/stream-credit-fetch-under-load.md (deleted here, goal met).

Summary

Under load, just test stream-credit --version moq-lite-07-wip got empty fetches from three causes. All three are fixed here, without loosening the fetch check:

  • The relay answered a fetch with OLD from its own cache (correctness). The relay's copy of a track has an upstream subscription that asked for a live-edge budget. Under that budget the publisher reset the copy's group stream as too old, then dropped the group (SUBSCRIBE_DROP(OLD)). Recover treated both the reset (undelivered) and the drop it recorded (poll_serving) as a final answer. So a one-shot fetch, which has no budget at all, got OLD even though upstream would still have sent it the group. That broke the cache rule in AGENTS.md.
    • The fix: the copy records judging, the narrowest budget any of its upstream subscriptions asked. It is set before the request reaches the wire (track::Producer::judge_under, set on SUBSCRIBE, on pipelined accepts, and on every update).
    • A copy's too-old reset or drop now ends a reader's group only when track::settles says the reader is no wider than that budget. This is the same rule stale drops already follow on the track.
    • A wider reader, such as a fetch or a reader with a longer budget, asks the route for the group under its own terms instead. JS mirrors this through hooks.judgeUnder / hooks.judgedUnder and Recover.#outgrows.
  • The relay preempted the fetch's own stream. On lite-07, a fetch is a one-shot SUBSCRIBE whose group stream competes for the same browser stream cap. So the relay may reset it with TOO_FAR_BEHIND. The draft says a subscriber that still wants a preempted group asks again, so the tab now fetches again on TOO_FAR_BEHIND, as the quest recommends.
  • Looking past a verdict is bounded. A group read after the reader looked past a copy's too-old verdict, or one delivered by the reader's own fetch, stands on its own OLD (Recover::judged in Rust, #judged in JS). So a route gets at most one more request per group.
  • Firefox drops the reset code. If a fetch's group stream is reset before the page reads it, Firefox reports a bare TypeError: Error in input stream. The tab then can't tell that the group was preempted. Now, when a lite-07 fetch's group stream fails without a code, @moq/net waits for the subscription to end and fails the group with the reason the publisher's drop names (FetchTarget.lost in js/net/src/lite/subscriber.ts). A matching drop also ends a fetch stream that is still open, which covers a reset Chromium lost. A stream that arrives after its drop is refused (FetchTarget.dropped), and a group received whole stays whole.

Modeled first with the verify-resume skill. rs/moq-net/verify/recover/StaleRecover.tla models one group read from a copy whose upstream budget retunes over time while the publisher judges the group under any budget asked so far.

  • The code's rule (Rule = "wider", Recorded = "narrowest") passes AnswersAsUpstream (a read ends OLD only when the reader's own request would) and AsksOnlyWhenWider.
  • Rule = "stand" (the old behavior) fails AnswersAsUpstream.
  • Rule = "ask" fails AsksOnlyWhenWider.
  • Recording under the current budget instead of the narrowest fails AnswersAsUpstream.

Impact

  • Public API: none.
  • Wire: none. The lite-07 draft is unchanged.
  • Behavior:
    • A relay asks upstream for a group its copy reset or dropped as too old whenever a reader is wider than the copy's narrowest asked budget. Before, it ended that reader's group with OLD.
    • A live-edge reader still takes the verdict without asking.
    • A @moq/net lite-07 fetch whose stream reset lost its code ends with the code from the drop.

Validation

  • Failing first, mocked time:
    • Rust: a_copys_stale_reset_stands_only_for_a_reader_no_wider covers bounded, longer, and live-edge readers, each with and without the recorded drop. a_copy_records_the_narrowest_budget_its_upstream_may_judge_under checks that SUBSCRIBE and updates are recorded before the wire.
    • Rust: a_fetched_groups_stale_reset_stands and a_group_fetched_from_another_route_stands_on_its_stale_reset check the one-request bound.
    • JS: the matching resume.test.ts cases, "a fetched group's stale reset stands", the extended lite-07 stale-budget test, and "a fetch whose reset lost its code ends with the reason its drop names". That last test covers the drop arriving before the reset, after it, with no reset at all, and before the group header.
    • Each failed without its fix.
  • quest gate just check passes on 336a7f6691. It ran 11,801 Rust tests plus the JS suites.
  • quest gate just rs tla moq-net/verify/recover/StaleRecover.tla passes.
  • just test stream-credit --version moq-lite-07-wip on a 32-core host at load 23 to 33:
    • main before: Chromium had 50 failing fetches (TOO_FAR_BEHIND). Firefox had 5 (OLD).
    • Diagnostic runs with temporary branch logs in Recover traced the remaining OLD fetches to poll_serving's drop verdict, and the TypeError fetches to Firefox resets that lost their code.
    • After: 5 full runs (10 cells) had no fetch failures. 4 runs passed both engines.
    • The one remaining failure was the high tier missing groups in one Firefox cell. The relay log shows the publisher's 200 ms groups arriving up to 1.07 s apart, past the tier's 500 ms budget. That comes from host load, not a fetch (see Follow-ups).
  • just test interop --all: not run. There is no wire, moq-ffi, or gateway change.

Decisions

  • The two open round-3 review findings are accepted (maintainer, 2026-11-27): ✅ accept them and land this PR (rejected: fix them here with per-group provenance in the track cache; drop the PR). Both need a group to switch routes partway between copies whose upstreams both asked a narrower budget than the reader:

    1. A recovery started from a non-OLD failure (such as CANCEL) can adopt its own fetch's answer through the copy's cache unmarked, so if that group later resets OLD the route gets one more request.
    2. A group adopted from a second route's live subscription, after looking past the first route's OLD, is marked judged, so if that live subscription later resets it OLD under a narrower budget the read ends instead of fetching.

    The fix, recording on the copy which request delivered each group, belongs in rs/moq-net/src/model/track.rs, which moq-dev/moq#9719 is rewriting. It is the new follow-up quest/m3/recover-group-provenance.md, which requires feat(net)!: per-range priority, order, and judged OLD drops on lite-07 #9719's per-range-policy quest. It sits in m3 because a quest cannot require one in a later milestone, and per-range-policy is in m2.

Taken while the user was away, each on my recommendation:

  • The tab matches TOO_FAR_BEHIND to fetch again. AGENTS.md says never match on errors. The quest recommended this for the test page anyway, since it is the draft's recovery for a preempted group. Moving that retry into the reader itself, for any drop code, is quest/m3/fetch-preempted-group.md.
  • A copy records the narrowest budget ever asked, not a per-group one. This can ask upstream for a group that the drop's own recorded budget would have settled. That costs a request, never a wrong answer. Once moq-dev/moq#9719 puts the judged Max Age on SUBSCRIBE_DROP(OLD), drops can use it. Resets still need judging.
  • A codeless fetch failure waits for the subscription's end rather than failing at once. The publisher FINs a one-shot right after its drop, so the wait is one control message.

Caused by

No single PR. Recover's verdict paths predate the per-budget stale drops of moq-dev/moq#8908, and no change since taught them that rule. The preemption and Firefox causes come from lite-07 one-shot fetches sharing the stream cap.

Follow-ups

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, unknown (arm A)
Implementer: Claude Code, claude-opus-5-5, unknown (iterate, M, arm A)

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 120add9

  • Base: origin/main at fcfa5b1

  • Risk: medium, A mistake could make relay readers and JS subscribers either end groups too old that upstream still sends, or re-ask routes more than they should, in shipped fetch and resume code; it keeps the public API and wire format, and a revert undoes it cleanly, so it is medium rather than high.

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session a2848117-d78e-46c2-b615-ac9796f76523

  • Risk file: bb7b1c0de60b

  • Accepted by the maintainer: Maintainer accepted both open mid-group route-switch findings on 2026-11-27 and chose to land this PR; the fix (per-group delivery provenance on the relay copy) is follow-up quest quest/m3/recover-group-provenance.md, which waits on moq-dev/moq#9719 rewriting rs/moq-net/src/model/track.rs.

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

  • Session: 01a21dfb-f323-7310-8978-cab064fadf4e, round 4

  • Score: 7/10, The maintainer approved landing with both cross-route recovery defects deferred, and the new commit records that decision without changing either code path.

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

  • Findings, accepted by the maintainer:

    • Medium, rs/moq-net/src/model/resume.rs:4231: Preserve recovery fetch provenance through the cache
    • Medium, rs/moq-net/src/model/resume.rs:4377: Keep one route’s OLD verdict from settling another route’s live delivery
  • The last round's findings, at 336a7f6:

    • Open: medium, rs/moq-net/src/model/resume.rs:4231: Preserve recovery fetch provenance through the cache; `quest/m3/recover-group-provenance.md:7` and `:14` record the maintainer’s decision to defer the fix, while the cache path still loses fetch provenance.
    • Open: medium, rs/moq-net/src/model/resume.rs:4377: Keep one route’s OLD verdict from settling another route’s live delivery; `quest/m3/recover-group-provenance.md:8` and `:14` record the maintainer’s decision to defer the fix, while adoption still carries the first route’s judgment onto the second route’s live delivery.

kixelated and others added 3 commits November 27, 2026 05:05
…its upstream judged

WIP checkpoint: Rust side and the StaleRecover model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A copy's too-old drop, not only its reset, stands only for a reader no wider
than the budget its upstream asked, in Rust and JS, so a relay serving a
one-shot fetch asks upstream instead of answering OLD from its own copy.

JS mirrors the copy's judging budget, and a lite-07 fetch whose group stream
reset lost its code (Firefox) ends with the reason the drop names. The
stream-credit tab fetches again after TOO_FAR_BEHIND, as the draft says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Stream credit's lite-07 fetches come back whole under load fix(net): lite-07 fetches come back whole under load Nov 27, 2026
kixelated and others added 2 commits November 27, 2026 09:53
…tands

A lite-07 fetch whose group the publisher drops ends with the drop's reason
at once, so a reset Chromium lost no longer holds it open. A group the
reader's own fetch delivered that then fails too old ends the read in JS
instead of asking the route again; Rust already does, now pinned by a test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A group read after looking past a copy's too-old verdict, or delivered by
the reader's own fetch, stands on its own OLD, in Rust and JS, so a route
gets at most one more request per group, across route switches too. A
lite-07 fetch whose drop overtook its group header no longer takes that
stream, whose reset Chromium may lose.

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

Follow-up to the two accepted review findings on mid-group route switches,
waiting on per-range-policy (#9719), which rewrites the relay copy.

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

coderabbitai Bot commented Nov 27, 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 8 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: 21781ce4-b43a-4b54-b757-385e8a903a95
Commits

Reviewing files that changed from the base of the PR and between 541c083 and 120add9.

Files selected for processing: 16

  • .claude/skills/verify-resume/SKILL.md
  • js/net/src/internal.ts
  • js/net/src/lite/subscriber.test.ts
  • js/net/src/lite/subscriber.ts
  • js/net/src/resume.test.ts
  • js/net/src/resume.ts
  • js/net/src/track.ts
  • quest/m0/test-flakes-5/stream-credit-fetch-under-load.md
  • quest/m3/recover-group-provenance.md
  • rs/moq-net/src/lite/subscriber.rs
  • rs/moq-net/src/model/resume.rs
  • rs/moq-net/src/model/track.rs
  • rs/moq-net/verify/recover/StaleRecover.cfg
  • rs/moq-net/verify/recover/StaleRecover.tla
  • test/stream-credit/README.md
  • test/stream-credit/src/main.ts
  • 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 added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit 54d3f18 Nov 27, 2026
8 checks passed
@kixelated
kixelated deleted the quest/m0/test-flakes-5/stream-credit-fetch-under-load branch November 27, 2026 20:35
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