Skip to content

fix(net): a pre-lite-07 tail owes nothing below SUBSCRIBE_START - #9536

Merged
moq-bot[bot] merged 1 commit into
mainfrom
fix/pre07-lowered-floor-tail
Nov 24, 2026
Merged

moq-bot[bot] merged 1 commit into
mainfrom
fix/pre07-lowered-floor-tail

Conversation

@kixelated

@kixelated kixelated commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Before lite-07 nothing answers a SUBSCRIBE_UPDATE, and a lite-05/06 publisher applies none once it has sent its FIN. A subscriber copy still owed the groups an update newly asked for below SUBSCRIBE_START. When a reader lowers the floor around the moment the publisher ends the track, the update reaches the publisher after its FIN, or is sent only after SUBSCRIBE_END arrived. The groups it asked for are then never sent or dropped.

The copy then holds its FIN for the tail grace, which is never under 1 s. The publisher's draining close waits for that FIN for at most 1 s, so Session::close fails with delivery timeout.

A relay hits this when a broadcast ends while a reader re-attaches from history. The route moves, the reader asks its copy from group 0 (Absolute(0)), and the copy sends that update right after SUBSCRIBE_END. Instrumented logs from a failing run:

SUB recv  End(SubscribeEnd { group: 10109 })
SUB buffer_update ranges=Replace([Range { start: Absolute(group 0) }])   <- after the END
PUB apply update serving=false                                           <- publisher already FIN'd: ignored
SUB recv  Ended  (FIN)
SUB tail poll owed=[0..10109]  ledger covers 10000..10109   ...  settles only at the 1 s grace

