Skip to content

Playback contract crate, BackendRunner and attempt-metrics reducers (unwired) - #1268

Merged
GLinnik21 merged 7 commits into
mainfrom
uri-first/p1-playback-contract
Nov 7, 2026
Merged

GLinnik21 merged 7 commits into
mainfrom
uri-first/p1-playback-contract

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Summary

Adds plx_playback_contract (rust-modules/playback-contract/), the backend-neutral playback vocabulary
that the later URI-first PRs build on, and lands five pure reducers in plx_media::player that nothing
calls yet.

  • The contract crate (names only plx_base, new layer [playback_contract]): the playback commands and
    readouts, the time, track and subtitle types, the BackendState machine, the adaptive-session types, the
    UriDriver port, the Feed port traits (FeedSeek, FeedLoad, FeedOpen, FeedStop, and FeedControl over
    them) and the adaptive FeedPort, with their test fakes (test-support).
  • Five reducers in plx_media::player, with unit tests and no callers: backend.rs (BackendRunner),
    backend_startup.rs, backend_metrics.rs, attempt_metrics.rs, attempt_view.rs. They are pub mod, so
    there is no dead-code warning to suppress. They land before the PR that wires them (P3+P4) so that PR
    reviews wiring, not 80,000 characters of new reducer.
  • Two consumers on main now read the contract: plx_data's TrackNames and plx_media's
    abr::units::MediaTimeMs become re-exports of the contract's types (same path, same fields).
  • Workspace and CI lists: workspace member, [playback_contract] in ci/module-layers.ini, the two
    ci/machines.ini entries, ci/check-deps.sh (the crate and the four reducers are machine code; no
    ci/allow/ ledger line is added or changed), ci/list-caps.ini, Makefile (UNIT_SUITE, the lab,
    hostsim and test-fast lines, RUST_INPUTS), tools/build-bench.py, the Python pins that quote those
    lists, .github/workflows/ci.yml, and the docs that quote the unit-suite -p line.

Behaviour: none. No production code constructs a BackendRunner, BackendState, AttemptMetrics or any
contract port; the two re-exports are the same types under the same paths.

This is the first PR of the URI-first series carved from the integ/uri-first integration branch. Every path
this PR owns is byte-identical to that branch (git diff integ/uri-first HEAD -- <the 23 paths> is empty);
shared files (Makefile, CI scripts and lists, docs) carry only the hunks this PR's crate and files need, found
by sweeping each shared file's integration diff for them.

Content size (non-whitespace characters, tr -d '[:space:]' | wc -c, base 4bf133d -> head)

crate / group files changed before after delta
playback-contract (src/**/*.rs) 15 (14 .rs + Cargo.toml) 0 177,456 +177,456
media (changed files; src/**/*.rs whole crate 5,517,473 -> 5,626,119) 8 190,561 299,258 +108,697
data (track_names.rs 1,649 -> 179, Cargo.toml +51) 2 5,331 3,912 -1,419
workspace Cargo.toml / Cargo.lock 2 54,964 55,120 +156
CI, Makefile, tools 14 488,691 491,142 +2,451
docs and skill prose 5 420,898 422,010 +1,112

Almost all of it is new code (contract +177k, reducers +108k) with its tests. data shrinks because
TrackNames moved into the contract; the 2,451 in CI/tools is the check-deps.sh scan lists and
list-caps.ini sections.

Duplicates this PR adds beside live media definitions (not fixed here)

The contract carries the vocabulary that later PRs move out of media. Until then both copies exist; byte-identity
with integ forbids editing either side here, and media does not use the contract copies (outside the five new
reducers and the abr/units.rs re-export, nothing in media names the contract). Each pair is removed by the series PR that switches media to the
contract (named below: P2 the codecs move, P3+P4 the neutral orchestration with the play-feed move):

