Skip to content

Person store: emit store jobs and read the server registry as an input - #990

Merged
GLinnik21 merged 17 commits into
mainfrom
sansio/store-jobs-person
Oct 24, 2026
Merged

GLinnik21 merged 17 commits into
mainfrom
sansio/store-jobs-person

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Closes #989

The Person store no longer starts workers or reads the server registry from inside its step. It now emits one typed StoreJob::Person per fetch slot, and the app's StoreRunner starts them. This is the lane Detail took in #975 and Collection in #987. It is wave 1, store 2 of the Sans-IO series (docs/sans-io.md, "The store job lane"), and it reuses #987's ClientKeys input and per-store drains unchanged.

What changed

The step. maybe_spawn keeps everything that comes before the start: 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, instead of spawning, it 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. When a source's server holds 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.

Addressing. Addr.req is a per-state wrapping sequence, so every job's address is unique. The slot and the person generation travel in PersonPort, and done/refused never read the address. 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.

  • For a server read, the launch resolves the client and 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.
  • A newer Detail request leaves parked Person jobs alone.

The job body. 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.
  • A server job handed no client is refused rather than answered.
  • PersonAnswer is opaque, so Landing stays private.

The Bridge. Bridge::person_pump refills the keys, steps, then runs start_store_jobs_of(StoreId::Person), all in one call. Person still pumps before Collection and the Detail reconciliation, so the tape's cross-store admission order holds.

Not pure yet. The Person 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 only, devtrig::read("personcredits"). docs/sans-io.md lists these reads and claims no purity for Person. fetch_profile/fetch_credits stay in data/, so the forks lines stay.

Ledgers

Before After
ci/allow/workers/data-person.txt 2 lines (maybe_spawn::spawn_small ×2) deleted
ci/allow/globals/data-person.txt 1 line (maybe_spawn::client_for) deleted
PINNED_LEDGER_TOTALS (workers/globals/forks/fxlanes) 24/98/60/11 22/97/60/11

Tests

Nineteen new tests:

  • 10 step tests in data/src/person.rs, over the assert_fx! contract:

    • slot order and the fan-out width;
    • the no-key back-off;
    • plex.tv identity;
    • unique addresses that survive 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 recorded shape;
    • a controlled read without IO;
    • a clientless server job is refused.
  • 7 runner tests in app/adapters/stores.rs: admitted and answered once; plex.tv admitted whatever the registry holds; a declined admission refused once with its claim back; owed under replay; a moved-on client not started; parked Person jobs survive a newer Detail request; a parked job whose client is gone is refused.

  • 2 Bridge tests in app/person_admission_tests.rs:

    • the first three reads admit in slot order: Media (slot 1), then plex.tv Profile (48), then Credits (49);
    • only the plex.tv reads admit when the server has no client.

    Both pass on the pre-change tree and on this branch, so the admissions are equal.

  • controlled_person_ignores_ambient_session_recovery now steps and pins the outbox empty, instead of running the jobs inline past the tape. Making the profile arm ignore its flag fails it.

The data test rig runs emitted jobs inline through finish_person_job, so the sleeps and drain_workers_for_test calls are gone.

Gates, run on the committed tree

Run on head c9b61f80b. That head carries the stacked re-base onto #987's squash and main at e843b99f1, the one-line docs addition, and a behaviour-identical simplify commit. The simplify commit merges the port constructors into PersonPort::to, moves the Roles key list instead of cloning it, adds test helpers, and rewords comments.

Gate Result
make check exit 0. Every test result: line reports 0 failed. The application crate passed 957 tests (default features) and 1070 (hostsim). check-deps reports workers 22, globals 97, forks 60, fxlanes 11 and "all gates green".
make check-nodef exit 0, no warnings
make check-replay Every resolve and targets replay of all three fixtures reports verdict=SAME, with every *_diffs=0. No fixture changed, including fixture 12.
make (ARM, tvdev) pkg/plxnative linked

One review, verdict FIX FIRST. Its two should-fix findings are in this branch: the controlled-step outbox pin and the live-path proof below. Its two notes are covered by the docs line and the re-base.

Live path

Replay never launches a job, so the live runner was checked in the macOS simulator against tests/mock_pms.py --seed 1, with plex.tv and Discover pointed at the mock.

The mock saw each of these once, with no re-ask and no refusal loop:

  • the Media read, GET /library/people/19/media;
  • the Profile read, GET /library/people/<guid> (200);
  • the Credits read, GET /library/people/<guid>/credits, which answered the mock's 401 for a token boot without an account token;
  • one batched Roles read, GET /library/metadata/<26 keys>.

The capture shows the biography header and the Movies (22) and Shows (4) shelves.

