Skip to content

fix(transcode): honor lite-07 time starts, descending gap lookups, and live group skips - #9737

Draft
kixelated wants to merge 3 commits into
mainfrom
quest/m1/transcode-lite07-spans
Draft

kixelated wants to merge 3 commits into
mainfrom
quest/m1/transcode-lite07-spans

Conversation

@kixelated

@kixelated kixelated commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Closes the quest quest/m1/transcode-lite07-spans.md (deleted here).

Problem

Three lite-07 gaps in moq-transcode's rungs, left after zero-timer accounting landed:

  • Time starts. rung::fetch fetched a reader's time start t as an exact key. When t falls inside source group [g, end), the source has no group at t, so the rung dropped t, which tells moq-net no group starts from the floor through t: the reader skipped g entirely.
  • Descending gaps. drop_gap placed the gap below a miss by reading the source in key order from the fill's first group, walking (and pulling from upstream) every source group below the miss just to find the newest one.
  • Live skips. The live path created groups with claim_group and never declared skipped starts, so the pause between two source groups stayed owed on the rung's track: a lite-07 reader of a rung waited on it for good (or paid a fill round trip that reported it as a lost gap).

Approach

  • fetch resolves a time start against the source the way any reader would: a one-group read from Start::Time(t) through t returns the group containing t. A group from the fill's floor through t is accepted under its own key (and transcoded from that read); otherwise the key is dropped. A retired rung's drain refuses a placement that can't answer at once, as drop_gap already does.
  • drop_gap, filling newest first, reads only the source group containing the miss: it is the newest group below it. Only when no group contains the miss (the one below ended whole before it) does it fall back to the read from the fill's first group.
  • The shared feed sends Item::Skip(range) ahead of each group whose run below the source declared skipped (from one past the previous group, since a whole group's span holds no starts), and asks a run again at the next group, since a skip travels apart from its group and may land after it. The rung mirrors each with skip_groups. Only source-declared skips are mirrored: a run the feed passed (stale, lost in transit) may hold real source groups, which stay fillable.

Tests use media-timescale keys (microseconds, groups seconds apart):

  • rung::a_time_start_inside_a_group_serves_the_group_containing_it: an unaccepted mid-group time-start fill through spawn_fill gets the whole containing group (fails without the fix).
  • rung::a_descending_gap_is_placed_from_the_miss: the source's handler is asked to place the miss (floor just past its 2 s group), never time 1 from the fill's start (fails with the old lookup).
  • rung::a_descending_fill_drops_a_gap_past_a_paused_group_at_once: covers the fallback.
  • feed::the_source_skips_reach_the_listeners: skips past a finish_at pause, past a lost group, none for an unproven run, and a trailing skip named at the next group.
  • a_rung_skips_what_its_source_skips (end to end through Transcoder::run): the rung's track records the source's skips across a pause and a lost group, keeps the lost group unskipped, and ends its group at the source group's End (finish_at).

Impact

  • moq-net: track::Subscriber::is_skipped is now public (it was crate-private; Ordered::is_skipped already was). Additive.
  • @moq/net: Track.Subscriber.isSkipped(start, end) is now public, mirroring Rust; Ordered.isSkipped calls it. Additive.
  • moq-transcode: behavior only (time-start fills, descending gap lookups, mirrored skips). No wire change.

Alternatives

  • Descending gaps through a descending arrival-order subscription, as the quest suggested: rejected, since arrival order is not key order under reordering, so the first group to arrive could be older than the newest one below the miss, and dropping down to it would drop real groups.
  • Switching the feed to an Ordered read, whose gaps say which runs are skips: rejected, since a key-order read holds newer groups behind a hole for up to the superseded budget, adding live latency.
  • Skipping every run between consecutive live groups: rejected as above; it would declare groups the source has.

Decisions

Taken while the maintainer was away; each is open to revisit.

  • Descending lookup reads the group containing the miss, falling back to the old read only when none contains it (see Alternatives).
  • Live skips mirror only what the source declared, which needed Subscriber::is_skipped public in Rust and JS (see Impact).
  • The existing tests that answer a reader's time-start fill by hand (a_group_nobody_reads_releases_its_fill, the drain tests, fill_across) keep doing so: there it is setup for the range fill under test, and routing it through a real transcode in those paused-clock tests would add codec-thread timing. The time-start path has its own test through spawn_fill instead.

Caused by

  • moq-dev/moq#9228 - made a reader's time start a group fill but left the rung's handler fetching the time as an exact key, dropping the containing group (found by reviewer).
  • moq-dev/moq#9686 - removed TrackState::miss_grace without the live path declaring its source's skips, so pauses stay owed (found by reviewer).
  • moq-dev/moq#9120 - placed a descending gap by reading from the fill's first group (found by reviewer).

Validation

  • cargo nextest run -p moq-transcode: 105 passed; the new tests also 30/30 under --stress-count 30.
  • Each new rung test confirmed failing against the old code path.
  • just check: passed (rs, js incl. API report, lint, docs).
  • Real surface: a_rung_skips_what_its_source_skips drives Transcoder::run with real OpenH264 encode and decode; no relay deployment was exercised.

Follow-ups

None.

Models

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

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

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

  • Base: origin/main at 7297210

  • Risk: medium, If the new skip declarations in moq-transcode's feed and rung code are wrong, lite-07 subscribers of transcoded rungs could skip groups that exist or stall on ones that never arrive, and the change reaches them with the next release cut; it is a fix plus an additive `is_skipped` API in moq-net and js/net that keeps the existing API and wire format, and a revert fully undoes it, so it is medium rather than high, with the quest plan deletion being low.

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session a2f136ec-2d96-4284-a4cf-3b855ea39bae

  • Risk file: bb7b1c0de60b

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

  • Session: 01a21b7c-d8e9-71f1-aca2-06c423a9ca6e, round 1

  • Score: 6/10, The additive Rust and JS skip queries preserve the ordered-reader API, but seeks into pauses can replay earlier media and late source skips can leave ordered viewers waiting or reporting loss.

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

  • Findings, open until the next round settles them:

    • Medium, rs/moq-transcode/src/rung.rs:778: Preserve the source GOP’s end when a seek lands in a pause
    • Medium, rs/moq-transcode/src/feed.rs:236: Forward late source skips without waiting for another GOP

kixelated and others added 3 commits November 26, 2026 19:26
…d live group skips

A rung's fill now resolves a reader's time start against the source's own
starts, accepting the group containing the time instead of dropping the key
(which skipped that group). A descending gap is placed from the source group
containing the miss rather than by reading the fill's history from its first
group. The live path mirrors the starts its source declared skipped, so a
lite-07 reader of a rung never waits on a pause between groups.

moq-net's Subscriber::is_skipped (and JS Subscriber.isSkipped) become public
so the shared feed can ask its arrival-order read.

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

A skip travels apart from the group above it, so the feed asks a run that
was not yet known skipped again when the next group arrives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Transcoder honors lite-07 time starts, descending gap lookups, and live group skips fix(transcode): honor lite-07 time starts, descending gap lookups, and live group skips Nov 27, 2026

This branch has not been deployed

No deployments
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