Skip to content

Metadata Related tail windows emit a store job; the runner resolves the client - #1102

Merged
GLinnik21 merged 7 commits into
mainfrom
sansio/store-jobs-metadata-m3
Oct 28, 2026
Merged

GLinnik21 merged 7 commits into
mainfrom
sansio/store-jobs-metadata-m3

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Closes #1101

The Detail page's Related row no longer starts the Metadata store's own worker for its tail windows, and the window read no longer reads the server registry. Each edge or seek ask leaves as a typed StoreJob::MetaRelated, which the app's StoreRunner starts with the client it resolved at launch. This is the third Metadata PR of the Sans-IO series (docs/sans-io.md, "The store job lane").

What changed

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

  • StoreJob::MetaRelated(Job<MetaRelatedReq>, MetaRelatedPort) is addressed by the window's send sequence (related_addr(seq), the same id space as season_addr).
  • It is Direct and belongs to StoreId::Metadata. A controlled run never emits it, because bootstrap/effects.rs has no related arm. No fixture records it, and the fixtures are unchanged.
  • ask_related keeps every guard and the claim block as before. Inside the claim it bumps rel.sent and pushes the job where it used to call spawn_small.
  • The body finish_related_job reads through M2's read_through guard, so a panicking read lands as a failure. The answer is posted outside the guard.
  • MetaRelatedPort::done lowers the claim, and it drops the answer of a withdrawn read. refused lowers the claim and clears withdrawn in the refusing call.

The client:

  • The window read (read_row over tail_page) takes the &'static Client the runner resolved. The runner captures it once, on the main thread, at launch; on main it was resolved inside the worker.
  • A read keeps its client for its few 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 window: None without a GET, which is what client_for(sid)? inside the worker gave.

Refusal (S2). A refused job leaves what a failed start leaves on main: the claim is lowered in the refusing call, and the next edge asks again (related_addr(2)).

Drains (S3). Every path to ask_related is Bridge::metadata_run, from the Detail screen's WantRelated / SeekRelated effects, and that already drains Metadata right after its step. Only screens/detail/mod.rs builds those commands outside tests. No bare-store caller and no fan-out reaches it; ViewState's closures send Metadata only ApplyView, and pump_related_pages emits nothing. No drain was added. the_bridge_metadata_run_starts_the_related_window_it_emitted pins it.

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

  • start_meta_related / launch_meta_related are new, in the file's start_* / launch_* shape. The Live arm calls client_for(job.req.sid) once and starts spawn_small("related-tail", ..).
  • The arms are in start, admit_home and run_held_where. retire_parked_details keeps a parked Related job. Its doc now says why: the pump's item check rejects its landing, and it holds the single-flight claim until it runs, as a worker still reading would.

The test runner. held() and held_all() both park MetaRelated, and LiveKind is unchanged. No app rig waits on a Related landing through a real worker: detail_related_landing_tests.rs lands the window with land_related_for_test.

Shared test support:

  • Pms::serve_query (bridge_test_support.rs) hands the loopback closure the query string too, so it can honour the pager's X-Plex-Container-Start/Size. Pms::serve is now a thin wrapper over the same spawn.
  • start_related_jobs() (metadata_test_support.rs) copies M2's start_season_jobs.
  • related_claim_for_test and related_landed_for_test are read-only seams beside detail_inflight_for_test.

Ledgers

Before After
ci/allow/workers/data-metadata.txt 2 1 (ask_related::spawn_small gone)
ci/allow/globals/data-metadata.txt 6 5 (ask_related::client_for gone)
PINNED_LEDGER_TOTALS (workers/globals/forks/fxlanes) 9/66/58/11 8/65/58/11

No ledger line was added or edited. M4's request_alt_sources worker line and its five globals lines remain.

Tests

Fails-first. 4365642 was committed first and run red on the base. An edge ask and a seek ask each leave their request on the outbox and start no worker:

test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 1246 filtered out; finished in 0.01s

