Skip to content

Player lifecycle: transport contract and foreground drivers leave the machine's file; machine shape gate - #1003

Merged
GLinnik21 merged 7 commits into
mainfrom
sansio/lifecycle-transport
Oct 24, 2026
Merged

GLinnik21 merged 7 commits into
mainfrom
sansio/lifecycle-transport

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Closes #1002

rust-modules/media/src/player/lifecycle.rs now holds only the ForegroundLifecycle machine. The player transport contract and the per-frame drivers that run the machine moved out verbatim:

  • the transport contract to player/transport.rs: paused, set_paused, viewer_paused, transport_target, set_transport_paused, resume_if_paused, commit_viewer_resume_for_load and their tests, the hostsim ones included;
  • the drivers to player/foreground.rs: drive_foreground, poll_foreground_flight, poll_foreground_load and park_pending_foreground_flight, with ForegroundActuator, ForegroundActivation, ForegroundPollOutcome and FlightLanding.

app::lifecycle re-exports the same names, so callers keep their paths. This is lifecycle PR B of the Sans-IO series and follows #977, which made the machine a step(event) machine with private state.

The move

git diff --color-moved=zebra over the three files classes 569 added and 571 removed lines as moved. The rest of the diff in them is:

  • module docs;
  • three machine helpers widened to pub(super), because the drivers in foreground.rs call them: ForegroundEffect::awaits_answer, PrepareAnswer::of_outcome and PrepareAnswer::of_start;
  • re-pointed doc links and use blocks;
  • .state spelled .state() at three sites in the moved hostsim tests, because transport.rs cannot reach the private field.

No test function and no other statement changed. Caller path edits are in preview.rs, pump.rs, claim_hold.rs, app/lifecycle.rs and app/run.rs.

Ledgers

Area file Before After Change
ci/allow/globals/media.txt 6 3 the three lifecycle.rs player::TX lines deleted
ci/allow/globals/screens.txt 15 18 3 seeded as a labelled coverage expansion
globals total −3 + 3 = net zero; PINNED_LEDGER_TOTALS unchanged at 19/95/60/11 (workers/globals/forks/fxlanes), main's totals

A relocation must never lower a pin by itself, so the deleted lines come with a widened globals rule:

  • The rule in ci/check-deps.sh now also sees the moved readers transport::paused and transport::viewer_paused, plus preview::paused. It sees each one qualified, bare after an import, in a braced group or by glob. A use … as rename is refused.
  • No scanned area calls the transport readers; their callers are in the unscanned src/app/ and media/. A transport-only widening would therefore have found nothing, and the pin would have dropped by three on a pure move.
  • preview::paused is the pause reader that a scanned machine does call, and it is TX.paused behind occupies(). The three seeded lines are its real reads in screens/src/detail/mod.rs (draw, preview_tick, collapse_full_trailer), and all three exist on main today. Seeding them is the coverage expansion; nothing was added to make a site pass.
  • The player::TX spellings stay pinned to lifecycle.rs as a zero-guard: the machine now reads no TX.
  • New import patterns are anchored on a word boundary. Without the anchor, a use crate::scrub_preview::*; would have turned every bare paused local in its file into a phantom site. A negative test pins this.

lifecycle.rs joins the wall gate with no hit.

Machine shape

ci/machines.ini lists media/src/player/lifecycle.rs::ForegroundLifecycle. ci/check-machine-shape.py fails on any pub field of a listed struct and on a stale entry, and reports the flag counts without failing on them:

machine media/src/player/lifecycle.rs::ForegroundLifecycle (ForegroundEvent -> ForegroundEffect): 2 fields, 0 bool, 0 Option
check-machine-shape: ok (1 machine; flag counts are report-only)

It is wired into ci/check-python-steps.txt with its 14-case test.

Build benchmark

make build-bench ran 3 interleaved runs per scenario on an Apple M4 with 10 cores and rustc 1.99.1. The base is 9bc127faf, the main this branch merged at the time. Both change runs carried the tool's host-load warning, because other lanes were building (load 10 to 37 on 10 cores).

