Repository navigation
Player foreground lifecycle: one step(event) machine with private state - #977
Merged
Merged
Conversation
The 15 public mutators become the ForegroundEvent arms of one private-state step(&ForegroundEvent, &mut Vec<ForegroundEffect>) -> Handled. The drivers are a loop that feeds each answering effect's answer back as the next event, held in one Option slot. PlayKeyOffPlayer folds key_play's discard_started_state into the same event as the PLAY it precedes; Park carries the viewer's pause as a value. Co-Authored-By: Claude Opus 5.5 <[email protected]>
play_off_player_is_one_event: a started session's pending clock goes to Idle and the press answers Ordinary in one event; every other state answers it as PlayKey. every_state_meets_every_event_as_the_table_says: next state, effects and Handled for all eight states against all 29 events. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The transport_pause_contract_tests park through Park, and claim_hold's two suspend tests name the lifecycle's attempt type, which clock_for_suspend_now used to pin. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The module doc of player/lifecycle.rs now says how the machine is driven (ForegroundEvents through `step`, private state, the read accessors and the drivers' single-slot loop), and the player guide points at `ForegroundLifecycle::step` for the per-state table and says to add no event outside `ForegroundEvent` instead of "no mutator beside `claim`", which no longer exists. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 24, 2026
GLinnik21
added a commit
that referenced
this pull request
Oct 24, 2026
… worker job (#979) Since #973, every app frame can run the session owner's cache refill. While the process-global cache was Unloaded, SessionAdapter::begin_cache_refresh submitted a real storage-worker job even under Resources::Fixture. Its CacheRefreshed answer landed on whichever frame the worker beat, so fixture Bridge tests depended on timing: home_worker_results_cross_the_addressed_dispatcher_ingest_once failed with "wrong result type" in three of four CI jobs on #977. A fixture-Bridge test with no TempSession could also install a developer's real auth.json into the cache for later tests. A fixture adapter now parks refresh_cache_job in FixtureResources, as StoreRunner::Held parks store jobs, and runs it only when a test asks (run_held_cache_refresh). cache_refresh_req covers a parked refresh, so the reconcile reads it as held. Live adapters are unchanged. Tests: a_fixture_adapter_submits_no_storage_worker_job_for_a_cache_refresh; the Home test starts from an Unloaded cache (premise asserted) and drains the worker between frames with its tap strict; a_live_adapter_begins_a_cache_refresh_without_taking_the_session_io_lock keeps the live IO-lock coverage that a fixture can no longer give; a debug_assert catches an overwritten parked refresh. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #976
The player's foreground lifecycle (
ForegroundLifecycle,media/src/player/lifecycle.rs) now has one writer:Its fifteen
pubmutators and itspub statefield are gone. This is step 3 of the Sans-IO series (docs/sans-io.md). The change preserves behaviour and leaves every ledger and pin as it was.What changed
Events. Eight
ForegroundEvents replace the mutators:Park{saved_ns, viewer_paused}suspend+clock_for_suspend_nowParkFlightpark_pending_flightInput(ForegroundInput)claimPrepareAnsweredfinish_prepare*LoadAnsweredfinish_load_*FlightStalerelease_stale_flightLoadStatussettle_loadClockAnsweredfinish_clockPlayKeyOffPlayer. This newForegroundInputturnsdiscard_started_state+claim(PlayKey)into one event.key_playsends it exactly when PLAY arrives off the player.Effects.
AfterLoad,LaunchedandDropFlightare new;Retirestays separate, so the #853 tables are unchanged.Purity. The pause flag arrives as a value on
Park.clock_for_suspend_now, the helper that read the transport's global, is deleted, andclock_for_suspendis private. The machine reads no global, clock or IO.State. The state is private. Callers read it through
awaiting_load,claimable_clock,pending_flightandpending_load_attempt, plusstate()undertest/test-support.Drivers.
drive_foreground,poll_foreground_flight,poll_foreground_loadandpark_pending_foreground_flightnow share one loop:Option<ForegroundEvent>slot;ForegroundActuator;debug_assert!checks that a step emits at most one answering effect;Ordering. Two orderings change, and the actuator cannot observe either: it holds only the adapter and
repause_at, never the machine.LoadAnswered's Failed/AlreadyRunning/Terminal arms,after_loadnow runs after the state write.ParkFlight,suspend_bufferfeednow runs after the park.Tests
every_state_meets_every_event_as_the_table_says: 12 rows over all 8 state kinds × 29 events. Every cell pinsHandled, the next state, the exact effects in order andnext_id. An unlisted cell must be "unchanged, no effects,No".play_off_player_is_one_event.foreground_flight_tests.rs, the claim_hold suspend tests and the app'slifecycle_regression_testschanged only in spelling or added assertions; no expectation changed.ParkthenDidForegroundthrough a test-onlyRefusedLoadactuator to reach the samePrepared{id:1, 0, Paused}, and asserts that state.Gates, run on the committed tree
make checkplx_media1708 passed (default features), 1869 passed (hostsim); notest result:line reports a failure.make check-nodefmake check-replayverdict=SAME, every*_diffs=0; no fixture changedmake(ARM, tvdev)Review
One review, verdict MERGE. It mapped every deleted mutator and its call sites on main to the replacing event, and found the same state, effects and IO order apart from the two reorderings above. It also checked the driver loop's id matching and its release-build fallbacks, and confirmed no test expectation changed.
Device check
The PR head's binary ran on the dev TV: a mock server (
version=…-synthetic,owned=1) with an H264 direct play. The running exe's md5 matched the local build.play=999..1000pm).SMP: calling Loadappears twice in the log, for the first play and the restore.WARN.turnOnScreenSaver(Invalid State change RequestfromScreen Off).getPowerStatereadScreen Saver), but the pipeline did not take the decoder back within about 80 s. There was notype=18callback, so nothing parked and the press restore was not exercised.park_playback→Parkstep the background run exercised.a_decoder_released_by_the_pipeline_parks_until_the_next_press_restores_it(hostsim, realEngine) passes.GStreamer-CRITICAL … still has a parentlines atsf_destroyalso appear in a day-old release build's stderr on the set, so they predate this change.Follow-up (separate PR): move the transport readers and drivers out of
lifecycle.rs, extend the ledgers and widen thewallgate.🤖 Generated with Claude Code