Skip to content

Lower-layer prerequisites of the neutral media crate: plx_net::range_io, plx_base::clock, LoadVideo in platform, contract landing plan - #1272

Merged
GLinnik21 merged 6 commits into
mainfrom
uri-first/p2b-lower-layers
Nov 7, 2026
Merged

GLinnik21 merged 6 commits into
mainfrom
uri-first/p2b-lower-layers

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Summary

The neutral plx_media that follows reads a handful of things that belong below it. This PR lands them on main first, so the media PR is
media-only. It is a move plus additive items; nothing on main selects a different path.

  • plx_net::range_io (net/src/curlio.rs): the HTTPS byte-range transport leaves media/src/curlio.rs. It is generic over a
    UrlAuthorizer (the caller's credential policy, asked on every open, reopen, seek and redirect hop) and offers RangeReader /
    RangeFactory so a lower layer can own a source without naming Plex. media/src/curlio.rs shrinks to the Plex credential facade
    (PlexAuthorization, type CurlSource = range_io::CurlSource<PlexAuthorization>, range_factory(), first_read), so every
    crate::curlio::* caller on main compiles unchanged. The curl_multi_* dynlib! table moves with it, symbols and candidate list as before.
  • plx_base::clock (vclock_ms, vclock_us): a monotonic clock for stamps that are only differenced. player::vclock_ms delegates to it.
  • plx_platform::devcaps::LoadVideo: the codec one Load declares, with the codec table's row lookup and refusal rule. engine::LoadVideo is
    now a re-export; decoder_row and load_video_refused delegate to it. The existing engine tests pin the values.
  • MediaPart.duration (plex) and PlayingItem.duration_ms (data): additive, nothing on main reads them yet; one new test.
  • The playback contract's Dolby Vision landing plan (DvLandingMode, DvLandingPlan, DvWithdrawal, OpenRequest.dv_landing,
    FeedLoad::dv_landing_due, FeedCommand::DvStandDown), FeedControl::stop_begin(terminal) and RuntimeFailure::ServerStopped, with the
    FakeFeed that scripts them. The contract that merged with the first carve PR predates Playback: a Dolby Vision resume or seek that lands on a CRA plays the HDR10 base layer #1263 and Playback: stop when the server ends the session #1265, which the integration branch
    re-expressed in it; the contract is unwired on main, so this is additive.
  • The facade's one consumer, the TLS self-test dev scenario, calls first_read.
  • Docs the move made false: agent-reference.md (5 sites), the dynlib! note in module-layers.md, plex/.../CLAUDE.md,
    the fw-compat reviewer's scope table, intra-doc links in net, ci/module-layers.ini (base += clock, net += range_io),
    ci/list-caps.ini (two sections renamed to the new path).

API for the next PR, with no reader on main yet: media::curlio::{CREDENTIAL_GATE, range_factory}, RangeFactory / RangeReader /
AuthorizingRangeFactory, LoadVideo::from_diag_code and plx_base::clock::vclock_us.

Left for the media PR (and why)

The platform video-sink split (DisplaySink, tv::plane, webos::video_sink, the feed-sink and uri-transport features) needs the
Starfish/ACB seam and the port wiring in the same commit; the telemetry backend/terminal_stage fields and consent-preview rows are a
wire change that only means something once the media PR fills them (and PRIVACY.md must move with them); Force's transcoder profile is
a behaviour change tied to the route planner. With those added from the integration branch, cargo check -p plx_media --lib --no-default-features on integ's media/ has zero errors (probe in p2b-sweep.md).

Behaviour

Unchanged for playback and for every request on the wire. The one change to the moved transport is a tightening of its contract with
no production effect on main today:

  • range_io asks the URL authorizer again at the top of a request started by a seek or reopen, not only at open and at each redirect
    hop, so a caller whose grant changes after a source opened gets the next seek refused before anything is sent. Nothing on main can
    change a grant mid-stream: the curl sources are https, a TLS origin is always allowed, and CredentialPolicy::build() is fixed at build
    time. Pinned by net::range_io::tests::a_seek_rechecks_the_caller_authority_before_the_next_request, which panics
    (a revoked grant refuses the seek) with the recheck removed and passes with it, and by a_reopen_rechecks_the_caller_authority_before_the_next_request
    (reopen already asked; kept from the integration branch).
  • A bug fixed with it: a seek refused by that recheck returned before the attempt state was reset, so the next read served the pre-seek
    bytes still buffered and then a clean end of stream (0), not an error (-1). retire_attempt now clears the transfer state on every
    early return of a start (the refused recheck, and a multi handle that cannot be rebuilt), so a read after a refused seek fails and a later
    seek recovers; the same test asserts both, and failed (a read after a refused seek is an error, not bytes or EOF) before the fix.