Scenario Base 9bc127f Change, run 1 Change, run 2
No-op host test build 7.7 s 7.9 s 9.4 s
Edit leaf plx_base cbuf.rs (non-incr) 31.5 s 33.8 s 41.9 s
plx_machine landgate.rs 30.9 s 31.9 s 39.6 s
plx_platform devcaps.rs 30.9 s 31.1 s 36.6 s
plx_gfx overdraw.rs 18.1 s 17.9 s 22.3 s
plx_net stream_redirect.rs 27.5 s 31.8 s 31.1 s
plx_ui dwell.rs (control: does not rebuild plx_media) 17.0 s 19.5 s 19.1 s
plx_plex retry.rs 26.8 s 27.1 s 31.1 s
plx_telemetry window.rs 23.7 s 23.7 s 24.9 s
plx_data tape.rs 22.5 s 23.2 s 25.1 s
plx_session scripted.rs 14.7 s 16.0 s 16.4 s
plx_media units.rs 16.9 s 17.3 s 17.7 s
plx_appkit skip_pill.rs 13.9 s 13.5 s 14.4 s
plx_screens clock_readout.rs 13.2 s 12.7 s 13.6 s
app coldstart.rs 7.5 s 6.9 s 7.7 s
Edit hub plx_ui lib.rs (non-incr) 16.8 s 19.8 s 17.1 s
Unit suite run 46.7 s 47.8 s 50.4 s
ARM staticlib rebuild 10.8 s 17.3 s 10.2 s
Target dirs 5618 MB 5618 MB

Medians are shown; the per-run min and max are in the lane's record. The two incremental rows were skipped because target-fast was absent.

No row moves outside load noise:

  • Run 1 sits within a few percent of the base on almost every row.
  • Run 2 was taken under heavier load. Its control row, which rebuilds nothing this PR touches, moved +2.1 s as well.

No speed-up or slowdown is claimed.

One of run 1's three unit-suite runs failed app::bridge::library_route_tests::the_crumb_root_pops_to_the_library_and_up_from_it_is_the_movies_pill. That test passed alone 25 of 25 times, in the full suite 4 of 4, in both make check passes and in every later suite run. This PR touches no code that test binary runs, apart from re-export lines. Filed as #1001.

Gates

This PR's CI is the gate for the tree it merges: a8849ea48, which merges main at e99c685 (#999). The merged tree was not compiled locally.

Before that merge, the full local gates ran on the committed tree ccbf99abd (then on main 9bc127f), with git status --short empty before and after each:

  • make check: exit 0. Every Rust test result: line reads 0 failed, and the harness ran 543 tests, OK. check-deps read workers (22 sites), globals (97 sites), forks (60 sites), fxlanes (11 sites), "all gates green"; check-machine-shape: ok.
  • make check-nodef: exit 0, no warnings.
  • make check-replay: "3 fixtures, 6 replays, 0 failures". Every replay read verdict=SAME with every *_diffs=0, and no fixture file changed.
  • make (ARM): pkg/plxnative linked.

The merge with main had two conflicts:

  • the ci/check-deps.sh wall line, which keeps both widenings (main's subsearch.rs and this PR's lifecycle.rs);
  • PINNED_LEDGER_TOTALS, recomputed from the area files' # count: headers.

On the merged head, the gates that run no cargo:

  • ci/check-deps.sh: exit 0, with workers (19 sites), globals (95 sites), forks (60 sites), fxlanes (11 sites) and "all gates green".
  • The harness's four ledger tests and its five globals-ledger tests: OK.
  • ci/test_check_machine_shape.py: 14 tests, OK.
  • ci/check-machine-shape.py: ok.

Doc fixes

