Skip to content

feat(moq-mux): only a padded TS export waits for the mux rate - #8829

Merged
moq-bot[bot] merged 4 commits into
mainfrom
quest/m1/ts-mux-rate-hold
Nov 15, 2026
Merged

moq-bot[bot] merged 4 commits into
mainfrom
quest/m1/ts-mux-rate-hold

Conversation

@kixelated

@kixelated kixelated commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m1/ts-mux-rate-hold.md (deleted here).

Summary

  • A TS import no longer withholds its catalog to measure a mux rate. The catalog goes out with the first media, and mpegts.muxRate follows as a catalog update once a 2 s PCR window measures it. A variable-rate source never records one. Removed from Import: the mux-rate reservation, the 4 s media bound, the re-arm on a clock break, and Meter::ready; the UNMEASURED constant becomes the export's WAIT.
  • An export with no with_mux_rate override waits up to one window (2 s, mux_rate::WAIT) for the rate when its first catalog snapshot comes from a TS import (non-empty mpegts section) and records none. It holds that snapshot and subscribes the tracks only when the rate arrives or the window runs out, so it joins the media as it is then, not on frames that went stale during the wait. A rate that arrives after the wait still takes over from the next slot, as before.
  • Docs (doc/bin/ts.md), the moq-mux changelog follow.

Public API and wire

Public API: none. Behavior: a TS import's first catalog no longer carries muxRate for a source that has not measured one; an export joining in that first window waits up to 2 s for it. Wire: muxRate may arrive in a later catalog update than the first, which the draft already allows (it is optional and "present only while the source holds a constant rate").

Choices a review can undo

  • Wait is one window, not window plus slack. WAIT is 2 s from the export's first snapshot. An export joining at the very start can race the update, and then starts unpadded and pads from the next slot once the rate arrives (the schedule already takes a mid-stream rate). Recommendation: keep; a slack would cost every variable-rate export more.
  • Trigger is "the first snapshot has a non-empty mpegts section, no muxRate, and no override". The catalog cannot say whether a source is variable-rate or still measuring, so a variable-rate TS source costs every export that joins it one wait, including late joiners. The quest's "only an export joining in the first window pays" holds for constant-rate sources only. Recommendation: accept; a "measured, none" marker would be a wire change, so it is not here. Say if you want it as a follow-up quest.
  • The wait is before subscribing, not before building the tables. Holding only the tables left the held keyframe stale after the wait (the moq-srt tests showed the export then waits for the next keyframe). Holding the snapshot costs the same wait and joins fresh.
  • A catalog that ended, a PSI already built, an override, or a catalog with no TS section never waits.
  • Test-only Export::without_rate_wait used by open_ts, so ~45 existing export/recovery/revision tests (which export TS-imported catalogs with no rate on a simulated clock) keep their timelines. Three new tests cover the wait itself.
  • moq-srt publisher_preserves_scte35_cues: its egress now waits one window on a source that records no rate, so the test's latency goes 3 s to 5 s and its read timeout 5 s to 10 s.
  • Removed the import tests for the hold (4 s media bound, rollover, resetting clock, break before the first catalog, short finish) with the code they covered; first_ts_catalog_gains_the_mux_rate_as_an_update and private_pes_only_program_publishes_its_pes_clock_with_the_first_media replace the first catalog tests.

Validation

  • just check passes (5987 Rust tests among them).
  • New tests on the simulated clock, each failing with the wait disabled (checked): export_waits_for_the_rate_a_window_is_measuring (a join 0.4 s into a 400 kb/s CBR source starts output at 2.2 s and pads; with an override the same join starts at 185 ms), export_stops_waiting_for_a_rate_that_never_comes (a VBR source: first output at 3.3 s, unpadded), export_with_a_rate_override_does_not_wait, and first_ts_catalog_gains_the_mux_rate_as_an_update on the import side.
  • Not run against a real relay or ffmpeg pipe beyond the moq-cli integration tests (moq import ts against a test relay), which pass.

Caused by

  • moq-dev/moq#5287 - held every TS import's catalog for a full PCR window, CBR or VBR (found by feature review)

Follow-ups

None.

Models

Size: S
Implementer: Claude Code, claude-sonnet-5-5, high effort (iterate, S, arm B)