The proof does not show a successful Credits landing (unit tests cover it) or a cross-server Resolve read (one server). It is host-simulator evidence only, with no TV claim. No drawing code or FFI changed.

🤖 Generated with Claude Code

GLinnik21 and others added 17 commits October 24, 2026 10:10
The store-agnostic pieces the Person and Collection stores need to move onto
the store job lane (the lane Metadata's detail fetch already uses).

plx_plex::plex::{ClientKey, ClientKeys}: the registry's answer for every
server slot as a plain value, so a store's step decides from an argument
instead of reading client_for itself. ClientKey is (instance, token): the
client object plus the credential it held. There is deliberately no reader on
the type; the application fills one in place from the live registry
(adapters::stores::refill_client_keys), and the Bridge owns the one buffer so
a pump that runs every frame allocates nothing for it.

Fetch::release_for(gen): a refusal hands back the claim of the request it
answers and leaves a newer request's claim alone.

Stores::take_jobs_of(StoreId) and Bridge::start_store_jobs_of(StoreId): a
store's Bridge pump drains only its own outbox, in the same call as its step,
so a job some other sender left behind is still found and counted by the
backstop instead of being started silently. take_jobs / has_jobs now walk
StoreId::ALL, so a store joins the aggregate in one place. metadata_run drains
its own store this way (the same jobs today: only Metadata has an outbox).
The backstop and frame-check texts name every drain, not only metadata_run.

The runner's parked-job handling (retire_parked_details, run_held) is a match
over every job kind, so a store that joins the lane must say what a newer
detail request does to its parked jobs.

store_admission_tests: pins the tape admission a pumped collection records as
literals (rating-key open, tag open, unregistered server). Written against
signatures that do not change when Collection moves onto the lane, so the same
file runs on both sides of that change.

Two dead-code expectations (the keys buffer and its refill) are fulfilled by
the next commit, which removes them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The collection store's step no longer starts a worker and no longer reads
the client registry. Its pump claims the fetch and pushes a typed
StoreJob::Collection (CollectionReq: server, the ClientKey it decided on,
the work) on an outbox; Bridge::collection_pump refills the Bridge's
ClientKeys, steps, and hands the job to the StoreRunner in the same call.

- CollectionReq / CollectionPort / CollectionAnswer / finish_collection_job
  in plx_data::collection. Addr.req is the listing generation (one fetch is
  out at a time). done() lands the answer stamped with that generation;
  refused() releases only that generation's claim (Fetch::release_for).
- CollectionStore::{run, pump} take &ClientKeys; Open and the pump's
  client-changed check compare ClientKey values instead of calling
  client_for. ViewState reaches the store through view_edit_collection,
  which only forwards ApplyView and passes no keys.
- The runner admits the request through the tape in the recorded shape
  (byte-identical to the old inline admission) and resolves the client
  inside the launch, accepting it only if it is still the client the step
  named. A Held runner parks the job; a newer Detail request retires only
  parked Detail jobs and keeps the rest.
- Contract tests for the emitted jobs (assert_fx!), the admission shape,
  refusal and supersede handling, and the runner's four outcomes; the
  Bridge-level admission test from the previous commit passes unchanged.
- The lifecycle rig that walks a collection page runs the held jobs.

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

Collection's step emits its request as a store job and reads the client
registry as an input, so its four ledger lines are gone: the worker start
(`workers`, 25 to 24) and the three `client_for` reads (`globals`, 101 to
98). Both area files held nothing else and are deleted; PINNED_LEDGER_TOTALS
follows, forks and fxlanes unchanged.

The `wall` clock-read gate now scans data/src/collection.rs (no hit).

docs/sans-io.md "The store job lane" names Collection as the second store,
ClientKeys as the input for a registry read, the per-store drain inside each
Bridge pump (refill keys, step, start_store_jobs_of) and the generic
backstop. CollectionStore's unreached Machine::step comment no longer says
empty keys strand a job (they fail the page; real keys without a drain
strand it).

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

a_server_without_a_client_emits_nothing_reads_failed_and_holds_off asserted Failed,
no job and no claim, then pumped with empty keys, which emit no job whether or not
retry_cd was set. It now asserts that the revision does not move across the
RETRY_FRAMES - 1 held-off pumps and does move when the hold-off ends. With the
`self.retry_cd = RETRY_FRAMES` line removed from maybe_spawn's no-client branch the
test fails (revision 3 against 2); with it, it passes.

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

The Bridge-level admission pins opened and pumped a collection alone, so the order
across stores inside one frame (the positional tape comparison) was pinned on no
tree. One test opens a person and a collection, pumps person_pump then
collection_pump inside one FrameScope and compares tape::finish() with the full
literal list: the person's three requests in slot order (the shapes fixture 12
records), then the collection's header read. It uses only signatures that exist on
the base tree. Swapping the two pumps makes it fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Person store no longer starts its own worker and no longer reads the
client registry inside its step. Its pump emits one typed StoreJob::Person
per request, in ascending slot order, and the app's StoreRunner starts it.

