Skip to content

Hubs store emits its read as a store job; the step decides its client from ClientKeys - #1011

Merged
GLinnik21 merged 14 commits into
mainfrom
sansio/store-jobs-hubs
Oct 24, 2026
Merged

GLinnik21 merged 14 commits into
mainfrom
sansio/store-jobs-hubs

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Closes #1010

The Hubs store no longer starts its own fetch worker from inside its step. Each step emits a typed StoreJob::Hubs, and the app's StoreRunner starts it, as it already does for Detail, Collection, Person, subtitle search, view reconcile and Catalog (#975, #987, #990, #996, #999). The step also stops asking the server registry which client a source talks to: it decides from the ClientKeys the Bridge refills in the same call. This is wave 3, lane A of the Sans-IO series (docs/sans-io.md, "The store job lane").

What changed

Admission is a type (data/src/stores/mod.rs, app/adapters/stores.rs):

  • StoreJob::admission() is one exhaustive match over Admission::{Tape, Home, Direct}. Detail, Collection and Person are Tape, subtitle search, view reconcile and Catalog are Direct, and Hubs is Home. A new kind cannot skip the question.
  • StoreRunner::start_admitted(job, Option<&mut HomeIo>) admits a Home job through the controlled Home's HomeIo and refuses it through its port if admission says no. Every other sender uses start, which runs a Home kind as Direct.
  • Only the controlled Home arms in the Bridge admit (Bridge::admit_hubs_jobs), and they still record the Hubs line before the discovery line. HubRequest::admission() carries the old hubs_descriptor body unchanged, so the recorded bytes are the same. hubs_descriptor and HomeIo::hubs* are gone.

The store (data/src/pms.rs, stores/hubs.rs):

  • kick_with builds the immutable HubRequest at the step and hands it to launch, which only collects it. spawn_fetch and its two test/production forks are deleted.
  • The client is decided from BrowseScope.clients, a borrowed ClientKeys. The five step-side client_for reads are gone. The landing compare keys on the bound client's instance_gen().
  • owed is raised when the runner launches a job (HubsPort::claim), held while a job is parked, and lowered when a parked job's client is gone by the time it runs.

Refusal (S2):

  • A refused launch queues its request id on the adapter, and the next Hubs step settles it (settle_refused): the source backs off and yields its RequestEndpoint. That is one step later than before, when the kick settled it inline.
  • The settling step can now be a view edit or a quiet notify refetch, so publish_view, the viewstate and notify-map runs, the Stores calls and the Bridge pumps all carry the EndpointRefreshSet out, and boot, input and the run loop execute it.

Drains (S3):

  • Every Bridge call that steps Hubs drains the Hubs outbox in the same call. A Stores call that fans out to Hubs names it in its fill list (VIEWSTATE_FILLS, NOTIFY_FILLS), and the Bridge drains those with start_store_jobs_in.

Held runner (test only): held() parks every kind but Hubs, which still starts on a worker, because a rig that waits for a Home landing needs a real one. held_all() parks Hubs too, for the rigs that run the parked job themselves.

Log line: hubs: source N fetching now prints when the step emits the request, before the runner starts it.

Ledgers

Before After
ci/allow/workers/data-pms.txt 1 line (spawn_fetch::spawn_small) deleted
ci/allow/globals/data-pms.txt 5 lines (client_for in kick_with, new, refresh_src_lifecycle, roster_with_scope, step_landings_with_scope) deleted
ci/allow/forks/data-pms.txt 2 lines (spawn_fetch) deleted
PINNED_LEDGER_TOTALS (workers/globals/forks/fxlanes) 19/95/60/11 18/90/58/11

No ledger line was added or edited.

Tests

  • Fails first:
    • The refusal tests rewritten for the step-side settle failed on the tree before it (plx_data 5 failed, app 4 failed) and pass with it.
    • The two tests that a settling view edit and a settling quiet refetch carry their endpoint refreshes out (a_refusal_settled_by_a_view_edit_step_is_carried_out_of_the_press_and_the_stop_patch, a_refusal_the_quiet_refetch_step_settles_is_carried_out_of_the_pass) fail with the outcome dropped (test result: FAILED. 0 passed; 1 failed) and pass with it.
  • The runner's 14 new branch tests (app/adapters/stores.rs) were each checked by breaking the branch they pin: dropping the gone-branch unclaim fails 1, never admitting a Home job fails 6, leaving a ledger refusal unanswered fails 4.
  • home_admission_tests.rs (added first, unedited since) pins what a controlled Home records for Hubs and discovery, in order. It passed on main and passes here.
  • Targeted suites at ff2c00e:
    • plx_data 1188 passed, 0 failed;
    • plx_screens 1698 passed, 0 failed;
    • app 988 passed, 0 failed.
    • The whole app hostsim suite passed (1101) on 85382ae, before the review fixes, and its return_hold and lifecycle subsets pass at ff2c00e.

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. The fixture files are unchanged from main.

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

  • a ClientKeys clone on every Home tick, now a borrow;
  • a refusal settled by a view edit or a quiet refetch dropped its endpoint refresh, now carried out (the two fails-first tests above);
  • a weakened assertion that an empty list would pass, now pinned to boot's exact yield, which is empty.