New tests in metadata_related_job_tests.rs, one for each claim path:

  • start;
  • refuse (the next edge asks again);
  • withdrawn, then landed;
  • withdrawn, then refused (no stale withdrawal);
  • a cancel while parked discards the answer when it runs;
  • a panicking read lands as a failure and releases the claim;
  • no client answers the failure;
  • a job emitted before a Reset answers into the retired adapter.

The existing adopt and withdrawn-read tests still pass unchanged. Nine call sites in metadata_related_tail_tests.rs start their jobs through start_related_jobs, and no assertion was weakened.

Runner tests (adapters/stores.rs):

  • live, answered once with its window landed, and not taped;
  • launched live under replay;
  • no client answers the failure;
  • held, then run once;
  • held, with the client gone by then;
  • the Bridge drain test.

The client tests serve Pms::serve_query(related_listing), a loopback that answers. A worker handed the client lands a window past (0, 24), and one handed none lands a failure. Each strengthened assertion was mutation-checked on the committed tree and turned red, then reverted:

  • client_for → None in the Live arm;
  • the same in the run_held_where arm;
  • a replay early-return in launch_meta_related;
  • the Live arm returning false for a missing client;
  • refused without rel.withdrawn = false;
  • done returning before the landing push.

Not forced by a test. The OS refusing the thread cannot be forced on a host. The refusal is pinned at the port (a_refused_related_job_gives_the_claim_back_and_the_next_edge_asks_again, a_withdrawn_then_refused_related_job_leaves_no_stale_withdrawal), and the arm is a three-line copy of start_meta_season and start_meta_episodes.

Targeted suites at 29e0933 (main has not moved since the base, 944d9c2):

make test-crate C=plx_data
test result: ok. 1256 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 12.51s
make test-crate C=plxnative-modules
test result: ok. 1067 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 25.49s
make test-hostsim T=return_hold
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 1176 filtered out; finished in 0.15s
make test-hostsim T=lifecycle
test result: ok. 88 passed; 0 failed; 0 ignored; 0 measured; 1094 filtered out; finished in 3.68s

The two ledger harness tests are OK, and ci/check-deps.sh is 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 MERGE, with four notes and no blocker:

  • N1: three runner tests could not tell a launch from a refusal, or a dropped client from a missing one. They now serve the loopback and assert the landing, mutation-checked as above.
  • N2: the data-level no-client check was vacuous on an empty mailbox. It now asserts one landing first.
  • N3: the refused-launch arm has no runner-level test, as stated above.
  • N4: retire_parked_details now says why a Related job is kept.

Doc-claim audit. The writer fixed every inventory that named the M2 kinds:

  • docs/sans-io.md, in five places, and docs/stores-as-machines.md;
  • the runner's module doc, held() and Held;
  • Bridge::metadata_run and the stores/metadata.rs //!;
  • the docs of the jobs field, pages_addr, read_through, ask_related, cancel_related and land_related_for_test;
  • the detail-chain note that said ask_related resolves its client inside its worker.

An independent audit afterwards found no contradictions.

Live path

Checked in the macOS simulator at a 960x540 window against a fresh tests/mock_pms.py --seed 1 --movies 120, with plex.tv and Discover pointed at the mock and a placeholder token. The identity lines, read before any key, were version=1.41.0.0000-synthetic and owned=1.

The app booted into movie 1001's Detail page with focus on the Related row, and 125 right presses walked to the last card. The mock read /library/metadata/1001/similar nine times, at nine distinct start offsets: 8, 31, 43, 55, 67, 79, 91, 103 and 115. Each window was read once, with no repeat. The row grew from the 8-card head to the end of the listing, there was no stores: WARN and no panic, and the reads went through the production Live arm.

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

Not in this PR

  • The alternate sources and the dev stand-ins (M4: request_alt_sources, the alt pruning).

🤖 Generated with Claude Code

GLinnik21 and others added 7 commits October 28, 2026 12:24
…e job

An edge ask (WantRelated) and a seek (SeekRelated) are expected to leave one request on the outbox with the single-flight claim up and no worker started. Both fail on the base: the ask starts "related-tail" itself, so the outbox is empty.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ner resolves the client

