Skip to content

Metadata season switch and episode pages emit store jobs; the runner resolves the client and the detail chain is one-client - #1023

Merged
GLinnik21 merged 9 commits into
mainfrom
sansio/store-jobs-metadata-m2
Oct 24, 2026
Merged

GLinnik21 merged 9 commits into
mainfrom
sansio/store-jobs-metadata-m2

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1022

A show's season switch and its episode row's page windows no longer start the Metadata store's own workers, and their fetches no longer read the server registry. Each read leaves as a typed store job that the app's StoreRunner starts:

  • a season switch is a StoreJob::MetaSeason;
  • an episode window is a StoreJob::MetaEpisodes.

The runner resolves the show's client once at launch and hands it to the body. The detail chain's opening season now uses the chain's own client, so the chain (#1013) is one-client end to end. This is the second Metadata PR of the Sans-IO series (docs/sans-io.md, "The store job lane").

What changed

The jobs (data/src/metadata.rs, data/src/stores/{metadata,mod}.rs):

  • StoreJob::MetaSeason(Job<MetaSeasonReq>, MetaSeasonPort) is addressed by the season generation.
  • StoreJob::MetaEpisodes(Job<MetaEpisodesReq>, MetaEpisodesPort) is addressed by the window's send sequence.
  • Both are Direct and belong to StoreId::Metadata. A controlled run never emits them, because bootstrap/effects.rs has no LoadSeason / WantEpisodes arm. No fixture records them, and the fixtures are unchanged.
  • The bodies finish_season_job / finish_episodes_job share one guarded read, read_through. The catch_unwind guard stays in the body, and the landing stays outside it.
  • A page job posts each page as it is read, through MetaEpisodesPort::page, and done is the terminal. The restore page on a return to episode 130 of 300 still seats after one GET, not after every page of the job.

The client:

  • fetch_episodes(client, season_rk) and fetch_episode_page(client, season_rk, page) take the &'static Client the runner resolved.
  • load_show_seasons passes the client it already holds. The "bar the opening season's episodes" caveats from Metadata detail chain runs its GETs through the client the runner resolved #1013 are gone, and the show test is flipped: a server re-pointed mid-chain now sees nothing.
  • The client is captured on the main thread at launch, the same rule as the detail chain in Metadata detail chain runs its GETs through the client the runner resolved #1013. A sign-out or a re-point between the launch and a GET keeps the captured client, and a page job keeps it for up to four serial GETs. After a sign-out the registry blanks the token, so those GETs come back as failures, as before.
  • A server with no client still launches, and the body answers the failure without a GET.

Refusal (S2). A refused job leaves what a failed start leaves on main:

  • Season: the port settles season_done up to the job's generation with fetch_max, never down. So a stale refusal after a newer landing cannot turn season_loading() back on. The tab stays on the flipped season, and the old episodes stay listed.
  • Pages: the port drops the job's in-flight keys, so the next WantEpisodes asks for the same pages again.

Drains (S3):

Path Drain
the Detail screen's LoadSeason / WantEpisodes effects → Bridge::metadata_run already drained there
the play-season menu's bare-store press (input.rs, menu_play_tick) bridge.start_store_jobs() on the next line
Bridge::metadata_pump_season start_store_jobs_of(Metadata) after its step: a guard, since no pump emits these today

ViewState's fan-outs send Metadata only ApplyView, so no fill list changes.

The runner (app/adapters/stores.rs):

  • start_meta_season / launch_meta_season and start_meta_episodes / launch_meta_episodes are new.
  • The arms are in start and run_held_where. retire_parked_details keeps both kinds, and the comment there says why.

The test runner:

  • held() runs MetaSeason live, because menu_play_season_tests polls for a real season landing. It parks MetaEpisodes, since no rig waits on a page landing through a worker.
  • held_all() parks both.
  • The live set is keyed by job kind (LiveKind { Hubs, MetaSeason }), because Metadata's Detail kind must stay parked.

Ledgers

Before After
ci/allow/workers/data-metadata.txt 4 2 (load_season, want_episodes spawn_small gone)
ci/allow/globals/data-metadata.txt 8 6 (fetch_episodes, fetch_episode_page client_for gone)
PINNED_LEDGER_TOTALS (workers/globals/forks/fxlanes) 14/75/58/11 12/73/58/11

No ledger line was added or edited.

Tests

Fails-first. 8ceb3d3 was committed first and run red on the base:

  • the show chain keeps one client (on the base, server B saw /children);
  • a season switch and an episode window each leave a request on the outbox and start no worker (on the base, a worker started).

New tests in metadata_season_job_tests.rs:

  • emit tests for each kind;
  • a refused season ends season_loading() and keeps the tab and the list;
  • a stale season refusal does not re-arm loading (mutation-checked: fetch_max → store fails it);
  • a season or page job with no client answers the failure;
  • a panicking season or page read lands as a failure;
  • a refused page releases its keys, and the next window asks again;
  • a_page_job_lands_each_page_as_it_is_read. It read [(2, []), (1, []), (3, [])] before the per-page post and [(2, []), (1, [2]), (3, [2, 1])] after.