Two notes are also fixed: unclaim saturates like the take, and check-deps no longer names a deleted function.

A doc-claim audit found six sentences this change made false, and all six are fixed here:

  • the drain rule against the fan-out fill lists;
  • the pms row of docs/stores-as-machines.md and the pms.rs module doc, which still called controlled work the capture path;
  • "a refused launch settles at once" in run.rs;
  • the meaning of the fetching log line;
  • check-deps' list of deliberately unlisted functions;
  • two pointers to a pms::kick rule that is now kick_with's "capture at the step".

Live path

Home was checked in the macOS simulator against tests/mock_pms.py, with plex.tv and Discover pointed at the mock and a placeholder token. It was a mock-only run with no real account.

  • It was a non-test build, so the read went through StoreRunner::Live.
  • The log shows hubs: source 0 fetching (off-thread) once, then hubs: source 0 ok - 2 shelves, 12 in CW and hubs: landed - 44 items, 3 shelves.
  • The mock saw exactly one GET /hubs, one /hubs/continueWatching and one /hubs/continueWatching/items: no re-ask, no refusal loop.
  • Home rendered its hero, Resume and first row.

The held and refused paths cannot be reached from a simulator boot, which always runs the Live runner. The runner's tests and the refusal tests cover them. This is host-simulator evidence only, with no TV claim. No drawing code or FFI changed.

Not in this PR

Four review notes are test coverage, not defects, and are left for a follow-up:

  • a decode test whose logical instance differs from the bound client's;
  • refusals superseded by a refetch or a reset;
  • a stranded claim in one bootstrap rig;
  • Bridge tests that fail if the notify or viewstate pump stops draining Hubs.

🤖 Generated with Claude Code

GLinnik21 and others added 14 commits October 24, 2026 17:05
…before Hubs moves onto the job lane

A controlled Home Bridge (recording side) writes one admission per request
the stores ask for, in the order they are asked, and a replay compares that
list byte for byte. The new Bridge-level test delivers a Hubs refetch and
the discovery work of the same frame and pins both recorded values as
literals, hubs first and discovery second, against the signatures that do
not change when Hubs emits a store job instead of starting its own worker.
It passes on the base and stays unedited through the lane.

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

Src keeps a ClientKey instead of a &'static Client and a token generation.
Every Hubs entry (tick, land, run, controlled) and the Stores methods that
step Hubs (viewstate_run, viewstate_pump, stops_landed, notify_map) take
the ClientKeys the Bridge refills just before the call. The landing compare
keys on resource.instance_gen(), so replay's recorded logical instance id
cannot make a live landing look stale. The recorded HubsInitial and the
request descriptor carry the same numbers as before.

BrowseScope carries the keys so the scope-level cores need no new
parameter; a test-only standalone scope reads the registry in test code.
Four client_for lines leave the globals ledger (count 5 to 1); the last one
goes with the worker in the job-lane commit.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Stores::VIEWSTATE_FILLS and Stores::NOTIFY_FILLS name the outboxes a fanning
call can fill, and Bridge::start_store_jobs_in starts them in that order.
hubs_run, viewstate_run, viewstate_pump, notify_pump and the three live
Store(Hubs) / HubsResult / StoreWork::Hubs arms drain Hubs in the same call
as the step. stops_pump and reconcile_pump reach Hubs through ApplyView only,
which launches nothing, so they drain none. The two controlled arms join in
the job-lane commit, where they start through admission.

Hubs has no outbox yet, so behaviour does not change; the WARN string and the
leftover-job assertion name the new drains.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…he kick

PmsAdapter gains an unrecorded refused list. kick_with records
(generation, request id, server) there when its launcher says no and leaves
the source in flight; settle_refused runs first in step_landings_with_scope,
run_with_scope and controlled_work_with_scope and runs the old inline block
verbatim (latch released; a quiet read spaces its next try; a page ask backs
off without spending an attempt; anything else fails the attempt and asks for
the endpoint again). An entry whose generation or request id no longer
matches was superseded and is dropped. No refusal reaches a recorded
mailbox, so no recorded byte moves.

The refusal tests were rewritten first and failed against the previous tree
(data 5 failed, app 4 failed); they pass with the settle.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… starts no worker

