Skip to content

feat(net)!: a live join is a range's Live start, asked upstream per join - #9316

Merged
kixelated merged 34 commits into
mainfrom
quest/m1/time-start-asks-upstream
Nov 22, 2026
Merged

kixelated merged 34 commits into
mainfrom
quest/m1/time-start-asks-upstream

Conversation

@kixelated

@kixelated kixelated commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

A lite-07 live join is now its own range start, Live(min_age), so a relay copy asks upstream for each reader's join exactly and takes that range's answer, with no inference.

Maintainer decision (comment), recorded here because this PR completes and deletes the quest: Decided 2026-11-21 (maintainer, /quest-complete): a new lite-07 Start variant Live(min_age) joins at the Group holding the live edge minus min_age. It replaces Start None plus the subscription-level Subscriber Min Age, which SUBSCRIBE and SUBSCRIBE_UPDATE no longer carry. A Start of None now only reaches back as far as Subscriber Max Age allows. This is lite-07-wip only: lite-05/06 and moq-transport keep their encodings, and moq-net maps to them. Multiple Ranges per subscription stay. Rejected: a per-range Min Age field beside Start, keeping the subscription Min Age with an edge probe, and keeping the inference.

Changes

  • Wire (lite-07-wip)
    • New Live anchor 0x3, a start only, carrying Min Age in milliseconds rounded up.
    • Subscriber Min Age is removed from SUBSCRIBE and SUBSCRIBE_UPDATE.
    • The draft and its changelog are updated, as is doc/concept/moq-lite.md.
  • Model
    • track::Start is Oldest | Time(u64) | Live(Duration), and track::Delay keeps only max.
    • A Live range is placed on its own, so one subscription can join at several lags.
    • The demand unions Live ranges by value.
  • Relay copy (lite-07)
    • It forwards each reader's live join as a Live(min)..end range and places that reader's join only from an answer to the same (min, end).
    • The answer must be recorded after the reader added its range, under a budget at least as wide as the reader's.
    • Readers joining alike share one answer. A later joiner asks again, because the live edge has moved.
    • JoinStart, its Past bound and feed_start (js/net #joinFed) are removed.
  • Copies on other wires
    • lite-05/06 and moq-transport copies can't carry the join, so they place it from the groups they hold as before, minus the feed-start inference.
    • Once a copy's end is declared, it does the same. Once that end settles (every group below it arrived or was given up) or the copy is final, a join its held groups can't prove resolves as a time start from the final edge, which reads from there and asks its upstream, since no group or answer will arrive to place it.
  • Join ticks
    • Answers are ordered by one process-wide join tick.
    • A front stamps each copy it subscribes with the tick at which its reader added the range. A copy subscribed after its upstream already answered still places the join that asked.
  • Publisher
    • A live join added by SUBSCRIBE_UPDATE behind where delivery started reports its own start in SUBSCRIBE_STARTED and lowers the delivery start.
    • Other added ranges, such as fills, still start no earlier than delivery.
  • Downstream
    • moq-mux owns the media playout delay as moq_mux::container::Delay { min, max }. Delay::subscription turns Oldest ranges into Live(min) when a min is stated.
    • moq-ffi and libmoq keep MoqDelay.min and map it the same way, so the binding API is unchanged.
    • js/net, js/hang, js/watch, js/publish and js/json mirror the Rust changes with the same names.

Impact

Breaking public API (Rust moq-net, moq-mux, JS @moq/net, @moq/hang) and the lite-07-wip wire.

Migration:

  • Rust moq-net
    • track::Range::start is a track::Start, no longer an Option<u64>: None becomes Start::Oldest, and Some(t) becomes Start::Time(t).
    • A live join is Range::from(Start::Live(lag)). Previously it was a range with no start plus Delay::min.
    • Delay::min / with_min are gone. Put the lag on the range instead.
  • Rust media (moq-mux, moq-audio, moq-video)
    • Use moq_mux::container::Delay (re-exported as decode::Delay), which keeps min and max.
    • Delay::subscription(sub) applies it to a subscription.
  • JS @moq/net
    • A range's start (Track.Start) is a time (bigint), { live: Duration } for a live join, or absent for the oldest group.
    • Delay.min is gone. A JSON-encoded start uses {live: number}.
  • JS @moq/hang
    • Container.Delay carries the media min and max. Container.subscribed builds the subscription.
  • Bindings (C, C++, Go, Python, Swift, Kotlin)
    • No change: MoqDelay.min still joins that far behind the live edge.

Decisions

These are my calls; a review can undo any of them:

  • Bindings keep the MoqDelay.min convenience. It maps onto Oldest ranges as Live(min) rather than exposing a per-range start type. This keeps the binding API stable until a binding user needs several lags.
  • Only lite-07 copies answer joins. IETF and lite-06 copies can't carry a Live start, so they keep measuring joins from held groups (minus the old feed-start inference). Making them wait would hang them.
  • A reader takes only answers recorded after it added its range. That point is stamped at registration, with a process-wide tick, and carried by a front to the copies it reads. A later joiner asks again, since the edge moved.
  • A copy whose end is declared measures locally. Its session won't ask a join again. Once the end settles, a join its held groups can't prove goes through the time-start rule (prove or ask upstream) instead of waiting forever. Before then it waits, since trailing groups can still move the edge.
  • A lite-07 update below the delivery start lowers it. Rust and JS, as on main: the cursor floor drops, so the groups below are served and an added range reports its own start (refuted CodeRabbit r4656268821).
  • The moq-transport publisher keeps measuring a join from what's held. It answers SUBSCRIBE_OK with no upstream answer to wait on, per the settled decision for old wires (refuted CodeRabbit r4656193903).
  • Demand union order. Time ranges come first, then the others (Live and bounded Oldest), each kept by value.
  • Range-table warm check. An empty warm delivery counts as answered by the copy alone only if the read ended.
  • moq-transport filter for a join. wire_bounds treats any non-empty range other than Oldest as asking a join.
  • JS hang. It exposes Container.Delay and Container.subscribed for the media min, mirroring moq-mux.
  • SUBSCRIBE_STARTED for a deeper live join. It reports the join's own start and lowers the delivery start. It isn't clamped to the subscription's first start, because the subscriber reads it as the join's placement.
  • A media reader's adaptive delay moves only the max. js/watch and moq-mux Consumer::set_delay keep the ranges first subscribed. A changed min would otherwise place the live join again and skip buffered media.

Validation

  • cargo nextest run --workspace --all-features: 13195 passed, after merging main.
  • After the review fixes: cargo nextest run -p moq-net --all-features 4220 passed, js/net 3594 passed, just check passed.
  • The settled-end tests deliver nothing forever without the fallback. With it, the Rust test (producer held, gaps given up by the tail grace) delivers group 6000 from the final edge, and the JS test delivers group 3000. A JS test checks that an unsettled end still waits.
  • JS judges the settled end directly (#settled(), lazily, only in the fallback), not by the outcome latch: js/net 3595 passed, just check passed.
  • One just check run timed out 4 moq-hls export::tests at 60s. They passed alone in 0.25s, and a full just check rerun passed, so I couldn't reproduce it.
  • js/net: 3593 passed, including all 85 range-table cases. Every other JS package passes.
  • just test interop --all: all checks passed.

Follow-ups

  • None owned by this quest.

Models

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

(Written by Claude Opus 5.5 with high)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 47af657

  • Base: origin/main at ca42dc4

  • Risk: high, The change rewrites shipped moq-net and js/net internals and changes the public API surface (js/net/api/index.api.md and js/hang/api/container.api.md are updated, and the lite version modules rs/moq-net/src/lite/version.rs and js/net/src/lite/version.ts are deleted), so a published Rust or JS consumer or a deployed peer speaking the lite wire protocol could break, and reverting it would mean redoing a large multi-package change.

  • Classified: high by Claude Code, claude-haiku-5-5, low effort, session 17dffd25-13a3-449d-8054-5869cf9fd56a

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

  • Session: 01a200d3-c0bd-71b1-84aa-c712ace76bc2, round 9

  • Score: 10/10, Source review found no new issues in the merge resolutions for batched join answers and probe accounting; builds and tests were not run.

  • Rounds: 14; first round 2 (medium 2); findings 8 (high 2, medium 6): fixed 8, refuted 0, open 0

  • Findings: none

kixelated and others added 17 commits November 21, 2026 14:47
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
moq-net moved a live join's lag from Delay::min into Range::start
(Start::Live). moq-mux gains container::Delay { min, max } as the media
playout delay; Delay::subscription and Playout::subscription turn each
Start::Oldest range into Start::Live(min) when min is stated. moq-audio
and moq-video re-export it as decode::Delay. Exporters take it.

moq-ffi and libmoq keep MoqDelay/moq_delay and MoqRange/moq_range,
mapping delay.min onto each range with no start at the conversion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mirrors the Rust moq-net change into js/net and its users.

- Track.Range takes `start?: Start`, where `Start = bigint | { live: Duration }`; the lag rounds
  up to whole milliseconds. Track.Delay keeps only `max`.
- lite-07 carries a live start as Anchor type 3 (milliseconds, start only); SUBSCRIBE and
  SUBSCRIBE_UPDATE drop Subscriber Min Age.
- A received lite-07 copy places a live join only from its upstream's answer to that (lag, end),
  recorded after the reader began waiting and under a budget at least as wide. Readers asking the
  same join share one pending range; the session forwards each as its own Live range.
- @moq/hang adds its own playout `Container.Delay { min, max }` and `Container.subscribed()`,
  which turns each range from the oldest group into a live join `min` back. watch, json and
  publish build their subscriptions through it or directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A replaced range resolves again, so rewriting a live join's lag from
set_delay re-placed a start the reader had already subscribed. The old
Delay::min update never moved a resolved range either.

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

A lite-07 copy places a reader's Live(min) range only from its upstream's
answer recorded since the range was added; IETF and lite-06 copies measure
joins locally. A range an update adds below where delivery started lowers
the start it reports from, so a deeper live join is not clamped to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…heir range was added

Mirrors the Rust follow-up:

- joinsLive is back to an open range with no time start, so a default subscribe asks for a
  refresh again; the refresh tests subscribe plainly as before.
- A copy places a live join only from its upstream's answer when its session marks it
  (`hooks.answersJoins`, lite-07 ranges). Another wire copy (lite-06, IETF) measures the join
  from the groups it holds as before, minus where the feed starts.
- The join tick lives in the demand (`Subscriptions.joinTick`, bumped by `answered`). Prefs
  record it per live join range when the range is added, and the window takes each range's
  `since` from there; the front's preview takes the current tick.
- The range table counts an empty warm delivery as answered alone only if the read ended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t added the range

The join tick is counted process-wide, and a front stamps each copy it asks
with the tick its reader added the range at, so a copy subscribed after its
upstream answered still places the join that asked.

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

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

Another added range, such as a fill, still starts no earlier than delivery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lite-07 draft adds the Live start anchor (0x3) carrying Min Age, drops
Subscriber Min Age from SUBSCRIBE and SUBSCRIBE_UPDATE, and states how a relay
copy places each join from its upstream's answer. The quest is complete.

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

Mirrors cb8b20a. The join tick is counted process-wide (`joinTick` and `answered` in
demand.ts), so a front's reader and the copies it reads compare ticks. A front stamps each copy
it asks with the tick its reader added each live range at (`Prefs.stamp`, through
`hooks.stampSubscriber`), on a new copy and on each update, so a copy subscribed after its
upstream answered still places the join from that answer instead of asking again. A stamp
places again only joins still waiting; one already placed stays where it started.

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 relay copy asks upstream for every live join it cannot prove feat(net)!: a live join is a range's Live start, asked upstream per join Nov 22, 2026
kixelated and others added 2 commits November 21, 2026 17:42
…stop asking once ended

- A reader asking one join with several ranges counts it once in the demand,
  so retiring the ranges leaves nothing asked (Rust and JS).
- A front notes its reader's tick on a ready copy before the copy's window
  places the edit, so an answer recorded since still places it.
- A JS copy whose end is declared places a live join from its groups, as Rust.
- js/watch keeps the ranges it first subscribed and updates only the max delay,
  so an adaptive min never places the join again.

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

# Conflicts:
#	rs/moq-cli/src/play/media.rs
@kixelated
kixelated marked this pull request as ready for review November 22, 2026 02:05
@kixelated

Copy link
Copy Markdown
Collaborator Author

Maintainer decision (2026-11-21):

  • Merge: /quest-merge.
  • Old wires: only lite-07 copies wait for an upstream answer to a live join; lite-06 and moq-transport copies keep placing joins from the groups they hold. Keep.
  • Bindings: keep MoqDelay { min, max } as it is. The follow-up below gives it a one-to-one mapping.
  • Follow-up, planned as its own m1 quest and not part of this PR: Max Age moves into the Live anchor as Live(min, max).
    • max is a per-range staleness budget measured from the live edge.
    • Time, Position, and Oldest/None ranges are floors for history and never expire for staleness. Retention stays bounded by Publisher Max Age.
    • The subscription-level Subscriber Max Age is removed, and so is FETCH's.
    • A group covered by several ranges takes the largest budget among them, and unlimited if any non-Live range covers it.
    • SUBSCRIBE_UPDATE gains a way to change a Live range's max in place without re-joining.
    • Rejected: keeping one subscription Max Age that applies only to Live ranges, and leaving it as is.

(Written by Claude Opus 5.5)

@kixelated

Copy link
Copy Markdown
Collaborator Author

Answers the maintainer decision: this PR lands as is. The Max Age follow-up is planned as its own quest.

(Written by Claude Opus 5.5)

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

Important

A lite-07 relay copy can leave a reader's live join waiting with no ask in flight. Separately, a binding update that changes delay.min now places the join again. Details are inline.

Approach: Sound. Making a live join its own Start::Live range lets a relay copy ask upstream for each join exactly, and it deletes the feed_start inference that kept losing information. It implements the maintainer's recorded decision, and lite-07 stays -wip and off by default (rs/moq-net/src/version.rs:271), so changing the wire is fine.

Reviewed changes

I reviewed the full diff at 1143197. Separate passes covered relay join placement, Rust/JS parity, and downstream media-delay users.

  • Wire (lite-07-wip): a new Live anchor 0x3 carries the lag in milliseconds, rounded up. It is a start only and is refused as an end. Subscriber Min Age is removed. Older wires send a Live start as no start.
  • Model: Range::start is now Start { Oldest, Time, Live }, and Delay keeps only max. The demand keeps each Live range by its value. Fit/collapse merges Live ranges into Live(max).
  • Relay copy: a reader's join is placed only from join_answers[(min, end)], using an answer whose tick is newer than the reader's since and whose budget is at least as wide. join_probes asks for joins that no live range answers. A front stamps its copies with the reader's tick.
  • Publisher: an added live join reports its own start, even below where delivery started, and lowers the delivery start.
  • Downstream: moq_mux::container::Delay { min, max } and Delay::subscription turn Oldest ranges into Live(min). moq-ffi and libmoq keep MoqDelay.min. js/hang, js/watch, js/publish and js/json mirror this.

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

Comment thread rs/moq-net/src/lite/subscriber.rs Resolved
Comment thread rs/libmoq/src/consume.rs Resolved
Comment thread js/net/src/lite/publisher.ts Resolved
Comment thread js/hang/src/container/consumer.ts Resolved
@moq-bot
moq-bot Bot disabled auto-merge November 22, 2026 02:13
@moq-bot

moq-bot Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

quest land watch: ended this pull request's pick, disarming its auto-merge, since its head 1143197 is held by finding by pullfrog[bot]: ⚠️ A reader's join can be left with no ask in flight. demand_answers counts a live demand range that is still unanswer (#9316 (comment)); finding by pullfrog[bot]: ⚠️ delay.min is now baked into each range as Start::Live(min), so an update that changes min changes the ranges. (https://github.com/moq-dev/moq/pull/9316#discussion_r4656161964); finding by pullfrog[bot]: JS lowersstartKeyinside the loop, so a range reported later in the same batch is clamped against the already-lowered (https://github.com/moq-dev/moq/pull/9316#discussion_r4656161968); finding by pullfrog[bot]: Nit: the Rust counterpart is the methodmoq_mux::container::Delay::subscription(andPlayout::subscription`), but her (#9316 (comment)). Push a fix, or answer each by a thread reply or a comment linking its review or decision, then land it again.

(written by quest land watch)

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 22, 2026
@moq-bot

moq-bot Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

quest land watch: the merge queue removed this pull request at 0820109 because it conflicts with main (merge_conflict).

The land fixer works on it in the background, and the watcher re-enqueues it at the back of the queue once it is fixed or judged flaky, or hands it back here with what it needs.

(written by quest land watch)

@moq-bot

moq-bot Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

quest land watch: Another session holds this pull request, so the watcher stops acting on it and leaves it to that session: the hold ends the pick, and a maintainer enqueues it again once that session is done.

(written by quest land watch)

…sks-upstream

# Conflicts:
#	rs/moq-net/src/lite/subscriber.rs

@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

This review covers 47af657, a merge of main since the prior review at 0820109. It doesn't change how the PR behaves.

  • Resolved the lite/subscriber.rs conflict: main moved SUBSCRIBE_STARTED handling into ServeLoop::record_started, which records a burst of STARTED messages and then runs report_starts / declare once. The resolution keeps that structure and drops active.mins.insert(id, active.min_delay), because this PR removed min_delay. Batching only moves answer_join to after the burst. That is still later than each reader's since tick, so join placement doesn't change.
  • Merged the rest of main without conflicts: the ietf/publisher.rs change (#9374) doesn't touch live_join. cargo check -p moq-net --all-features --tests passes at 47af657.

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

@kixelated
kixelated added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 3d1bb40 Nov 22, 2026
8 checks passed
@kixelated
kixelated deleted the quest/m1/time-start-asks-upstream branch November 22, 2026 13:53
kixelated added a commit that referenced this pull request Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated added a commit that referenced this pull request Nov 25, 2026
A TS export subscribed each live track with `Live { min: delay }`, so the
relay sent up to two groups of history that the export's newest-group reader
then skipped. Since #9316 forwards that join upstream exactly, on a congested
path the backlog delayed the newest keyframe by a group, and the scheduled
`TS congested path` step started a group late, its audio one frame past the
3 s join. A live-start `ExportSource` now joins with a zero min; a replay
still reaches back the whole delay, and the max still bounds every group.

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