Runner tests, per kind:

  • started and answered once, and not taped;
  • launched live under replay;
  • with no client, it answers the failure;
  • the held() / held_all() behaviour;
  • a newer detail request leaves parked season and page jobs to run;
  • three Bridge drain tests.

The client tests dial a loopback server that answers. Replacing the client with None on each branch (season Live, page Live, both run_held arms) turns that branch's own test red.

Not forced by a test. The OS-refusal branch (spawn_small returning false) is not forced by a runner test. A host has no failure knob for it, as the Search lane records. The refused outcomes are pinned at the port.

Targeted suites at 14a8477, which merges main at 19048ea. The last commit is one doc comment.

  • plx_data: 1228 passed, 0 failed.
  • the app crate: 1025 passed, 0 failed.
  • plx_media: 1744 passed, 0 failed.
  • hostsim, return_hold: 6 passed, 0 failed.
  • hostsim, lifecycle: 86 passed, 0 failed.
  • The ledger tests and ci/check-deps.sh are green.

Gates

This PR's CI is the gate for make check, check-nodef, the replay fixtures and the ARM build. They were not run locally.

Review. One review, verdict FIX FIRST, with one should-fix finding and four notes, all handled:

  • F1: the runner's client tests dialed a dead port, so they could not fail on a dropped client. They now serve a loopback and assert the landing, mutation-checked as above.
  • F2: a multi-page job landed every page at once. Each page now lands as it is read, and a test pins it.
  • F3: one test reached the season pump's guard instead of pressing as the dispatcher does. It now presses through metadata_run.
  • F4: the page, season and Detail jobs can share an Addr. This is now noted on pages_addr, since nothing routes by Addr alone.
  • F5: capture at launch, stated above.

Doc-claim audit. It found seven sentences made false, and all seven are fixed here:

  • the season landing is gated, and only the page landing is an ungated take;
  • the admission lists in docs/sans-io.md and the runner's module doc;
  • the runner's module doc on held(), and the StoreRunner::Held doc;
  • the Bridge::metadata_run doc and the MetadataState::jobs field doc;
  • a comment in request_play_inner (media/src/route/decision.rs) that named load_season.

Live path

Checked in the macOS simulator at 960x540 against tests/mock_pms.py --seed 1 --shows 2 --seasons 3 --episodes 150, with plex.tv and Discover pointed at the mock and a placeholder token. It was a mock-only run, driven with the remote keys on show 2002.

  • Opening the show read 20021/children start=0 size=60 once, through the detail chain's one client.
  • Each season switch read /library/metadata/<season>/children start=0 size=60 exactly once. A left and right revisit read each season once more.
  • Paging season 3 read start=60 once and start=120 once, with no repeat.
  • The season strip and the episode row updated on each switch. There was no stores: WARN and no panic.

This is host-simulator evidence only, with no TV claim. No drawing code or FFI changed.

Not in this PR

  • The related-items read, the alternate sources and the dev stand-ins (M3, M4).

🤖 Generated with Claude Code

GLinnik21 and others added 9 commits October 25, 2026 00:14
…s and the one-client show chain

The detail chain's show test now expects the opening season's episodes on the server the chain was handed (the other server sees nothing), and a season switch and an episode-page window are expected to leave a request on the outbox instead of starting a worker. All three fail on the base.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… runner starts; fetches take the client

load_season and want_episodes no longer start workers: each pushes a typed StoreJob (MetaSeason,
MetaEpisodes, both Direct) on the Metadata outbox, and the app's StoreRunner starts it with the client
it resolved for the show's server at the launch. fetch_episodes and fetch_episode_page take that
client, so the detail chain (load_show_seasons passes the one it holds) is one-client end to end.

A refused season job catches season_done up with fetch_max (a stale refusal never re-arms
season_loading); a refused page job drops the inflight keys it held, so the next window asks again.
A server with no client at the launch answers the failure without a GET. input.rs drains the bare
store's season job in the call that emitted it; metadata_pump_season drains Metadata after its step
(a guard: no landing pump emits a job today).

Deletes the four ledger lines (workers 4 -> 2, globals 8 -> 6; pins 14/76/58/11). The held test
runner runs the season switch live (menu_play_season_tests waits on a real landing) and parks page
jobs, keyed by job kind.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…jobs and the detail chain is one-client

sans-io.md gains the "Metadata reads" bullet (kinds, client resolution, refusal states, page batching,
drains) and drops the "bar the opening season's episodes" caveats; stores-as-machines.md and the
Metadata module docs name the jobs instead of an off-thread fetch.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…at answers; the superseded-season test presses as the dispatcher does

F1: every M2 runner test dialled a dead port, where a worker handed the client the
runner resolved and a worker handed none both landed the failure. The four tests
that claim the client was handed over (the season and page jobs under Live, and
their held-run arms) now register the slot against a loopback that answers
/children and assert the landing: the season stays on the new tab with its
episodes listed, the page is seated. Each of the four branches (the page Live arm,
spawn_meta_season, and the two run_held arms) was mutated to hand over None and
failed its own test.