A doc-claim audit found two sentences this change made false. Both are fixed here:

  • Line 3 of every ci/allow/globals/*.txt header. It listed the globals rule's spellings by hand, so the widened rule had left all eleven copies stale. The line now points at the rule in ci/check-deps.sh. No tool parses that line. This is why the diff touches nine globals area files whose entries did not change.
  • route/flight.rs's module doc. It now names the driver that drains the foreground flight, player::foreground::poll_foreground_flight.

transport.rs's doc on resume_if_paused also gains its provenance: it came from app/playback.rs, and module-layer step L12 moved it into lifecycle.rs before this PR moved it on.

Not in this PR

  • PR A's device check is still owed on the TV: one --guest --mock background and foreground cycle, reading the Park and DidForeground outcomes in the log.

🤖 Generated with Claude Code

GLinnik21 and others added 7 commits October 24, 2026 15:03
…fecycle.rs

Sans-IO lifecycle PR B, behaviour-preserving. lifecycle.rs keeps the machine
(events, effects, state, step, accessors) and its tests; two new modules take
the rest as a pure move:

- player/transport.rs: paused, set_paused, commit_viewer_resume_for_load,
  transport_target, viewer_paused, set_transport_paused, resume_if_paused and
  their tests (the hostsim pause-contract tests too).
- player/foreground.rs: drive_foreground, poll_foreground_flight,
  poll_foreground_load, park_pending_foreground_flight, their shared loop,
  ForegroundActuator, ForegroundActivation, ForegroundPollOutcome and
  FlightLanding.

Not pure moves: the module docs, three machine helpers widened to pub(super)
(ForegroundEffect::awaits_answer, PrepareAnswer::of_outcome/of_start), doc
links and use blocks re-pointed, `lifecycle.state` -> `lifecycle.state()` at
three sites in the moved hostsim tests, and the app::lifecycle re-export split
in three. Callers keep their names through app::lifecycle.

Ledgers (the honesty rule: a relocation lowers no pin on its own): the three
lifecycle.rs player::TX lines leave ci/allow/globals/media.txt because the
machine now reads none. In the same diff the globals rule is widened to the
transport's readers (transport::paused, transport::viewer_paused,
preview::paused; bare after an import, renames refused), which seeds three
preview::paused reads in screens/src/detail/mod.rs as a coverage expansion
with correct counts. Globals total: 98 - 3 + 3 = 98, PINNED_LEDGER_TOTALS
unchanged. The player::TX spelling stays pinned to lifecycle.rs as a
zero-guard. The wall gate also covers lifecycle.rs now (no hit when it joined).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…chine-shape.py

ci/machines.ini lists the machines whose shape is gated, in list-caps.ini's
[file::symbol] style with paths relative to rust-modules/; the first entry is
ForegroundLifecycle. ci/check-machine-shape.py (wired into check-python-steps.txt
with its unit test) fails on a pub, pub(crate) or pub(super) field of a listed
struct and on a stale entry, and REPORTS, never fails on, the number of bool and
Option<..> fields per machine: a report-only flag ratchet. docs/sans-io.md gets
the status line, the globals row and TX bullet for the transport readers, and a
"Machine shape" section.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
#990 deleted the data-person ledger files and set the pins to workers 22 and
globals 97. Take those, and restate this diff's pin comment and the
docs/sans-io.md sentence as the change's own net effect (-3 deleted, +3
seeded, net zero) instead of naming a total other lanes move.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The import halves of the globals rule for the player's pause readers had no
left word boundary, so `use crate::scrub_preview::*;` (or any `..._transport`
module) made every bare `paused` token in that file a registry read. Both
halves (and the awk prefilter) now want a non-identifier character before
`transport::` / `preview::`.

The self-test plants a `scrub_preview::*` glob and a `hud_transport::{..}` /
`my_preview::{paused}` group beside a `paused` local and requires no site;
it failed on the unanchored patterns (phantom `::paused` sites) and passes now.
Also corrects the lifecycle.rs-zero-guard test's docstring: the machine reads
no TX at head.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…i says what the gate reads

lifecycle.rs's module doc justified its location by the player machine, the
trailer transport and the claim hold all naming it. At head only the player
machine does; the transport (and its users) are transport.rs's doc. foreground.rs
said "the only change to the machine's file", which ignored its doc. machines.ini
said only the section name is read, but event and effect are printed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: ci/check-deps.sh (the gate wall line and its comments keep both
widenings: media/src/player/lifecycle.rs and data/src/subsearch.rs) and
tests/test_harness.py PINNED_LEDGER_TOTALS (the sums at the resolved tree:
workers 19, globals 95, forks 60, fxlanes 11; this branch's net-zero comment kept).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…w are

The globals ledger headers copied the rule's spelling list, which this branch
widened to transport::paused, transport::viewer_paused and preview::paused, so
every copy was false. They now point at ci/check-deps.sh's globals rule instead
(no tool or test parses those header lines; only line 1, the count, is read).

route/flight.rs: the foreground restore's resume is drained by the driver
player::foreground::poll_foreground_flight, not by the machine in lifecycle.rs.

transport.rs: resume_if_paused carries its provenance (app/playback.rs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit ac0d171 into main Oct 24, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the sansio/lifecycle-transport branch October 24, 2026 15:40
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.

Player lifecycle file still holds the transport contract and its drivers; no gate pins a machine's private state

1 participant