Skip to content

Browse section hubs emit store jobs for the list and row reads; the step decides the client from ClientKeys - #1021

Merged
GLinnik21 merged 11 commits into
mainfrom
sansio/store-jobs-browse
Oct 24, 2026
Merged

GLinnik21 merged 11 commits into
mainfrom
sansio/store-jobs-browse

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Closes #1020

A library's section hubs (the Recommended page's list and the row windows under it) no longer start the Browse store's own worker or read the server registry from its step. Each read leaves as a typed StoreJob::BrowseHubs:

  • the step takes the section's client key from a borrowed ClientKeys;
  • the app's StoreRunner resolves that key at launch and hands the worker body the client.

The store lanes merged so far work this way (#975, #987, #990, #996, #999, #1011, #1013, #1015). This one copies the Hubs lane (#1011) one store over. It is wave 4, lane B, PR B-A of the Sans-IO series (docs/sans-io.md, "The store job lane").

What changed

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

  • StoreJob::BrowseHubs(Job<BrowseHubsReq>, BrowseHubsPort) is one kind for both the list read and a row's window read. The request carries which read it is, the section, its ClientKey and the epoch.
  • The two reads still share the adapter's one claim and mailbox (Fetch<HubResult>), so one section-hubs read is in flight across all sections, as before.
  • Admission is Direct. A controlled run never emits this work, because bootstrap/effects.rs's work_value() refuses every StoreWork but Hubs and discovery. So no fixture records it, and the fixtures are unchanged.

The claim and refusal (S2):

  • The claim is raised at the step, and the store records the read it sent.
  • A refused job lowers the claim in the call that refused it. Refusal covers three cases: the key moved by launch, the registry no longer holds the client, or the system refused the thread.
  • The next hubs_pump_spawns then puts back what a failed start left on main: a list read is owed again, and a row read is no longer in flight. The pump after that asks again with the current key.
  • A read sent on an adapter that has since been replaced is dropped, not settled. While a read is out with no claim, the store reports pump work, so the settle cannot wait on an unrelated frame.

The landing: hubs_land compares the answer's ClientKey with the section's current row in ClientKeys, instead of reading the registry (client_for, ptr::eq, token_gen). A re-token, a re-point (another client instance with the same token) and a sign-out each land as not ours, and the section stays owed. The harness line libhubs: section N landed N shelves, N items is byte-identical (tests/mock_fps.py reads it).

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

  • start_browse_hubs / launch_browse_hubs resolve the key at launch, or refuse.
  • The worker body keeps its panic guard and runs only against the client it was handed.
  • The arms are in start, run_held_where, admit_home and retire_parked_details.

Drains (S3). Every Bridge call that can step the section hubs drains Browse in the same call:

Entry Drain
Bridge::browse_run (and the dispatcher's StoreCmd::Browse arm, which calls it) refills the client keys, steps, start_store_jobs_of(Browse)
the dispatcher's StoreWork::Browse arm refill, step, start_store_jobs_of(Browse)
Bridge::reconcile_pump (its owed requery) start_store_jobs_of(Browse)
Bridge::viewstate_pump / viewstate_run (a burst-end HubsInvalidateAll) VIEWSTATE_FILLS
Bridge::notify_pump (a library change, HubsInvalidateServer) NOTIFY_FILLS
  • VIEWSTATE_FILLS and NOTIFY_FILLS are now [Browse, Hubs], in StoreId order as S3 says. A test asserts the order. Browse is Direct, so this changes no recorded admission.
  • browse_run joins the backstop's list of drains in start_late_store_jobs.
  • Machine::step on BrowseStore passes no keys, as Collection's and Person's do, so a key-less step decides no section-hubs read.

Test runner:

  • StoreRunner::held() parks BrowseHubs; only Hubs stays live there.
  • The default app suite needs no live read. The one hostsim rig that does, the_recommended_page_fetches_the_sections_hubs, now runs the parked read on each pass of its wait (run_held_store_jobs_of_for_test(StoreId::Browse)), the pattern the Collections rig uses.

Call sites:

  • Stores::browse_run takes the keys. Test-only browse_run_for_test / BrowseStore::run_for_test keep the screens and app tests' one-argument calls. That is why 14 files in screens and app change only at those test call sites.
  • search/scope.rs changes one test call the same way.

Gate list: ci/check-deps.sh's wall list gains data/src/browse/section_hubs.rs, which has no clock read.

Ledgers

Before After
ci/allow/workers/data-browse.txt 5 3 (hubs_spawn, hubs_spawn_row spawn_small gone)
ci/allow/globals/data-browse.txt 20 17 (hubs_land, hubs_spawn, hubs_spawn_row client_for gone)
PINNED_LEDGER_TOTALS (workers/globals/forks/fxlanes) 16/78/58/11 14/75/58/11

No ledger line was added or edited. The directory, page and source reads, discovery and the pins keep their data-browse lines for the next PRs.

Tests

Fails-first:

  • a_section_hubs_step_emits_a_job_and_starts_no_worker_of_its_own was committed first (728e95c) and was red on the base.
  • a_landing_whose_client_moved_is_not_ours_and_the_section_is_still_owed pins behaviour main already had.
  • The refusal-settle test cannot compile on the base (no job seam), so it landed with the seam.

New tests:

  • 9 in section_hubs_job_tests.rs: emit, the list and row settles, a retired adapter, three not-ours landings (re-token, re-point, sign-out), a superseded read's late answer, and the pump waking to settle.
  • 7 runner branch tests: run and answer once; client gone → refused and asked again; thread refused → refused and asked again; held park and run; held with the client gone; the held runner parks; Direct admission leaves the Home ledger untouched.
  • 5 drain tests in app/browse_hubs_drain_tests.rs.

Mutation checks, each reverted:

  • Removing each drain in turn (browse_run, the StoreWork::Browse arm, the VIEWSTATE_FILLS entry, the NOTIFY_FILLS entry, the reconcile_pump drain) fails its drain test.
  • A landing compare on the token alone fails the re-point and sign-out tests.

Targeted suites at 81228e7, which merges main at e87ca65:

  • plx_data 1218 passed, 0 failed;
  • plx_screens 1704 passed, 0 failed;
  • app 1013 passed, 0 failed;
  • plx_machine 94 passed, 0 failed;
  • hostsim, whole app crate, 1126 passed, 0 failed;
  • the ledger tests, ci/check-deps.sh and ci/check-module-layers.py are 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. The fixture files are unchanged from main.

Review. One review, verdict FIX FIRST, with one should-fix finding: the branch conflicted with main after #1013 and #1015. That is fixed by the main merge, with the pins recomputed from the # count: headers. One stray ) the merge left in the runner's admit_home pattern was found and fixed before the suites above ran. Five notes were handled:

  • a Collection comment named a sender this PR removed;
  • the drain paragraph now names viewstate_run;
  • the fill lists are in StoreId order;
  • the re-point and sign-out landings are now tested;
  • the held-runner choice is confirmed as is.

Doc-claim audit. It found six sentences this change made false, and all six are fixed here:

  • the admission list in docs/sans-io.md;
  • its list of drains;
  • the owed and hubs_land docs, which said owed clears when a worker is claimed;
  • two test docs in section_hubs.rs;
  • the HubResult doc;
  • the Collection Machine::step comment.

Live path

The section hubs were checked in the macOS simulator against tests/mock_pms.py --section-hubs 6, with plex.tv and Discover pointed at the mock and a placeholder token. It was a mock-only run with no real account. Before any key, the log showed a synthetic server with owned=1.

  • Opening the Movies Recommended page with the remote keys made exactly one GET /hubs/sections/1. Eight seconds later there was still one.
  • The log read libhubs: section 0 landed 6 shelves, 68 items, with no stores: WARN and no panic.
  • Walking into a shelf and past its window edge made one row read at each window (start 0, then start 11).

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

Not in this PR

  • The rest of browse/: the directory (B-B), the page and source reads (B-C), discovery (B-D), the roster and gate reads (B-E), and the pins (B-F).

🤖 Generated with Claude Code

GLinnik21 and others added 11 commits October 24, 2026 22:45
A section-hubs step must start no worker of the store's own (red on this
base: the step's own worker answers), and a landing whose client moved is
not ours and leaves the section owed (a pin on this base). The refusal
settle test needs the job seams and lands with them.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
A library's section hubs (the list read and the per-row page read) no longer start their own
worker and no longer read the registry in the step. Each read is a typed job on Browse's outbox,
decided from the borrowed ClientKeys the Bridge filled; the application's StoreRunner checks the
key at launch (resolve) and hands the worker the &'static Client. The one shared Fetch holds the
claim, the mailbox and the refusal for both reads, so one read is in flight across all sections.

- StoreJob::BrowseHubs(Job<BrowseHubsReq>, BrowseHubsPort), admission Direct (controlled runs never
  emit this work: bootstrap/effects.rs work_value refuses every StoreWork but Hubs and
  BrowseDiscovery).
- The claim is raised at the step and lowered by the landing or the refusal; a refused read is
  settled by the store's next hub step to the state of a read that never started.
- hubs_land compares the result's ClientKey with the section's current row of ClientKeys.
- Bridge: browse_run, the StoreWork::Browse arm and reconcile_pump refill the keys and drain
  Browse's outbox in the same call; the viewstate and notify fan-outs drain it through their FILLS
  lists.
- Ledger: workers -2 (hubs_spawn, hubs_spawn_row), globals -3 (their client_for reads and
  hubs_land's); PINNED_LEDGER_TOTALS 16/87/58/11.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
- adapters/stores.rs: the BrowseHubs branches (start on a worker and answer once, refused when the
  registry's key moved, refused when the system refuses the thread, held park and run, a parked
  job whose client is gone, Direct admission under a Home ledger), each checked by breaking the
  branch it pins; the Hubs launch hook now covers the section hubs' reads too.
- browse_hubs_drain_tests.rs: every Bridge entry that can step the section hubs (browse_run, the
  StoreWork::Browse arm, reconcile_pump, viewstate_pump through VIEWSTATE_FILLS, notify_pump through
  NOTIFY_FILLS) starts the read its step left in the same call; each test fails when its drain is
  removed.
- BrowseStore: two test-only reads of the shared claim and mailbox.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…te covers section_hubs.rs

docs/sans-io.md names the section hubs' reads as a store job (StoreJob::BrowseHubs, one shared
claim, one mailbox, one read in flight) and lists which Bridge entries drain Browse's outbox.
docs/stores-as-machines.md and docs/poster-scheduler-design.md follow: the libhubs worker is
started by the application's runner. The //! of section_hubs.rs and the hubs_kick doc say the
step starts nothing. ci/check-deps.sh adds data/src/browse/section_hubs.rs to the wall gate (no
clock read in it, so no ledger line).

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

The full hostsim pass found the one rig that needs a section-hubs request to reach the server:
the_recommended_page_fetches_the_sections_hubs. A test Bridge's runner parks the read (as it parks
every kind but Hubs), so the rig's wait now runs what the page's step left parked with
run_held_store_jobs_of_for_test(StoreId::Browse), the way the Collections rig runs its jobs. held()
keeps parking BrowseHubs; the docs name the rig.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…w field

landgate.rs and browse_dump_tests.rs still called the section hubs' flag hubs.fetching; it is the
store's one stores::Fetch, hubs.fetch, since the reads became store jobs.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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]>
…-ours landing is tested for a re-point and a sign-out

N3: VIEWSTATE_FILLS and NOTIFY_FILLS are [Browse, Hubs], the order the design (S3) states and
StoreId declares, and the fill-list test pins the order.

N4: the landing compare was tested only for a re-token. Two cases join it, one whose answer comes from
another client instance with the same token (built with from_client_for_test, so the builder is no
longer unused) and one whose server holds no client at the landing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Six audit contradictions. sans-io.md: the Direct list of admission() names the section hubs' read, and
the bypassed-drain list gains browse_run as bridge.rs's copy has it. section_hubs.rs: `owed` is cleared
when the step emits the read (a refusal puts it back at the next step), not when a worker is claimed;
the not-ours test docs no longer say the rejection arm is unreachable without a client; HubResult
names its ClientKey gate, not DirectoryResult's shape. collection.rs: no StoreEv::Cmd sender exists
now that Browse's commands go through Bridge::browse_run (also review note N1). The review's N2 clause
(viewstate_run drains the same VIEWSTATE_FILLS list) rode in the main merge.

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

Resolving the main merge kept both sides' lines of the or-pattern, including the section hubs' own
`)` that ends the arm. The pattern now lists BrowseHubs, Search and SaveRecents inside one arm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ixes left long

Comment layout only; no code, signature or assertion changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 15e843e into main Oct 24, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the sansio/store-jobs-browse branch October 24, 2026 21:49
GLinnik21 added a commit that referenced this pull request Oct 24, 2026
Brings in the Browse B-A section-hubs job and the other changes main gained
since fba7a81 (#1017, #1021, #950). Five files conflicted and every one
keeps both sides: the Direct arm of StoreJob::admission() lists BrowseHubs,
MetaSeason and MetaEpisodes; the runner and the Held docs name both the
Browse and the Metadata kinds; bridge.rs's late-job messages name every
drain of both stores; docs/sans-io.md numbers Metadata as the tenth store;
PINNED_LEDGER_TOTALS is the real sum of the # count: headers (the textual
merge produced a wrong-looking pair).

Co-Authored-By: Claude Sonnet 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.

Browse section hubs: emit store jobs for the list and row reads, with the client decided from ClientKeys

1 participant