F3: a_superseded_season_landing_plays_nothing left its MetaSeason job on the
outbox, and only the guard drain in metadata_pump_season started it. It now runs
the press through Bridge::metadata_run, as the dispatcher's StoreCmd::Metadata
arm does, so it no longer depends on the pump guard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the shared id space is noted

F2: the page job answered once with all its pages, so the restore page a window
asks for first waited on every later GET of the job (restoring episode 130 of a
long season asks for pages [2, 1, 3]; on a relayed server the hole stayed two
round trips longer). The body now posts each page through MetaEpisodesPort::page
as it is read, as the inline worker pushed it, and ends the job with the one
done, which carries nothing (the S7 shape: many posts, one terminal). Fails
before the change (a_page_job_lands_each_page_as_it_is_read saw [(2, []), (1, []),
(3, [])]), passes after. The landing is still ungated (decision 7).

F4: pages_addr documents that page, season and Detail jobs share one Addr id space.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The doc-claim audit of the M2 branch found seven sentences the change made false:
the season landing is gated (only the page landing is an ungated take), the
Direct inventory and the runner module doc omit the two new kinds, the module
doc's description of held() omits the live season switch, the Held doc omits that
a season or page job carries no key, Bridge::metadata_run's doc omitted the
Bridge-holding bare-store caller (menu_play_tick), the MetadataState::jobs doc
names only the Detail job, and a comment in route/decision.rs points at
load_season's retired catch_unwind.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the Browse B-A section-hubs job and the other changes main gained
since fba7a81 (#1017, #1021, #950). Five files conflicted and every one
keeps both sides: the Direct arm of StoreJob::admission() lists BrowseHubs,
MetaSeason and MetaEpisodes; the runner and the Held docs name both the
Browse and the Metadata kinds; bridge.rs's late-job messages name every
drain of both stores; docs/sans-io.md numbers Metadata as the tenth store;
PINNED_LEDGER_TOTALS is the real sum of the # count: headers (the textual
merge produced a wrong-looking pair).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ge job takes one lock

Behaviour-identical cleanups of the M2 job code. `finish_season_with` and
`finish_episodes_with` each spelled the same "no client is no GET, a panic
is a failure" read, now `read_through`, so the invariant is stated once.
`want_episodes` took the page mailbox's lock twice, rebuilt each key a
second time for the port and cloned the season once per page for the
inflight list; it now takes the lock once and builds each key once.
`MetaEpisodesPort::page` compared a freshly cloned key against every
inflight entry; it compares the fields instead.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 84a780d into main Oct 24, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the sansio/store-jobs-metadata-m2 branch October 24, 2026 22:36
GLinnik21 added a commit that referenced this pull request Oct 24, 2026
Conflicts, all of the "keep every arm of both sides" kind:
- data/src/stores/mod.rs: StoreJob gains ViewWrite beside MetaSeason and MetaEpisodes, and all
  three are Direct in admission().
- app/adapters/stores.rs: start, admit_home, retire_parked_details and run_held_where take the
  ViewWrite arm and the two Metadata arms; the module doc names both lanes.
- docs/sans-io.md: Metadata M2 is the tenth store on the job lane and the view-state writes the
  eleventh; the fan-out drain list and the admission list name both.
- tests/test_harness.py: PINNED_LEDGER_TOTALS recomputed from the # count: headers at the merged
  tree: workers 11, globals 68, forks 58, fxlanes 11 (the comment lines of both sides kept).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Oct 24, 2026
Metadata M2 (#1023) and ViewState (#1026) landed after the base. Both lanes and this one
added their own test-only LiveKind, took PINNED_LEDGER_TOTALS down from the same base, and
extended the same exhaustive StoreJob matches.

- LiveKind = {Hubs, MetaSeason, BrowsePage}. held() runs all three live, so the season
  switch stays live for menu_play_season_tests and the page read for the library route
  rigs and session_dispatch_tests. park_page_reads() sets {Hubs, MetaSeason}: it parks
  only the page read. held_all() stays [].
- Every StoreJob match in adapters/stores.rs (start, admit_home, retire_parked_details,
  run_held_where) lists both lanes' kinds.
- PINNED_LEDGER_TOTALS = workers 9, globals 66, forks 58, fxlanes 11, recomputed from the
  `# count:` headers of the merged tree (main is 11/68; this lane takes 2 and 2), with
  every lane's comment kept.
- docs/sans-io.md and the stores.rs //! paragraph carry every lane's prose.
- Review notes N2 (the /// docs that named only the section-hubs read now also name the
  directory or page read) and N3 (one sentence: an Addr is not an identity across kinds).

Co-Authored-By: Claude Sonnet 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.

Metadata season switch and episode pages: emit store jobs started by the runner with the client it resolved

1 participant