Review

Rewritten by quest review after each round.

  • Head: c40404b

  • Base: origin/main at 5b4c01b

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

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

  • Session: 01a1dfab-2e10-7aa2-b969-8a2501d91138, round 3

  • Score: 10/10, The incremental diff only corrects test comments to describe the current behavior and introduces no actionable defects; builds and tests were not run as instructed.

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

  • Findings: none

kixelated and others added 2 commits November 15, 2026 04:40
…nd only an export that may pad waits for the mux rate

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Only a padded TS export waits for the mux rate feat(moq-mux): only a padded TS export waits for the mux rate Nov 15, 2026
@kixelated
kixelated marked this pull request as ready for review November 15, 2026 14:46
@coderabbitai

coderabbitai Bot commented Nov 15, 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 3 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: aecb9a96-4640-491d-8a82-caafebc7d7f0
Commits

Reviewing files that changed from the base of the PR and between bf04cec and c40404b.

Files selected for processing: 11

  • doc/bin/ts.md
  • quest/m1/ts-mux-rate-hold.md
  • rs/moq-cli/src/publish.rs
  • rs/moq-cli/tests/integration/import.rs
  • rs/moq-mux/CHANGELOG.md
  • rs/moq-mux/src/container/ts/export.rs
  • rs/moq-mux/src/container/ts/export_test.rs
  • rs/moq-mux/src/container/ts/import.rs
  • rs/moq-mux/src/container/ts/mux_rate.rs
  • rs/moq-mux/src/container/ts/republish.rs
  • rs/moq-srt/src/ts.rs
  • 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

@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 blocking issues — one timer race worth closing inline.

Reviewed changes

Initial review of moving the two-second mux-rate wait from the TS import (which held the catalog from every subscriber) to the TS export (only exports that have no with_mux_rate override wait).

  • Import publishes at once — Import drops the mux-rate reservation, the 4 s media bound, and the re-arm on a clock break. muxRate now arrives as a catalog update once a PCR window measures a constant rate, and timebase_break routes through reset_mux_rate.
  • Export-side wait — prepare holds the newest snapshot in held_catalog. awaiting_rate holds back update_catalog, and so the track subscriptions, until the rate arrives or mux_rate::WAIT (2 s) runs out. The hold applies only when the program has no override, PSI, or tracks yet and the snapshot's non-empty mpegts section records no rate. Replacements inherit rate_wait.
  • Tests — three new sim-clock export tests via Joined, with open_ts opting out through without_rate_wait. The import test now checks that the rate arrives as an update, five hold tests are removed, and the moq-srt SCTE-35 egress test gets the extra window.
  • Docs — the doc/bin/ts.md Semantic bullet, the moq-mux changelog, and the ts-republish quest text now describe the new behavior.

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

Comment thread rs/moq-mux/src/container/ts/export.rs Resolved
An elapsed rate wait ends on the sleep's own result, so it never holds without a waker.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
pullfrog[bot]
pullfrog Bot previously approved these changes Nov 15, 2026

@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. The fix for the timer race is correct.

Reviewed changes

This review covers the changes since the review of 7c3457b: a fix in export.rs and a merge of main.

  • The rate wait can no longer stall — awaiting_rate now checks what waiter.poll_future returns for the rate_timer sleep. If the sleep is already Ready, it clears the timer and ends the wait. Before, an elapsed deadline could leave the export with no waker. The now() >= until check stays as a cheap early exit.
  • Merged main — main changed the same lines as this PR's edits to the ts-republish quest and the Republish::instance doc comment, so those edits are no longer part of the diff. The only publish.rs change left is the comment wording in a_clock_step_republishes_under_a_new_instance.

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

…he mux-rate hold

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

@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

Reviewed the delta since f5b27e8.

  • Test comments corrected — a_switch_before_the_first_catalog_republishes in republish.rs no longer cites the removed mux-rate hold. Its comments now describe a step in the same chunk as the first media. No code behavior changed.

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

@moq-bot
moq-bot Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 2c3eb75 Nov 15, 2026
7 checks passed
@moq-bot
moq-bot Bot deleted the quest/m1/ts-mux-rate-hold branch November 15, 2026 21:43
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