Log lines are unchanged (crate::player::log is plx_base::eventlog::log; the curlio: bound ... (7 symbols) line is emitted by the same code).

Content size (non-whitespace characters, origin/main -> branch)

crate / path files before after delta
net 6 310,726 450,854 +140,128
media 5 736,645 605,885 -130,760
playback-contract 3 72,338 75,657 +3,319
platform 1 120,913 123,423 +2,510
base 2 2,639 3,902 +1,263
data 1 261,756 262,916 +1,160
plex 2 132,743 132,886 +143
screens (test literals) 2 164,422 164,456 +34
app (rust-modules/src; run.rs is a test literal, tls_selftest.rs the facade consumer) 3 452,086 451,790 -296
ci, docs, .agents 5 453,455 453,895 +440

media/src/curlio.rs 135,827 -> 6,719; net/src/curlio.rs 0 -> 139,727 (the net share includes the transport's moved tests); the rest of the
net delta is the fd-slack test and doc links. The move is mechanical apart from the generic parameter and the recheck above
(git diff --no-index of the old file against the new one: 115 hunks, imports, crate::player::log -> plx_base::eventlog::log, CurlSource<A>).

Verification

  • On 4c0999a: make check (all 126 steps, cargo stage incl. the hostsim pass; every test result: ok, 0 failed), make check-nodef,
    the ci/test_*.py pins, ci/check-module-layers.py, ci/check-list-caps.py, bash ci/check-deps.sh, and the fw-compat-reviewer
    agent on origin/main...carve/p2b (a dynlib! table moved crates): no blocker; the table, its candidate list and its one Once are
    unchanged; the ELF half is CI's.
  • One pr-reviewer pass: five minor findings, fixed in 1c9bb28 (the refused-seek bug above, two forward references) and in this text;
    then the doc-claim-auditor agent, ten stale sentences fixed in a2dcf13.
  • On a2dcf13: plx_net test result: ok. 265 passed; 0 failed, plx_media test result: ok. 2094 passed; 0 failed; 84 ignored,
    make check-nodef exit 0, check-deps green. CI runs the full gate.

Build benchmark (make build-bench --runs 3, same Mac, base then head)

Scenario main 279b66d (median) P2b a2dcf13 (median) delta
No-op host test build 34.2 s 35.1 s +0.9 s
Edit leaf (plx_base cbuf.rs), non-incremental 58.1 s 58.8 s +0.7 s
Edit leaf (plx_machine landgate.rs), non-incremental 51.9 s 52.1 s +0.2 s
Edit leaf (plx_platform devcaps.rs), non-incremental 50.9 s 50.4 s -0.5 s
Edit leaf (plx_gfx overdraw.rs), non-incremental 34.6 s 36.1 s +1.5 s
Edit leaf (plx_net stream_redirect.rs), non-incremental 46.5 s 49.9 s +3.4 s
Edit leaf (plx_ui dwell.rs), non-incremental 34.3 s 37.4 s +3.1 s
Edit leaf (plx_plex retry.rs), non-incremental 45.6 s 47.6 s +2.0 s
Edit leaf (plx_telemetry window.rs), non-incremental 44.1 s 45.5 s +1.4 s
Edit leaf (plx_data tape.rs), non-incremental 41.1 s 41.1 s +0.0 s
Edit leaf (plx_session scripted.rs), non-incremental 29.6 s 29.8 s +0.2 s
Edit leaf (plx_media units.rs), non-incremental 34.0 s 34.8 s +0.8 s
Edit leaf (plx_appkit skip_pill.rs), non-incremental 29.0 s 30.1 s +1.1 s
Edit leaf (plx_screens clock_readout.rs), non-incremental 26.4 s 27.7 s +1.3 s
Edit leaf (app coldstart.rs), non-incremental 17.2 s 17.2 s +0.0 s
Edit hub (plx_ui lib.rs), non-incremental 25.3 s 26.0 s +0.7 s
Unit suite run (default features) 68.0 s 67.7 s -0.3 s
ARM staticlib rebuild (touch lib.rs) 20.3 s 34.1 s +13.8 s

Within noise apart from the ARM relink median (+13.8 s), whose spread is the same on both sides (base 20.1-47.9 s, head 18.2-48.4 s).
The two incremental rows were not run (the full run exceeds the two-hour job limit; P1 and P2 made the same cut). One load warning per
run (a single repetition above 10 cores). ARM archive 119.7 -> 119.6 MiB.

Related: #1064

🤖 Generated with Claude Code

GLinnik21 and others added 6 commits November 7, 2026 11:10
…e_io in net, clock in base, LoadVideo in platform)