Approach

  • Rust (SubStream::owed): before lite-07 the owed groups never start below SUBSCRIBE_START. An update can still raise the floor, and a lowered group that arrives before the tail settles is still delivered. Lite-07 is unchanged, since it answers every range an update adds with its own SUBSCRIBE_START.
  • JS (Subscriber.#covered): the same rule, for parity.

The cost is that, before lite-07, a stream for a group a lowered floor asked for is no longer waited for if its header hasn't arrived by the FIN. A stream whose header has arrived is still read to its end. The publisher finishes every group stream before it FINs, so this window is only reordering in flight. Before lite-07 the subscriber can't tell that case apart from an update the publisher never read, and only lite-07's per-range SUBSCRIBE_START settles it exactly.

Impact

  • Public API: none.
  • Wire: none.
  • Behavior, lite-05/06 subscribers in Rust and JS: a tail no longer waits on groups below SUBSCRIBE_START that a floor-lowering update asked for.

Tests

  • New: a_floor_lowered_as_the_publisher_ends_owes_nothing_below_start (moq-net, lite-05 and lite-06). It uses the memory transport. The publisher answers SUBSCRIBE_START, a second reader lowers the floor, and the publisher sends END and FIN without applying the update. The copy must FIN with no time passing. On main it fails with no FIN.
  • Changed: the_owed_floor_follows_the_demand. A floor lowered below START now owes from START, and its disjoint-ranges case moved above START. The old assertion fails on main.
  • Changed: JS a lowered floor owes the groups it newly asked for keeps that name and assertion for lite-07. For lite-05/06 it becomes a lowered floor owes nothing below SUBSCRIBE_START and asserts that the subscriber FINs within 50 ms, under the 60 s grace. It fails on main for both versions.

Validation

  • nix develop --command just ci origin/main passes: Rust 11428 tests passed and 146 skipped, plus the JS suites.
  • The real surface: a Python application test drives two moq-ffi clients through an in-process moq-ffi server over QUIC/WebTransport, negotiating moq-lite-06. One client publishes audio and a catalog, then finishes them and closes the session cleanly, while the other client's reader re-attaches. The moq-ffi wheel was built with maturin build --release.
    • Upstream main (d791d549a6, this branch's base): 8 of 20 runs failed, all with MoqError.Protocol: delivery timeout from the clean close. A separate run with debug logs failed 4 of 10.
    • This branch: 30 of 30 runs passed.
  • Second check: temporary tracing instrumentation, not committed, logged the copy's owed set and tail ledger in failing runs on main. owed=[0..10109] against a ledger covering 10000..10109, with the update buffered after SUBSCRIBE_END. That confirmed the mechanism above before the fix was written.

Caused by

  • moq-dev/moq#4533: made the owed floor follow a lowered update before lite-07, which assumes the publisher read the update before its FIN (found by a downstream application test).
  • moq-dev/moq#9409 made it reachable here: since then, a reader re-attaching after the route moves asks its copy for a lowered floor as the track ends. The application test passed 25 of 25 just before it, at f1871e210a.

Alternatives

  • Send no SUBSCRIBE_UPDATE once SUBSCRIBE_END arrived before lite-07. Rejected: it misses an update that crosses the END, which the publisher reads only after its FIN.
  • Owe a lowered floor only once a drop or stream below START shows that the publisher applied it. Rejected: SUBSCRIBE_DROPs for holes skipped before the start can land below START without the update, and streams in flight show nothing yet.
  • Lengthen the drain deadline or shorten the grace. Rejected: the grace would still settle groups that nobody sends.

Decisions

  • Decided 2026-11-24 (agent, maintainer away; /quest-afk): ✅ before lite-07, owe nothing below SUBSCRIBE_START, which narrows fix(net): track tail hardening #4533's lowered-floor rule (rejected: keep owing lowered floors and stop sending updates after SUBSCRIBE_END).
  • Decided 2026-11-24 (agent, maintainer away; /quest-afk): ✅ change JS in the same PR (rejected: Rust only, leaving the implementations disagreeing on when a tail settles).
  • Decided 2026-11-24 (agent, maintainer away; /quest-afk): ✅ test at the subscriber state machine over the memory transport, the lowest layer that fails on main (rejected: a real-QUIC moq-net or relay test; once the trigger is known, the fault doesn't depend on the transport).

Follow-ups

  • When a reader lowers the floor this way, the copy's start_at also reopens the groups below START for its readers. In the unit harness, a live reader on the finished copy then did not end at once. It no longer delays the FIN, but readers may still wait out their own grace. Possible quest: the same acknowledged-floor rule for reader declarations before lite-07.

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: e7c0438

  • Base: origin/main at d791d54

  • Risk: medium, If the `owed()` change in `js/net` and `rs/moq-net` is wrong, a pre-lite-07 subscriber could hold or close a track's subscription incorrectly for publishers and relays that use it, but the fix keeps the public API and wire format and a revert undoes it fully, so this is a bug fix in shipped code, which is medium rather than high.

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session 561b6f02-5038-4e30-9c9d-8cf1ef65cefa

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

  • Session: 01a20d8b-c397-7bf2-a9af-fecc587ef1e9, round 1

  • Score: 9/10, The change consistently clamps pre-lite-07 tail obligations to SUBSCRIBE_START across Rust and JS with no actionable regression found, though builds and tests were not run as instructed.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

  • Reviewer: Codex, gpt-6.1-sol, high effort, shadow

  • Session: 01a20d8b-c397-7132-9a20-026c82453214, round 1

  • Score: 9/10, The Rust and JavaScript tail-accounting changes are consistent with no actionable regressions found, pending automated validation because the review was static.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

Before lite-07 nothing answers a SUBSCRIBE_UPDATE, and the publisher
applies none once it has sent its FIN. A floor an update lowered below
SUBSCRIBE_START as the track ended was still owed, so the subscriber held
its FIN for the tail grace, and the publisher's draining close timed out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 24, 2026 12:34
@kixelated
kixelated enabled auto-merge November 24, 2026 12:35
@pullfrog

pullfrog Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

No configured credential can serve this run. Your Claude subscription has hit its usage limit, which resets at 2026-11-25 06:00 UTC. Re-trigger after it resets, or add an API key for this provider, which Pullfrog falls back to automatically.

The providers' responses
CLAUDE_CODE_OAUTH_TOKEN: 429: This request would exceed your account's rate limit. Please try again later.

Pick another model →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using claude-opus-5-5

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The JS and Rust Lite subscribers now prevent a lowered requested floor from making groups below the answered SUBSCRIBE_START owed when the version lacks per-range starts. Versions with per-range starts retain their independently reported starts. Tests cover owed ranges and stream completion, including FIN behavior without waiting for the grace period.

Merge Risk: Minimal · up to e7c04

This change stops Lite05/06 subscribers from owing groups below the answered SUBSCRIBE_START after a floor-lowering update. That avoids the delivery timeout the publisher's draining close could report. Lite-07 behavior is unchanged, and no concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: before lite-07, a tail owes nothing below SUBSCRIBE_START. It matches the Rust and JS owed-floor changes in the summary and objectives. It is specific and uses the sam…
Description check Passed The description explains the problem (a lowered floor makes the subscriber copy owe groups below SUBSCRIBE_START after the publisher sends FIN), the Rust and JS approach, the tests, validation, relate…
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 change: before lite-07, a tail owes nothing below SUBSCRIBE_START. It matches the Rust and JS owed-floor changes in the summary and objectives. It is specific and uses the same terms as the code.

Full details: Description check

Explanation

The description explains the problem (a lowered floor makes the subscriber copy owe groups below SUBSCRIBE_START after the publisher sends FIN), the Rust and JS approach, the tests, validation, related PRs, and alternatives. It matches the changeset and objectives closely.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • 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: 6faf8e29-0f6a-44b2-8bd1-36def3db50a2
Commits

Reviewing files that changed from the base of the PR and between d791d54 and e7c0438.

Files selected for processing: 3

  • js/net/src/lite/subscriber.ts
  • js/net/src/lite/tail.test.ts
  • rs/moq-net/src/lite/subscriber.rs

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

@moq-bot
moq-bot Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 6847598 Nov 24, 2026
6 of 7 checks passed
@moq-bot
moq-bot Bot deleted the fix/pre07-lowered-floor-tail branch November 24, 2026 17:12
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