Skip to content

fix(net): a superseded group reads as one over moq-transport too - #9808

Closed
kixelated wants to merge 9 commits into
mainfrom
quest/m2/typed-superseded-group-end
Closed

kixelated wants to merge 9 commits into
mainfrom
quest/m2/typed-superseded-group-end

Conversation

@kixelated

@kixelated kixelated commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes and deletes quest/m2/typed-superseded-group-end.md.

A group cut short because a newer one superseded it, such as one an on-demand track's dropped producer left open while a reader held it, now reaches readers as superseded on moq-lite and moq-transport alike, and the readers branch on a typed classification instead of matching Error::Old and StreamError::Old.

Over moq-transport the Rust publisher dropped that group's stream writer, which resets with CANCELLED. A subscriber reads a cancelled group as one to recover elsewhere, which on an on-demand track finds nothing, so libmoq's C raw reader with an unlimited delay.max ended the whole track with NotFound instead of reading on to the next producer's group (reproduced in raw_track_reads_past_a_group_a_drop_left_open before the fix). A moq-net reader holding the group waited on that recovery until the next producer arrived.

Changes

  • Error::superseded() (Rust) and Error.superseded(err) (JS): whether a group read failed because a newer group superseded the group, so the reader moves on rather than ending the track. True for Old, whether this reader's own budget, this side's track, or a reset said it. A publisher's explicit group abort, and its own timeout, are never superseded on either wire. Mirrors Error::retry / retry(err).
  • moq-transport wire: StreamError::Old encodes as DELIVERY_TIMEOUT (0x2) instead of INTERNAL_ERROR, and a received DELIVERY_TIMEOUT decodes as Old, in Rust and JS. A publisher's own timeout (StreamError::DeliveryTimeout, JS TimeoutError) now resets with INTERNAL_ERROR there, so from our peers that code only ever means superseded. The Rust GroupServe resets a superseded group's stream with it (stale while serving, stale after an unacknowledged FIN, or given up upstream) instead of dropping the writer as CANCELLED. Every other group failure still resets as before. A fetch recovering from a superseded subscription copy therefore still sees Old, as on moq-lite.
  • Readers: libmoq's raw and metadata readers, moq-ffi's ordered reader, the Rust and JS moq-json snapshot and window consumers, moq-hls's and moq-relay's fetch miss checks, and the moq-cli and stream-credit tests use the classification.
  • Docs: rs/moq-net/CHANGELOG.md gains the entries; libmoq's and moq-ffi's DELIVERY_TIMEOUT kind docs say it reports as OLD over moq-transport; doc/concept/standard.md lists the DELIVERY_TIMEOUT mapping among the moq-transport choices; doc/lib/rs/moq-net.md and doc/lib/js/net.md say how to read past a superseded group.

Impact

  • Public API: additive. Rust moq_net::Error::superseded(&self) -> bool; JS Error.superseded(err: unknown): boolean from @moq/net (API report updated). No migration.
  • Wire: moq-transport only, and compatible with every published version: a superseded group's stream resets with the registered DELIVERY_TIMEOUT instead of CANCELLED (Rust subgroup streams) or INTERNAL_ERROR (fetch streams, and JS). An older peer reads it as a delivery timeout, a group failure as before. A peer's DELIVERY_TIMEOUT now reads as Old here, so a relay carries it onto moq-lite as OLD. A publisher's own timeout resets a moq-transport stream with INTERNAL_ERROR instead of DELIVERY_TIMEOUT, so a reader may retry it once per route where it used to give up. During a rollout, an older relay fetching over moq-transport from a newer one reads a superseded fetch's DELIVERY_TIMEOUT as a terminal timeout rather than the retryable INTERNAL_ERROR it got before; relays link over moq-lite, so this needs a moq-transport relay hop. moq-lite is unchanged, so no lite draft changes; moq-transport has no draft of ours covering reset codes.
  • Behavior: a moq-transport reader now reads past a superseded group instead of failing on it or waiting on a recovery that cannot succeed, and moq-hls answers a group that aged out across a moq-transport hop as a cache miss (404), as it does across moq-lite.

Caused by

  • moq-dev/moq#9550 - ended the groups a dropped on-demand producer left open as Old and had libmoq and moq-ffi skip them by matching Error::Old | StreamError::Old, which never reaches a reader over moq-transport (found by person).