contract item live definition on main removed by
subtitle.rs (WINDOW_NS, SCAN_NS, fingerprint, Anchor, ReadCfg, RunEnd, SideStop, pacing_parks, playhead_of, delta_*, judged_clock) media/src/ff_subside.rs P2 (integ's ff_subside.rs keeps only the transport and imports these from the contract)
subtitle.rs Spec media/src/player/subside.rs:51 P3
feed.rs consts MAX_FEED_AHEAD_NS, AUDIO_SLACK_NS, AQ_VIDEO_BYTES, AQ_AUDIO_BYTES, PRES_NONE; SampleBuf media/src/player/engine.rs:3127 (and neighbours), :157 P3+P4 (ci/list-caps.ini therefore carries both MAX_FEED_AHEAD_NS sections until then)
readout.rs ABR_MODE_*, ABR_ACTION_*, RuntimeFailure (pub(crate) in media); feed.rs SeekMode media/src/player/mod.rs:316, :1117 and the ABR_* consts P3
readout.rs RefusalPath, PlaybackState; feed.rs HlsUserPause, HlsUserResume, HlsPauseCompletion, HlsPlayCompletion media/src/player/shared.rs:21, :363-:478 P3+P4
feed.rs PcmFormat media/src/route/decision.rs:5828 P3
feed.rs DolbyHdrInfo (identical fields) data/src/metadata.rs:652 (the data layer's own copy) P3 (data re-exports the contract's)
playurl.rs PlayUrl, PlayDovi media/src/player/playurl.rs:43, :110 P3+P4 (file deleted; adapter.rs/engine.rs switch to plx_playback_contract::playurl)
video.rs Rat, Mastering, ContainerHdr media/src/player/vp9_hdr.rs:35-:51 P4 (file moves to play-feed)

Documentation that names paths which exist only after a later PR

The contract's and reducers' doc comments describe the final layout. These sentences name a crate or file P1 does
not add (they are comments, not links; nothing breaks):

  • playback-contract/src/feed.rs:24 (play-feed/src/readout.rs)
  • playback-contract/src/playurl.rs:3, :21, :112 (plx_play_feed::playurl, plx_play_feed::audio_payload_codec, media's feed_open once it moves)
  • playback-contract/src/subtitle.rs:136, :145 (plx_play_feed::side_reader, SideReaderPort)
  • playback-contract/src/uri.rs:58 (plx_play_uri)
  • media/src/player/backend.rs:943, :946 (the play-uri backend rig, UriBackend::picture_step, play-uri/src/picture_gate.rs)
  • media/src/player/backend_metrics.rs:348 (PlayerAdapter::observe_backend_condition, P3)
  • playback-contract/Cargo.toml [package.metadata.plx] mount: read by integ's ci/check-module-layers.py (P7); main's gate ignores it and derives the layer from the package name.
  • docs/module-layers.md (the new paragraph) says the BackendRunner and attempt reducers are "written against" the contract; they have no caller until P3+P4.

Not fixed in P1 (follow-ups on integ, found by the same review)

  • Finding 8: the contract names webOS facts (BackendKind, BackendSet, Starfish-shaped fields in feed.rs).
  • Finding 9: three Backend enums (attempt_view::Backend, the contract's BackendKind, the reducers' local one).
  • ci/check-build-budgets.py --graph --src never listed the contract on integ; P1 adds it (and the three prose
    places that enumerate the crates). Integ should take the same edit.

Verification

  • make check on the committed tree (41b4e6b, git status --short empty before and after): ==== check: 126 steps — all ok (323s wall, ...) ====, ==== check: harness — ok (416s) ====, exit 0. Its unit passes include plx_playback_contract: test result: ok. 40 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (default features and hostsim) and plx_media: test result: ok. 2135 passed; 0 failed; 84 ignored (default), 2369 passed; 0 failed; 84 ignored (hostsim); bash ci/check-deps.sh: check-deps: all gates green.
  • Python pins: ci/test_build_bench.py 44 ok, ci/test_ci_split.py 16 ok, ci/test_test_fast.py 9 ok, ci/test_build_budgets.py 21 ok; ci/check-rust-inputs.py, ci/check-module-layers.py (15 layers), ci/check-list-caps.py (342 sites), bash ci/check-deps.sh (all gates green).
  • Not run (CI runs them): make test-hostsim, the TV, make (ARM cross-build).

Build cost

make build-bench on one Apple M4 (10 cores), base 4bf133d57 then this branch at 41b4e6bc5 (the only later commit is a
docs line), 3 interleaved runs per scenario, medians. The two incremental rows were skipped on the branch run (a full run exceeded
two hours on this machine). Another job was building during both runs (the tool warns load > 10 cores), so differences of this size
are noise; the branch adds one small leaf crate that only data and media name.

Scenario main this PR
No-op host test build 34.7 s 35.2 s
Edit leaf (plx_base cbuf.rs), non-incremental 52.9 s 55.9 s
Edit leaf (plx_machine landgate.rs), non-incremental 68.6 s 51.9 s
Edit leaf (plx_platform devcaps.rs), non-incremental 66.6 s 59.2 s
Edit leaf (plx_gfx overdraw.rs), non-incremental 49.5 s 36.3 s
Edit leaf (plx_net stream_redirect.rs), non-incremental 59.1 s 46.1 s
Edit leaf (plx_ui dwell.rs), non-incremental 41.1 s 33.2 s
Edit leaf (plx_plex retry.rs), non-incremental 57.0 s 47.2 s
Edit leaf (plx_telemetry window.rs), non-incremental 53.0 s 43.9 s
Edit leaf (plx_data tape.rs), non-incremental 57.2 s 41.7 s
Edit leaf (plx_session scripted.rs), non-incremental 56.4 s 29.4 s
Edit leaf (plx_media units.rs), non-incremental 51.5 s 33.2 s
Edit leaf (plx_appkit skip_pill.rs), non-incremental 52.3 s 29.3 s
Edit leaf (plx_screens clock_readout.rs), non-incremental 37.1 s 26.7 s
Edit leaf (app coldstart.rs), non-incremental 22.8 s 16.6 s
Edit hub (plx_ui lib.rs), non-incremental 31.0 s 26.8 s
Unit suite run (default features) 96.7 s 75.6 s
ARM staticlib rebuild (touch lib.rs) 70.1 s 19.9 s

No-op: both sides rebuild the same one unit (app crate rebuilt: mixed, 1/181 units on main, 1/183 here), a pre-existing marker.
Unit suite: 11,893 passed on main, 11,975 here (the contract's 40 and the reducers' tests). ARM archive 118.4 MiB -> 118.5 MiB.

Related: #1064

🤖 Generated with Claude Code

GLinnik21 and others added 7 commits November 7, 2026 00:19
…ics reducers (unwired), workspace and package lists

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…k-deps scans, docs

The pr-reviewer's blockers and minors against carve/p1:
- Makefile RUST_INPUTS lists rust-modules/playback-contract (ci/check-rust-inputs.py).
- tools/build-bench.py HOST_TEST_ARGS and the unit-suite prose name plx_playback_contract;
  ci/test_build_bench.py's fake cargo reports its artifact, and ci/test_test_fast.py counts the
  `-p` crates instead of hard-coding the number.
- ci/list-caps.ini classes the contract's MAX_FEED_AHEAD_NS, subtitle WINDOW_NS and fingerprint,
  and media's MAX_ATTEMPT_HISTORY.
- ci/check-deps.sh scans playback-contract/src like every other layer crate and puts the contract
  and the four unwired reducers (attempt_metrics, attempt_view, backend_startup, backend_metrics)
  in MACHINES, the contract in FORK_SCOPE. No ledger line changes.
- ci/test_build_not_always_dirty.py LIB_ARGS, the CI source-lines budget (--src, its prose in
  check-build-budgets.py and build-budgets.json) and every quoted unit-suite `-p` list in the docs
  name the contract.
- docs/module-layers.md describes the playback_contract layer and its data/media edges;
  docs/sans-io-guide.md lists the new machine files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#1265 added FailureKind::ServerStopped. The server ending the session is
not the backend's refusal, so it maps to an unknown presentation failure
and arms no backend fallback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit ec0df8c into main Nov 7, 2026
29 checks passed
@GLinnik21
GLinnik21 deleted the uri-first/p1-playback-contract branch November 7, 2026 01:23
GLinnik21 added a commit that referenced this pull request Nov 7, 2026
…nto lane/merge-1265

#1265 lands where integ keeps that code: the neutral parts (timeline reply, terminal-for-the-logical-
playback, recovery cancel, read-out) stay in media; the physical Feed parts (deferred cleanup of an
in-flight native Load, the off-frame release of the stopped engine) are play-feed's, reached through
`FeedStop::stop_begin(terminal)`. A server stop is terminal for whichever backend plays: the
backend-neutral `route_start::retire_if_server_stopped` releases a Feed engine or a URI attempt.

#1268's paths take integ's side (integ is the superset); `backend_metrics.rs` gains main's
`ServerStopped` arm, and the contract's `RuntimeFailure` gains the variant.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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