Skip to content

Metadata detail chain runs its GETs through the client the runner resolved - #1013

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

GLinnik21 merged 8 commits into
mainfrom
sansio/store-jobs-metadata

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Closes #1012

The Metadata detail chain no longer asks the server registry for its client before each GET. StoreRunner::start_detail resolves the client once, at the admission, and finish_detail_fetch hands it to fetch_full and on through the chain. Collection, Person, Hubs and subtitle search already work this way (#987, #990, #996, #1011). This is wave 4, step M1 of the Sans-IO series (docs/sans-io.md, "The store job lane").

What changed

The chain (data/src/metadata.rs):

  • finish_detail_fetch(port, addr, key, client: Option<&'static Client>, fetch) takes the runner's client. With none, it logs, lands None and never calls fetch.
  • These fetches take client: &'static Client:
    • fetch_full, fetch_detail and fetch_item_streams;
    • fetch_seasons and load_show_seasons;
    • fetch_primary_trailer and resolve_trailer;
    • fetch_extras_rows, which moves the client into its scoped detail-extras thread;
    • project_extras and fetch_related.
  • Their eight client_for reads are gone.
  • The one read left in the chain is the opening season's episodes (fetch_episodes). The season worker shares it, and M2 moves it.

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

  • start_detail makes the one client_for(sid) call. The tape admission is built from client.map(instance_gen), so the recorded bytes are the same as before.
  • launch_detail is handed that client.
  • The test-only Held arm resolves its own client when the held job runs.

fetch_playing_item(client, sid, rk, want): its caller, build_stream in media/route/plan.rs, already holds the client and now passes it. build_stream's own client_for line on ci/allow/globals/media.txt stays.

No key compare: DetailReq carries no ClientKey. Its step reads no registry, so the runner's one read is a presence check, not the key compare that Collection, Person and Hubs make. A server the registry holds no client for still launches, and its worker answers the failure without asking anything, as the old chain's first read did. The plan was to refuse such a job at launch instead. That broke seven app tests that park Detail jobs against unregistered servers, so it was dropped.

What a sign-out or a re-point does to a page in flight

The old chain re-resolved its client before each GET:

  • after a sign-out, its later GETs found no client and landed None;
  • after a re-point, they went to the slot's new client and finished.

This chain keeps the client it was handed. On both events the registry blanks that client's token in place (revoke_all, and the re-point arm of register_lazy), so the rest of the chain is sent tokenless, is refused, and lands None:

  • Sign-out: same outcome as before. The GETs are now sent and refused where they used to be skipped.
  • Re-point: a page with its hero but empty seasons, streams, extras, trailer and related, where the old chain went on to the new client. Bar the opening season's episodes, one page never mixes two clients.
  • Same-origin retoken: this updates the held client in place, so it is the one event a chain finishes through.

Ledgers

Before After
ci/allow/globals/data-metadata.txt 16 lines 8 (the client_for lines of the eight functions above deleted)
PINNED_LEDGER_TOTALS (workers/globals/forks/fxlanes) 18/90/58/11 18/82/58/11

No ledger line was added or edited. The eight left in data-metadata.txt are M2-M4's: fetch_episodes, fetch_episode_page, ask_related and the alternate-source reads.

Tests

  • metadata_detail_client_tests.rs, five tests against two loopback servers, A and B. Each test registers the slot at A, takes the client, then re-points the registry at B or empties it. What each pins:
    • a movie chain makes all its GETs (metadata, /extras, /related, trailer) to A, and B sees none;
    • a refused /extras falls back to the primary trailer through the same client;
    • a show chain sends B only /library/metadata/<show>/children, M2's fetch_episodes;
    • an emptied registry neither redirects nor skips the chain;
    • fetch_playing_item reads through the caller's client.
  • The test of the change: with the old per-fetch client_for restored, all five fail.
  • A mailbox test pins that a detail job with no client answers the failure and asks nothing.
  • Targeted suites at 15823bb:
    • plx_data: 1196 passed, 0 failed;
    • plx_media: 1729 passed, 0 failed;
    • app: 989 passed, 0 failed;
    • hostsim: plx_media 1891 passed, plx_data 1196 passed, and app return_hold 6 and lifecycle 86 passed, all with 0 failed.
  • Ledger gates: the ledger tests and ci/check-deps.sh are green.
  • Final commit: it rewords two comments only, and plx_data's detail_client tests pass on it.

Gates

This PR's CI is the gate for make check, check-nodef, the replay fixtures (simulators.yml replays every committed fixture on a rust-modules/** change) and the ARM build. None of them was run locally. metadata/record.rs and tests/fixtures/replay/ are untouched.

One review, verdict FIX FIRST, with three should-fix findings:

  • The semantic change was mis-stated. The first draft said a sign-out or a re-point lets the chain finish. Both blank the held client's token, so it does not. The prose is fixed in the docs, the doc comments, the runner comments and the test header, and the section above states the corrected behavior.
  • "The first worker body to take its client as an argument" was false. Collection, Person and Hubs came first. Fixed.
  • "make check-replay must run" is a false positive. CI replays the fixtures (above).

Three notes are also fixed: a test name and its header no longer claim the rig models a sign-out, a runner comment is reworded, and the runner's module doc states the Detail exception. One note is left for a follow-up: pinning the runner half of the capture in an app test.

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

  • the sign-out and re-point claim, in docs/sans-io.md, the finish_detail_fetch doc and the test header;
  • "first worker body";
  • "every GET goes to the server the runner resolved", in docs/stores-as-machines.md and two comments, which now say "bar the opening season's episodes";
  • the fetches' section comment, which said every fetch takes a ServerId;
  • "what ask_related already does": ask_related resolves its client inside its worker, which is why it is still on the ledger.

Live path

Detail pages were checked in the macOS simulator against tests/mock_pms.py --seed 1, with real key navigation. It was a mock-only run with no real account, on a non-test build, so the fetch went through StoreRunner::Live.

Page GETs the mock saw, one of each Result
Movie, rk 1001 metadata/1001, /related, /extras landed, 8 related
Show, rk 2006 metadata/2006, /children, 20061/children (the opening season's episodes), 200611 (first-episode streams), /related, /extras app log seasons=2 eps=6 related=5; page drew 2 seasons
Episode, rk 200413 one metadata, one /related landed

No page re-asked. This mock's /extras is empty, so extras and trailers could not be shown. The run was at ec1b67b, before the main merge, which touched nothing the chain runs through. This is host-simulator evidence only, with no TV claim. No drawing code or FFI changed.

Not in this PR

  • M2-M4: the season and episode workers, ask_related, and the alternate-source reads.
  • A rig that records the token header, to assert that a re-pointed chain asks tokenless. The loopback server strips the query and does not record headers.

🤖 Generated with Claude Code

GLinnik21 and others added 8 commits October 24, 2026 21:03
…esolved

The detail job's chain no longer re-reads the server registry in every sub-fetch. StoreRunner::
start_detail reads client_for(sid) once, records that client's instance in the tape admission as it
always did, and hands the very client down: finish_detail_fetch(port, addr, key, client, fetch)
calls fetch(client), and fetch_full, fetch_detail, fetch_item_streams, fetch_seasons,
fetch_primary_trailer, fetch_extras_rows (and its scoped thread), resolve_trailer, project_extras
and fetch_related take it as a parameter. fetch_playing_item takes the client its caller
(route/plan.rs build_stream) already holds. A server the registry holds no client for still
launches and lands the failure, as before; finish_detail_fetch answers it without calling fetch.

Semantic change, accepted: the chain used to turn every GET after a sign-out or a re-pointed slot
into None; it now keeps the client it was handed for the rest of its GETs (the capture-at-the-step
rule of pms::kick_with, and what ask_related does). The opening season's episodes
(fetch_episodes) still resolve their own client until the season worker moves.

Ledger: the eight data-metadata client_for lines (fetch_detail, fetch_playing_item,
fetch_item_streams, fetch_seasons, fetch_primary_trailer, fetch_extras_rows, resolve_trailer,
fetch_related) are deleted, the file's count goes 16 -> 8, and PINNED_LEDGER_TOTALS globals 90 -> 82.
The detail admission bytes are unchanged (same request JSON); replay never launches a job.

Tests: the pure chain tests and the panic test are handed a registered client
(metadata_test_support::offline_client); a job with no client answers the failure and asks nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Five tests on two loopback PMSes (rust-modules/data/src/metadata_detail_client_tests.rs). The slot
is registered against the first, its client taken as the runner takes it at the admission, and the
registry then moves on: the slot re-pointed at the second server, or emptied as a sign-out does.
fetch_full for a movie (extras with a trailer that needs its follow-up GET), a movie whose /extras is
refused (primaryExtraKey fallback) and a show (seasons, the stream backfill's episode, extras,
related) reach only the first server, whole; the signed-out movie finishes all four GETs; and
fetch_playing_item reads through the client its caller holds. The show test also pins what
deliberately did not move: the opening season's episodes (fetch_episodes) still resolve their own
client and are the one read the second server sees (M2 empties that list).

Checked against the old behaviour: with every sub-fetch asking client_for again, all five fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs/sans-io.md, "The store job lane": the detail fetch chain is the first worker body to take its
client as an argument (the eight client_for reads gone from data/src/metadata.rs, what the capture
changes about a sign-out halfway through, the opening season's episodes still resolving their own),
and a bullet for the Detail job, which carries no ClientKey and is resolved by presence once at the
admission. docs/stores-as-machines.md: the paragraph that says the stores still read client_for
names the chain as the exception.

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

The old chain re-resolved its client before each GET, so after a sign-out its
later GETs found no client and after a re-point they went to the slot's new
client. The chain keeps the client it was handed, and the registry blanks that
client's token on both events (revoke_all, and the re-point arm of
register_lazy): the tail asks tokenless and lands None. A sign-out ends as it
did (the requests are now sent and refused, not skipped); a re-point leaves a
partial page where the old chain followed the slot to its new origin. The docs
said the chain "finishes against the client it was handed".

Also: the chain is not the first worker body to take its client as an argument;
the Collection, Person, Hubs and subtitle-search bodies already do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The emptied-registry test no longer claims to model a sign-out (reset_servers_for_test
nulls the slot and blanks no token). The runner's header says the Detail job carries
no key, and the Held arm's comment says where a live job's client is resolved.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The chain asks no registry bar the opening season's episodes (fetch_episodes still
resolves its own client until M2), so the places that said it never asks again
now say so. A re-point sends the old chain to the slot's new client, not to its
"new origin". The detail-client test rig says it neither blanks a token nor models
a sign-out, and its repoint helper no longer names a credential change (a
same-origin retoken keeps the same client).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in #805 (player playback speed); no file it touches is one this lane
changed.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…k_related resolves in its worker

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit ef3e55a into main Oct 24, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the sansio/store-jobs-metadata branch October 24, 2026 19:30
GLinnik21 added a commit that referenced this pull request Oct 24, 2026
Main carries the Metadata (#1013) and Search (#1015) store-job lanes. Both sides' additions are
kept: StoreJob::Search, SaveRecents and BrowseHubs side by side in the enum, admission(), store(),
take_jobs_of/has_jobs_of, the runner's start/admit_home/retire/run_held arms, and the wall list
(search and section_hubs.rs). The Search and section-hubs bullets of docs/sans-io.md both stay
(Browse's is the ninth store on the lane). PINNED_LEDGER_TOTALS is the real sum of the '# count:'
headers at the merged tree: workers 14, globals 75, forks 58, fxlanes 11.

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.

Metadata detail chain: run its GETs through the client the runner resolved

1 participant