Decisions

  • Classify on the error, not a new read result. Error::superseded() beside Error::retry(), which a group read's Err answers wherever it came from.
    • Rejected: a typed read result (an enum in place of Option<Frame>). It breaks about 1,300 call sites of read_frame / poll_read_frame across the workspace for one more arm.
    • Rejected: group::Consumer::superseded(). libmoq's metadata reader reads meta::Group, and moq-ffi's ordered reader and the moq-json consumers see the error after the group is gone, so each would need its own accessor.
    • Rejected: ending a superseded group with Ok(None). A truncated group would read as whole to archives, HLS export, and relays.
  • DELIVERY_TIMEOUT carries superseded on moq-transport, decoded as Old at the wire. Its registry has no OLD, and a group given up for a newer one is late content its reader skips, which is what other moq-transport publishers say with it. Decoding it as Old (after review round 1) keeps superseded() to Old alone, so a moq-lite DELIVERY_TIMEOUT stays a failure and fetch recovery keeps its Old path.
    • Rejected: keep INTERNAL_ERROR. A reader cannot tell it from a failure.
    • Rejected: a code outside the registry. A peer reads it as INTERNAL_ERROR anyway.
    • Rejected: count DeliveryTimeout as superseded on every wire (round 1's version). It hid a moq-lite publisher's own timeout and skipped fetch recovery.
  • A publisher's own timeout resets with INTERNAL_ERROR on moq-transport (review round 2). One code cannot say both superseded and failed, and superseded is the one readers act on. Over moq-transport that timeout now reads as a retryable Internal (a cut, asked again once per route) instead of a terminal hole, as every unregistered condition already does there. Nothing outside tests aborts a group with Error::Timeout or a JS TimeoutError today (control timers send ControlTimeout), so this is the rule for a future one, not a change anyone sees now.
    • Rejected: decode DELIVERY_TIMEOUT as Old only on subgroup streams and keep it terminal on FETCH streams. A relay answering a fetch from a subscription copy that goes stale resets the fetch as Old (round 1's finding), which must recover; the recovery that Old buys is one fetch per route generation (rs/moq-net/src/model/resume.rs poll_serving), the same as INTERNAL_ERROR already got.
    • Rejected: keep DELIVERY_TIMEOUT for a publisher's own timeout too (round 2's version). Readers would skip a failed group as superseded.
    • Rejected: an unregistered code for a publisher's own timeout. It stays terminal between our peers, but other implementations read it as INTERNAL_ERROR anyway, and it adds a value the registry does not have.
  • Only a superseded group changes its moq-transport reset. Every other Rust group failure still drops the writer as CANCELLED, which a downstream subscriber recovers elsewhere. Resetting each with its own code, as JS and moq-lite do, would turn Evicted into a cut downstream, a behavior change with no reader asking for it.
  • No bindings classifier yet. moq_error_is_superseded beside moq_error_is_auth would reach py, swift, kt, go, dart and cpp, but no wrapper reads groups past a superseded one today: moq-ffi's ordered reader and libmoq already skip internally.

Waiting

  • Codex's open finding, "Keep publisher timeouts terminal after FETCH_OK" (rs/moq-net/src/ietf/error.rs:67). An application that calls Finished::abort(Error::Timeout) on a group after accepting a moq-transport FETCH now resets it with INTERNAL_ERROR, which the fetcher retries and, while the route may still move, waits on, where before it got a terminal DELIVERY_TIMEOUT. Nothing in the repository aborts a group with a timeout outside tests, and Finished::abort(Error::Cancel) already waits the same way on both wires. Two refutations did not settle it, so quest review stopped for your pick:
    • Accept (recommended). The case needs an application to choose Error::Timeout by hand, over moq-transport only, and gets the existing retryable-abort policy.
    • Fix per stream kind. Keep FETCH streams on the pre-PR mapping (Old as INTERNAL_ERROR, DELIVERY_TIMEOUT read as a terminal timeout) and use DELIVERY_TIMEOUT for superseded only on subgroup streams. Needs the uni stream's registry picked after its header in Rust and JS, for an abort nothing sends today.
    • Drop the PR. Leaves moq-transport readers failing on, or waiting for, a superseded group.

Overlap with #9719

moq-dev/moq#9719 (head 2646e0f7a2) merges with this branch without conflicts (git merge-tree). Its hunks in rs/moq-net/src/ietf/publisher.rs, rs/libmoq/src/consume.rs, rs/moq-ffi/src/consumer.rs, and the moq-json and moq-hls readers sit away from the lines changed here, and the new libmoq test builds its subscription from moq_subscription_defaults() so #9719 moving priority and order onto ranges does not break it.

Validation

  • quest gate just check: passed on the head.
  • quest gate just test interop --all: all checks passed.
  • rs/moq-net/tests/integration/superseded_group.rs: over moq-lite-03, 06, 07-wip and moq-transport-18, 22, 23, a remote reader holding a group an on-demand producer's drop left open reads it as superseded and then gets the next producer's group; a publisher's App(7) abort never reads as superseded. Before the publisher fix the moq-transport rounds never ended the held group.
  • rs/libmoq/src/test.rs raw_track_reads_past_a_group_a_drop_left_open: the C raw reader over a real QUIC session reads on to the next producer's group on moq-lite-06 and moq-transport-22. Without the publisher fix it fails on moq-transport-22 with -2.
  • coding::codes::a_superseded_group_reads_as_one_across_every_wire checks every negotiated version, including that a publisher's own timeout is never superseded on any wire; the JS error and stream tests mirror it, including a bare Reader.stop(StreamCode.DeliveryTimeout), which now goes through the same translation.

Models

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

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: 1a43453, named in full once no reviewer reports a finding

  • Base: origin/main at 0275260

  • Risk: high, It changes the wire on frozen moq-transport versions: a superseded group now resets with DELIVERY_TIMEOUT instead of INTERNAL_ERROR, and a received DELIVERY_TIMEOUT now reads as superseded instead of a failure, so deployed moq-transport peers and relays that send or read these codes see different behavior, and a revert cannot undo what peers have already received. Rust, JS, and Go consumers of moq-net and the bindings also see the changed `from_stream_code` mapping, though the additions (`Error::superseded`, `superseded()`) are additive.

  • Classified: high by Claude Code, claude-haiku-5-5, low effort, session 064cc9f7-0d30-4b7c-a672-f835e3cbf667

  • Risk file: bb7b1c0de60b

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

  • Session: 01a220b6-dfb7-77e1-a1c2-0ec3c279c9eb, round 3

  • Score: 6/10, The wire change needs rework because it turns an explicit publisher delivery timeout into a wait that can outlast the FETCH indefinitely.

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

  • Findings, open until the next round settles them:

    • Medium, rs/moq-net/src/ietf/error.rs:67: Keep publisher timeouts terminal after FETCH_OK
  • The last round's findings, at 1a43453:

    • Open: medium, rs/moq-net/src/ietf/error.rs:67: Keep publisher timeouts terminal after FETCH_OK; The cited retry branch already applied to CANCELLED, but this patch newly sends timeouts from the public Finished::abort API (rs/moq-net/src/model/group.rs:2843) into that branch (rs/moq-net/src/model/resume.rs:4652) by replacing terminal DELIVERY_TIMEOUT with retryable INTERNAL_ERROR.
  • Reviewer: Claude Code, claude-opus-5-5, high effort, second

  • Session: 4792011c-2e8d-4cad-a636-9bab62f702ca, round 2

  • Score: 9/10, Earlier finding 2 stays fixed: JS `toStreamCode` still sends a publisher's own timeout as INTERNAL_ERROR (js/net/src/error.ts:390), and Rust's path is unchanged. The changes since 4af6b014 only update docs and route JS `stopReason` through `toStreamCode`, which applies the same per-registry translation, so they cause no new problem.

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

  • Findings: none

kixelated and others added 5 commits November 27, 2026 16:27
A group given up for a newer one, such as one an on-demand track's dropped
producer left open, resets its moq-transport stream with DELIVERY_TIMEOUT
instead of CANCELLED, and Error::superseded (JS Error.superseded) says so on
either wire. libmoq's raw and meta readers, moq-ffi's ordered reader, and the
moq-json readers branch on it instead of matching Error::Old.

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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Typed superseded group end in moq-net fix(net): a superseded group reads as one over moq-transport too Nov 28, 2026
kixelated and others added 4 commits November 27, 2026 20:40
… timeouts failures

Review: a moq-lite DELIVERY_TIMEOUT is a publisher's own timeout, not a
superseded group, and a fetch recovering from a superseded copy expects OLD.
Decode the moq-transport code as OLD at the wire instead, so superseded()
means OLD alone. Mirrored in JS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A publisher's own timeout now resets a moq-transport stream with
INTERNAL_ERROR in Rust and JS, so a received DELIVERY_TIMEOUT from our
peers only ever means a newer group superseded this one. The moq-hls and
relay fetch miss checks and the stream-credit test use superseded(); the
changelog and binding docs note the mapping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reader.stop with a numeric code now goes through toStreamCode, so a bare
DELIVERY_TIMEOUT is not sent to a moq-transport peer that reads it as a
superseded group. The sharedStreamCode, DELIVERY_TIMEOUT constant and Go
wrapper docs say what that code carries there.

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

Copy link
Copy Markdown
Collaborator Author

Superseded by #9847: per the maintainer, a group's failure now stays with that group and readers continue past it, so superseded() and the moq-transport code remap are no longer needed.

(Written by Claude Opus 5.5)

@kixelated kixelated closed this Nov 28, 2026
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