A Related row's tail window read (an edge ask or a seek) no longer starts the Metadata store's own worker, and its body no longer reads the server registry.

The step takes the single-flight claim, as before, and leaves a StoreJob::MetaRelated on the outbox: Direct, StoreId::Metadata, the request carrying everything the worker closure captured (sid, rk, ask, the window it starts from with its cards, the keys to skip, the hubs, the ledger, the view-state stamp). The app's StoreRunner resolves the server's client once at the launch and runs finish_related_job on a worker; a server with no client still launches and its body answers the failure without a GET. The held test runner parks the kind.

The port settles the claim: done lowers it and lands the window unless the reader withdrew the read; refused lowers it and the withdrawal with it, in the call that refuses, which is where the inline !spawned arm gave it back. A body that panics lands as a failure, posted outside the guard.

One worker line and one client_for line leave the data-metadata ledgers, and PINNED_LEDGER_TOTALS goes workers 9->8, globals 66->65. The existing related tests that drive the store directly start their jobs through start_related_jobs, as the season tests do.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…anches, panic and withdrawal

Data level: the exact request an edge ask and a seek emit, a refused job giving the claim back in the refusing call with the next edge asking again, a withdrawn-then-refused job leaving no stale withdrawal, a withdrawn job's answer dropped, no client answering the failure without a GET, a panicking body landing as a failure, and a job emitted before a Reset answering into the retired adapter.

Runner level, against a loopback that answers the pager (Pms::serve_query hands its closure the query, so the X-Plex-Container-Start/Size window is honoured): started and answered once and not taped, launched live under replay, no client, held park-and-run, held with the client gone, and a cancel while parked. The Bridge entry test now also covers the Related ask and seek.

The held runner parks the kind (held() and held_all()): no rig in the app, screens or hostsim tests waits on a Related landing through a real worker, so no LiveKind is added.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
docs/sans-io.md gains the Related window under "The Metadata reads" (the claim, the request, the capture-at-launch client, the port's settle of the claim, the return value, the drains and the held-runner choice) and names the kind in the admission and held-runner inventories. docs/stores-as-machines.md, the Metadata wrapper's WantRelated/SeekRelated entries, the jobs field, the shared-address note, the ask/cancel/test-seam docs, the runner's module and held() docs and Bridge::metadata_run's doc say the read is a job now. The detail chain's note that ask_related resolves its client inside its worker, which was the reason it stayed on the globals ledger, no longer holds and is replaced.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…usal; retire_parked_details says why a Related job is kept

N1: the replay test serves a listing that answers and asserts the window slid past where it stood,
so a launch that was refused, or one that dropped the client, no longer passes it. The no-client and
client-gone tests count the answers waiting in the mailbox (a new test seam, related_landed_for_test)
and assert exactly one failure landed: a refusal gives the claim back too and lands none.

N2: the data-level no-client test asserts one answer landed before it checks that none is a window,
so an empty mailbox no longer satisfies "a failure, not a window".

N4: the retire_parked_details doc says what a newer Detail request does to a parked Related job.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…oc paragraphs the Related job touched are re-wrapped

read_related_window derived `before` and `start` from two matches over the same `ask`; one match
yields both. Behaviour is identical (a seek reads from half a window before its position and never
reads backwards; an edge reads from the window's start or end by its direction). The doc paragraphs
this branch edited (read_through, pages_addr, the detail chain, the runner's module and Held docs,
Bridge::metadata_run) had lines left over-long or ragged by the edit; they are re-wrapped, words
unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 9cab21e into main Oct 28, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the sansio/store-jobs-metadata-m3 branch October 28, 2026 10:38
GLinnik21 added a commit that referenced this pull request Oct 28, 2026
Metadata M3 (#1102) landed first: the ledger sums are 7/64/58/11 (workers 8 -> 7,
globals 65 -> 64) and PINNED_LEDGER_TOTALS follows.

Co-Authored-By: OpenCode <[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 Related tail: emit a store job the runner starts with the client it resolved

1 participant