Moves the HTTP range transport out of media into plx_net::range_io (generic over a UrlAuthorizer; media/src/curlio.rs
becomes the Plex credential facade, so main's crate::curlio::* callers are unchanged), adds plx_base::clock, moves
LoadVideo into plx_platform::devcaps (engine.rs re-exports it), and adds MediaPart.duration / PlayingItem.duration_ms.

Behaviour: none except one hardening hunk in range_io: a seek or reopen asks the URL authorizer again before the
request (a revoked credential grant no longer rides on the source's first open). Pinned by
net::range_io::tests::a_reopen_rechecks_the_caller_authority_before_the_next_request.

Deferred to P3+P4/P5 (see p2b-map.md): the VideoSink/DisplaySink split and tv::plane (they need the Starfish/ACB seam),
telemetry backend/terminal-stage fields and the consent-preview rows (a wire change), Force's transcoder profile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l stop_begin and ServerStopped (additive)

The contract crate merged with P1 predates #1263 (DV landing guard) and #1265 (honor Plex server stops), which integ re-expressed
in the contract: DvLandingMode/DvLandingPlan/DvWithdrawal, OpenRequest.dv_landing, FeedLoad::dv_landing_due,
FeedCommand::DvStandDown, FeedControl::stop_begin(terminal), RuntimeFailure::ServerStopped, and the FakeFeed that scripts them.
Nothing on main implements or matches these yet (the contract is unwired), so main's behaviour is unchanged; the neutral
media crate (P3) reads them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ut it

The seek/reopen authorizer recheck in plx_net::range_io was carried by integ with a reopen test only, and that test passes
without the recheck (reopen_until already asks). This one revokes the grant after the first open and expects the seek to be
refused with no request sent; it panics ("a revoked grant refuses the seek") with the recheck removed and passes with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t's crate doc names range_io

The first make check failed in its hostsim pass: rust-modules/src/app/run.rs:4967 builds a PlayingItem inside a hostsim-only
test, so the default-feature check could not see the missing duration_ms. fw-compat review (MINOR): net/src/lib.rs's crate
doc still called the module curlio, but it is mounted as range_io.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…instead of serving stale bytes

The seek/reopen authority recheck returned before the attempt-state reset, and
seek's error arm only detached the handle. After a refused seek the next read
returned the pre-seek bytes still buffered, then a clean end of stream (0)
instead of -1. retire_attempt (detach, drop the buffered body, clear
done/failed/readable) now runs on every early return of a start: the refused
recheck and a multi handle that cannot be rebuilt. The seek test asserts the
read after a refused seek is negative and that the next granted seek recovers.

Also: two forward references named things that arrive later (devcaps'
SHARED.dg_load_v, clock's reader list).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…inters, curlio's place in media's cycle, forward references

doc-claim-auditor on 279b66d...HEAD, contradictions only: shared-servers.md and
the engine/ff.rs pointers named media's curlio.rs for the dynlib! table and the
abort-registry rationale (both now in plx_net::range_io); media's crate doc kept
curlio in the call cycle it left; RangeReader/AuthorizingRangeFactory named a feed
worker and demux job this tree does not have; feed.rs named plx_play_feed::dv_start
and a Feed that builds the guard (the guard is media::player::dv_start); clock's doc
named a Feed layer; plus the net::origin::ResolvePin path, the range_io::tests name,
a data-test comment and media's Cargo.toml comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit dc3d03c into main Nov 7, 2026
20 checks passed
@GLinnik21
GLinnik21 deleted the uri-first/p2b-lower-layers branch November 7, 2026 10:23
GLinnik21 added a commit that referenced this pull request Nov 7, 2026
Every P2b path keeps integ's version except net/src/curlio.rs, which takes main's:
the seek authority recheck test and retire_attempt (a start that returns early resets
the attempt, so a read after a refused seek fails), plus its doc fixes. The two test
literals main gave duration_ms already carry it here. The doc and comment fixes of
P2b's audit that integ lacked come in with the merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PilaScat added a commit to PilaScat/plx-native that referenced this pull request Nov 7, 2026
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