- PersonReq names the request (slot, generation, args, guid, and the work:
  a plex.tv profile or credits read with the identity the step decided on,
  or a read of one registered server with the ClientKey it decided on).
  PersonPort lands the answer into the adapter slot it was emitted for, and
  its refusal releases only that generation's claim.
- The step decides from ClientKeys the Bridge refills right before the call
  (the scaffolding the collection lane added). A source whose server holds no
  client emits nothing and backs off, as before.
- Bridge::person_pump refills the keys, steps, and starts the person jobs in
  the same call, so the tape's admissions keep their cross-store order.
- The runner resolves the client inside the tape's launch closure and
  compares it with the job's key; a mismatch is a refused admission. Parked
  person jobs survive a newer Detail request and are re-resolved when run.
- finish_person_job is the old worker body, moved to the runner side:
  the Controlled identity answers the failure value without a read.

Admission records are byte-identical to the base tree's (pinned by a
Bridge-level test that passes on both trees). What stays in the step:
tape::active, session::peek_settled, session_watch, the synchronous
discover-refused landing, server_ids and server_roster_gen.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The collection lane's stage B and review fixes retire its own ledger lines and
pins; this branch needs them so ci/check-deps.sh sees no stale collection line.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Delete ci/allow/{workers,globals}/data-person.txt (both held only the lines
the store job lane removed; the fork lines stay, the fetch bodies stay in
data/). PINNED_LEDGER_TOTALS goes to the real sums with the collection lane
merged in: workers 22, globals 97.

docs/sans-io.md: Person is on the store job lane; PersonPort carries the slot
and the generation because several Person jobs are out at once; the Person
step is not pure and the section lists the reads it keeps (tape::active,
session::peek_settled, the session watch, the refused-discover landing,
server_ids, server_roster_gen). Comments that said the pump or the person
store spawns a worker now say it emits a job, and the capture-at-spawn rule
that left the step lives on the runner's resolve helper.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The job tests import Job and Port that the parent module's glob already supplies, the Bridge
spells StoreId in full where the file imports it, and the client_keys module doc narrated what
the step "used to" do. Names and wording only; no behaviour, expectation or ledger line moves.

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

The rig's pump is step() plus run_jobs(), and run_jobs() hands each job to
finish_person_job, bypassing tape::admit, so the test's tape::finish()
assertions (no requests, no failure) could no longer see anything a controlled
step emitted. Step alone and assert_fx!(jobs, []) puts the 'no request' half
back where it can be observed. The person also carries a guid now, so the two
plex.tv reads WOULD be wanted if the profiled/credited flags were not honoured
(address() is None for an empty guid whatever the flags say); with address()
ignoring profiled, the test fails on the outbox.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to sansio/store-jobs-person

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The list of what the Person step still reads omitted
plx_base::devtrig::read("personcredits"), which seed_dev_credits makes on every
pump while a person is open and no tape is armed (dev-trigger builds only).
Review note F3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Behaviour-identical cleanups from the pre-PR simplify pass:
- PersonPort::of and the cfg(test) at_for_test collapse into one private PersonPort::to.
- local_landing takes the key list by value, so the Roles landing moves it instead of cloning.
- The test owner drops its stored keys and its second run path: step is step_with over the
  registry's keys, run_jobs unwraps through person_jobs; holding() and media_job() replace
  eight repeated key literals and three repeated open/step/find preambles.
- Comments that narrated the migration ("as the worker did before", "the old pump") state the
  present behaviour; the plex-layer docs no longer name the data layer's launch mechanism; the
  K_RESOLVE note names the places a new kind now edits.
- bridge.rs uses the imported StoreId.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 10e9287 into main Oct 24, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the sansio/store-jobs-person branch October 24, 2026 11:48
GLinnik21 added a commit that referenced this pull request Oct 24, 2026
Records the squash on the branch; its tree is already in (c9b61f8's tree is
byte-identical to 10e9287's).

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]>
GLinnik21 added a commit that referenced this pull request Oct 24, 2026
#990 deleted the data-person ledger files and set the pins to workers 22 and
globals 97. Take those, and restate this diff's pin comment and the
docs/sans-io.md sentence as the change's own net effect (-3 deleted, +3
seeded, net zero) instead of naming a total other lanes move.

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.

Person store: emit store jobs and read the server registry as an input

1 participant