Skip to content

Detail store: request_detail emits a job; the app's StoreRunner starts it - #975

Merged
GLinnik21 merged 5 commits into
mainfrom
sansio/p2-detail-job
Oct 24, 2026
Merged

GLinnik21 merged 5 commits into
mainfrom
sansio/p2-detail-job

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Summary

Pilot P2 of the Sans-IO series (docs/sans-io.md). This is the first store to stop starting its own worker. request_detail (data/src/metadata.rs) used to call tape::admit, read client_for and run spawn_small("detail") itself, behind a cfg(test) held lane that answered superseded fetches inline. It now hands the work out as a value, and the app runs it. The interface is the one the remaining stores will copy.

  • The job:

    • plx_machine::job::{Job<R>{addr, req}, Port<T>, assert_fx!}, which names nothing above base;
    • StoreJob::Detail(Job<DetailReq>, DetailPort) in data/src/stores, where DetailReq is { sid, rk, prefer };
    • DetailPort holds the adapter Arc that was current when the job was emitted. A job emitted before a Reset still answers into the retired adapter, as the old Arc::clone did. The store keeps no handle to a retired adapter, so an id would need a registry.
  • The outbox: MetadataStore::take_jobs / has_jobs, aggregated as Stores::take_jobs / has_jobs. A store joins by giving itself an outbox. MetadataStore's Machine::step does not drain it; its owner does.

  • The runner: app/adapters/stores.rs StoreRunner { Live, Held }, chosen when the Bridge is built.

    • Live does main's production path line for line: the same tape::admit JSON, keys and order, the client_for read, spawn_small, and refused when not admitted.
    • Held is the test rigs' runner. It parks the job and answers a superseded parked job with None.
    • controlled_home always runs Live, and its rustdoc says so.
  • Drains:

    • Bridge::metadata_run is the store step followed by start_store_jobs(), and the dispatcher's StoreCmd::Metadata arm now calls it. So the tape admission is still recorded in the same call and position: after cancel_all's record, before any other tape request.
    • describe_movie drains explicitly.
    • metadata_pump_detail keeps a backstop that counts late jobs (late_store_jobs) and logs one warning.
    • Every test rig asserts, after every frame, that the outbox is empty and the counter is zero, so a sender that bypasses metadata_run is a red test. On its first run the check caught describe_movie (a movie's Play from the item menu), which had been relying on the backstop; it now drains explicitly.
  • The result path is unchanged: landing, gate, adapter_rank and both drain modes.

  • Ledgers: request_detail::spawn_small (workers), request_detail::client_for (globals) and the request_detail fork leave ci/allow/*/data-metadata.txt. request_detail_with_spawn becomes #[cfg(test)]. ci/module-layers.ini places job in [machine].

  • Docs: a "store job lane" section in docs/sans-io.md covers:

    • two drains: stepped machines emit through Effects, Bridge-run stores through take_jobs;
    • results return through the landing, not the FIFO, a deliberate exception that keeps the replay anchors;
    • why the job is not an AppFx effect: a new fxlanes site, controlled Home's fail-closed, and recorder churn;
    • the frame check and the Arc port.

    Plus docs/module-layers.md (held_detail is gone) and rustdoc.

No Makefile, Cargo or workflow change, and no file moved, split or merged, so no build-bench table.

Verification

  • a_superseded_detail_request_keeps_its_reservation_until_answered was written first. It failed on ae611ee: a pump with no answer in hand does not free the superseded slot / left: 1 / right: 2. It passes now.
  • Contract tests pin the emitted job (assert_fx!), that a request refused for capacity emits no job, and that the job captures prefer.
  • Runner tests cover Live under tape replay with admitted:false and admitted:true, Held superseding, and the frame check's two red cases. Three planted mutations (runner refusal removed, refuse everything, capacity early-return removed) each turned a test red.
  • a_job_emitted_before_a_reset_answers_into_the_retired_adapter pins the port.
  • make check on the committed merge head 1326115 (with main's 088f6f7 merged in): check: 106 steps — all ok.
    • plx_data test result: ok. 1136 passed; 0 failed.
    • plxnative_modules 936 passed; 0 failed (hostsim pass 1049 passed; 0 failed).
    • plx_screens 1698 passed.
    • Harness Ran 539 tests / OK.
    • check-deps: all gates green.
  • Ledger totals after the merge: workers 26 → 25, globals 102 → 101, forks 61 → 60, fxlanes 11. These were checked against the sum of every # count: header.
  • make check-nodef: clean.
  • make check-replay: 3 fixtures, 6 replays, 0 failures, all six verdict=SAME. Fixture 12-filmography-detail-return holds four recorded metadata admissions, so the replay runs the new runner's admission JSON. No fixture was re-recorded.

Closes #974

🤖 Generated with Claude Code

GLinnik21 and others added 5 commits October 24, 2026 06:56
request_detail keeps begin_detail_request (the supersede, the generation, the tape's cancel
record, the landing admission) and pushes a StoreJob::Detail(Job<DetailReq>, DetailPort) on the
owner's outbox; the application's runner starts it. plx_machine::job adds Job, Port and
assert_fx!. The held lane (held_detail, run_held_detail_fetches_for_test, and the inline answer
of a superseded fetch) is deleted: a superseded request now keeps its landing reservation until
its own answer arrives, as it does on the device. fetch_full and finish_detail_fetch become pub
IO bodies, and finish_detail_fetch answers through the port.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Bridge owns a StoreRunner chosen at construction (Live in production, Held in test rigs, as
ConsentAdapter::fixture() is). Live copies the old spawn's tape::admit request and worker; Held
parks the job after its admission and answers a superseded one, and
Bridge::run_held_store_jobs_for_test runs the parked ones on the test thread. Bridge::metadata_run
takes the jobs the store step emitted in the same call, and the dispatcher's Metadata arm goes
through it, so the tape's admission record follows the step's cancellation record with nothing
between them; metadata_pump_detail drains leftovers first, for describe_movie, which holds only the
store. The direct RequestDetail senders (input, playback, scenarios) call bridge.metadata_run.
The test rigs' frame helpers assert that no store holds an unstarted job, so a sender that bypasses
metadata_run is a red test. The eight run_held_detail_fetches_for_test callers use the Bridge
helper and two stale comments are fixed. plx_machine::job is placed in the machine layer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… document the lane

request_detail no longer starts a worker, reads the client registry or forks on cfg(test), so
its three ledger lines are stale: workers 5->4 and 27->26, globals 17->16 and 105->104, forks
4->3 and 62->61 (fxlanes stays 11). docs/sans-io.md gains "The store job lane" (the shape, the
two drains, why results still return through the landing, why the job is not an AppFx, the
stranded-job test check and why the port holds the adapter Arc); docs/module-layers.md and one
rustdoc stop naming the deleted held lane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The store job lane is the template eight later store PRs copy, so the review's findings land
before it does.

- play_item_now_with drains right after describe_movie (Bridge::start_store_jobs), so no
  production path relies on the detail pump's backstop and the tape admission is written where
  the request is made, as on main. The extra pump in the content.rs rig goes away.
- The backstop counts what it had to start late (Bridge::late_store_jobs) and logs one
  "stores: WARN" line. assert_no_store_jobs_left_for_test asserts the count is zero, so a sender
  that bypasses metadata_run is red in every rig that makes the check, the one that runs
  update()'s pump included. The route-test harness makes the check after each frame and each
  request pass.
- Stores::take_jobs / has_jobs aggregate every store's outbox: the drain and the rig check are
  written once and a new store joins in one place. Bridge::metadata_pump (test-only now) goes
  through the same counted backstop. Stores::metadata_run, MetadataStore's Machine::step and
  docs/sans-io.md say that the owner drains.
- request_detail no longer routes through request_detail_with_spawn, which is test-only now.
- Tests: StoreRunner under tape replay (admitted false and true, byte-for-byte admission, one
  refusal, nothing launched) and Held's superseded answer; the drain/bypass checks on a Bridge;
  the contract test pins that a capacity refusal emits no job and that the job captures prefer.
- Prose the lane made false: metadata.rs, bridge.rs, stores.rs, sans-io.md, job.rs (which now
  says what does and does not check "exactly one call per job"); controlled_home's rustdoc says
  it always runs Live.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One conflict, in tests/test_harness.py: both sides lowered PINNED_LEDGER_TOTALS. The merged
totals are the sums of the `# count:` headers under ci/allow/<rule>/ on the merged tree:
workers 25, globals 101, forks 60, fxlanes 11. rust-modules/src/app/bridge.rs auto-merged:
Bridge has one struct literal (with_publications_and_stores), which initialises P1's
cache_refresh_begun and this branch's store_runner and late_store_jobs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 591362f into main Oct 24, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the sansio/p2-detail-job branch October 24, 2026 05:55
GLinnik21 added a commit that referenced this pull request Oct 24, 2026
…input (#987)

The Collection store no longer starts a worker or reads the server registry from inside its step.
It emits a typed StoreJob::Collection that the app's StoreRunner starts, the lane the Detail store
took in #975; wave 1, store 1 of the Sans-IO series (docs/sans-io.md, "The store job lane").

Store-agnostic pieces every later store reuses: ClientKey { instance, token } names a client and
its credential, and ClientKeys maps servers to keys; the Bridge owns one buffer, refilled in place
by adapters::stores::refill_client_keys right before a store step (the only loop over the
registry). Fetch::release_for(gen) releases only that generation's claim. Stores::take_jobs_of and
Bridge::start_store_jobs_of drain one store, and each Bridge entry point drains only its own store
in the call that steps it, which keeps the tape's admission order. StoreRunner matches on the job,
and a newer Detail request retires only parked Detail jobs.

Collection: maybe_spawn claims the generation and pushes Job<CollectionReq> carrying the server
and the ClientKey the step chose; without a key it holds off RETRY_FRAMES. run, pump and
refresh_if_client_changed take &ClientKeys, so the three client_for reads are gone. The launch
resolves the client and starts the job only if the registry still answers that exact client;
otherwise it records "admitted":false and the port releases the claim. finish_collection_job runs
the IO under catch_unwind and answers through CollectionPort; CollectionAnswer is opaque.

Ledgers: data-collection's workers (1) and globals (3) files deleted; PINNED_LEDGER_TOTALS
25/101/60/11 -> 24/98/60/11. The wall gate scans data/src/collection.rs.

Tests: 10 step tests in data/src/collection_job_tests.rs (emit, stamp, no request without a key,
an observed hold-off); a registry-moved-on job is not started; store_admission_tests pins the
recorded admission literals and a person-then-collection frame's cross-store order, byte-equal on
main and on this branch. Fixture replays all SAME; the live runner loaded a Collection page's
header and members against the mock server in the macOS simulator.

Closes #984

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Oct 24, 2026
#990)

The Person store no longer starts workers or reads the server registry from inside its step. It
emits one typed StoreJob::Person per fetch slot, which the app's StoreRunner starts, the lane
Detail took in #975 and Collection in #987; wave 1, store 2 of the Sans-IO series, reusing #987's
ClientKeys input and per-store drains unchanged.

The step: maybe_spawn keeps the busy and retry_cd checks, the address, the plex.tv branch with its
session early return, the claim and the synchronous refused landing, then pushes a
Job<PersonReq>. A pump emits at most one job per wanted slot, in ascending slot order, up to the
fan-out width. A server read carries the server and the ClientKey the step chose; with no key the
step backs off RETRY_FRAMES without claiming. A plex.tv read (Profile, Credits) carries the
identity the step decided on: Controlled, or the settled session. Addr.req is a per-state wrapping
sequence; the slot and the person generation travel in PersonPort, and the tape's admission JSON
takes its gen from the request, so the recorded bytes are unchanged.

The runner: start_person admits through the tape. A server read starts only if ClientKey::of(c)
still matches the job's key; otherwise it records "admitted":false and PersonPort::refused
releases only that generation's claim. The Held lane re-resolves the client and refuses on a
mismatch, and a newer Detail request leaves parked Person jobs alone. finish_person_job holds the
old worker body: Controlled answers the failure value without a read, Settled runs
fetch_profile/fetch_credits under catch_unwind, a server job runs the Resolve, Media or Roles read
with its chunking kept, and a server job handed no client is refused. PersonAnswer is opaque.
Bridge::person_pump refills the keys, steps and drains StoreId::Person in one call, still before
Collection and the Detail reconciliation, so the cross-store admission order holds.

Not pure yet: the step still reads tape::active(), session::peek_settled(), the session watch, the
refused-discover landing, server_ids(), server_roster_gen() and, in dev-trigger builds,
devtrig::read("personcredits"); docs/sans-io.md lists them and claims no purity for Person.

Ledgers: data-person's workers (2) and globals (1) files deleted; PINNED_LEDGER_TOTALS
24/98/60/11 -> 22/97/60/11.

Tests: 10 step tests in data/src/person.rs (slot order and width, the no-key back-off, plex.tv
identity, unique addresses across a reset, a pre-reset port lands only into the old adapter, a
refusal releases only its own claim, the admission record in fixture 12's shape, a controlled read
without IO, a clientless server job refused); 7 runner tests in app/adapters/stores.rs; 2 Bridge
admission-order tests that pass on the pre-change tree and on this branch. The controlled-session
test now steps and pins the outbox empty. Fixture replays all SAME; the live runner loaded a
Person page's Media, Profile, Credits and batched Roles reads once each against the mock server in
the macOS simulator.

Closes #989

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21 added a commit that referenced this pull request Oct 24, 2026
…he step can observe (#996)

The subtitle-search and view-reconcile stores no longer start workers or read the server registry
from inside their step. Each emits a typed store job that the app's StoreRunner starts, the lane
Detail (#975), Collection (#987) and Person (#990) took; wave 2, lane A of the Sans-IO series.

A refusal the step can observe: Fetch::refuse_for(gen) releases that generation's claim and records
the refusal, only when the claim is its own; Fetch::take_refused(gen) answers once, and a refusal
for a superseded generation frees and records nothing. These stores back off RETRY_FRAMES after a
refused start, and the backoff survives the start leaving the step.

Subtitle search: maybe_spawn claims and pushes Job<SubSearchReq> with the server and the ClientKey
the step chose; pump reads take_refused before maybe_spawn and backs off one pump later, with no
respawn spin; the no-client branch is unchanged; finish_subsearch_job runs under catch_unwind.

View reconcile: kick pushes Job<ReconcileReq> per server batch. A landing is Landing { id, outcome }
with Outcome::{Read, NotStarted}; a refused or key-mismatched flight posts NotStarted, which
requeues its leaves and parents (an item asked for again goes back as an item), drops the dirty
marks it covered, backs off and settles nothing. reset() keeps a job still on the outbox, which
answers into the retired adapter.

The runner resolves the client inside the launch and starts a job only if ClientKey::of(c) still
matches; both kinds are untaped and launch live under replay; Held parks them, run_held re-resolves
or refuses, and a newer Detail request leaves them parked. Bridge::subsearch_pump and reconcile_pump
refill the keys, step and drain their own store in one call.

Ledgers: data-subsearch's and data-viewreconcile's workers and globals files deleted;
PINNED_LEDGER_TOTALS 22/97/60/11 -> 20/95/60/11. The wall gate scans data/subsearch.rs.

Tests: 36 new (Fetch refusal 4, subsearch job 8, view reconcile job 11 plus 1 parents test, runner
12), and the stop-after-identity-change regression test now sweeps the parked read-back. Fixture
replays all SAME; in the macOS simulator against the mock server, a watched-state read-back and a
player subtitle search were each sent to the runner, ran and landed.

Closes #995

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.

The metadata store starts its own detail worker instead of handing the work to the app

1 participant