HubsStore steps emit StoreJob::Hubs(Job<HubRequest>, HubsPort) on an outbox
and the app's StoreRunner launches them. HubRequest carries the ClientKey its
step decided on and owns the IO body (fetch) and the landing (complete);
HubsPort holds the adapter Arc, raises the dump-mode claim at the launch (at
the park in Held) and files a refusal on the unrecorded list the next step
settles. StoreJob::admission() names three families as one exhaustive match
(Tape, Home, Direct); the Hubs read is Home, admitted through the controlled
run's own ledger by StoreRunner::start_admitted with the bytes HubRequest::
admission returns (the bytes hubs_descriptor returned). The controlled arms of
the Bridge step Hubs and admit what it emitted inside the arm, so the hubs
line still precedes the discovery line; the live arms, the landing and the
fan-outs start through start. Held parks per kind: held() leaves Hubs live,
held_all() parks it for the tests that choose when it settles.

Both spawn_fetch forks, kick's client_for read and the HomeIo::hubs* helpers
are gone, and the three data-pms ledger files are deleted. The test seams the
inline spawn had (a refused spawn, a late worker) are the runner's, cfg(test)
beside the boundary they stand for.

The runner branches have tests of their own (live, spawn refused, client gone,
held run, held gone, and the Home ledger recording and replaying a launch and a
refusal); each fails when its branch is broken (gone-branch claim kept: 1
failed; Home never admitted: 6 failed; ledger refusal unanswered: 4 failed).
home_admission_tests passes unedited.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
docs/sans-io.md gains the Hubs lane (the third admission family, the claim
raised at the launch, the refusal outside the landing mailbox, replay
identity) and names the Hubs drains; PINNED_LEDGER_TOTALS drops to workers
18, globals 90, forks 58 with the three data-pms files gone. Comments that
the change made false are corrected: the landing gate's owed claim now names
launch_hubs_job, the adapter and port docs say the port holds the Arc, a
refused launch is settled by the next step, the check-deps hubs-owner note
no longer names HomeIo::hubs_with_directory, and the rlib string measurement in
docs/module-layers.md records that the Hubs refusal seam is the runner's.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Conflicts: ci/allow/globals/data-pms.txt (main only reworded its header; the
Hubs lane deletes the file, so it stays deleted) and PINNED_LEDGER_TOTALS in
tests/test_harness.py (main kept 19/95/60/11 and moved globals -3/+3; the real
sums of ci/allow on the merged tree are workers 18, globals 90, forks 58,
fxlanes 11).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… them (F1)

BrowseScope::retained cloned the Vec<(ServerId, ClientKey)> on every Hubs
step, so the idle per-frame Home tick allocated and freed once per frame for
any user with a server. The scope now holds a Cow: Borrowed from the host's
one buffer in retained(), Owned in the test-only standalone().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… endpoint refreshes (F2)

A launch the runner refused is settled by the next Hubs step, and that step can
be an ApplyView (a press, a stop patch, a read-back fact) or a quiet source
refetch (the notification map). Their callers threw the EndpointRefreshSet
away (`let _`), so a refusal settled there backed the source off and never
asked for the server's endpoint to be re-resolved.

publish_view returns the Hubs step's endpoints; ViewStateState::request/run,
ViewStateStore::run, Stores::viewstate_run and Bridge::viewstate_run return a
StoreOutcome (changed = the old bool); Stores::stops_landed/publish and
Bridge::stops_pump return the set; Stores::reconcile_pump returns a
StoreOutcome; Spent gains `endpoints`, which Bridge::notify_pump hands back.
The dispatcher arm carries them (`Bridge::carry`), boot merges them, the
item-action presses and the frame loop execute them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d (F3)

`all(|sid| *sid == a)` was true for an empty list, so a boot that returned
EndpointRefreshSet::default() passed. Boot yields exactly nothing in this rig
(Reset rotates the Hubs and Browse adapters, and the refetch it sends is
settled by the next Hubs step), so the assertion is is_empty() with that
reason beside it and the list printed on failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a deleted fn (F6, F9)

HubsPort::unclaim was a plain fetch_sub, so an unclaim after the landing take
had already saturated the count to 0 wrapped it to u32::MAX. It now lowers
with the same saturating update take_landings uses. ci/check-deps.sh's comment
listed controlled_work_with_directory, which this lane deleted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The doc-claim audit found three prose claims the lane made false: the drain
rule ("each Bridge entry point drains only its own store", "in that one place")
that the *_FILLS fan-out lists broke, the stores-as-machines pms row and the
pms.rs module doc that still described controlled work as the capture path
(it is now a test driver; every step emits a StoreJob::Hubs), and run.rs's
"a refused launch settles at once" (it is settled by the next Hubs step).

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

The Hubs read is a StoreJob the runner starts, so the "fetching" log line says only that the step emitted the request, and the capture rule is `pms::kick_with`'s "capture at the step".

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.

Hubs store starts its own fetch worker and reads the server registry from its step

1 participant