Skip to content

Browse: the Library's directory and listing-page reads leave as store jobs - #1028

Merged
GLinnik21 merged 9 commits into
mainfrom
sansio/store-jobs-browse-bbc
Oct 25, 2026
Merged

GLinnik21 merged 9 commits into
mainfrom
sansio/store-jobs-browse-bbc

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

Closes #1027

The Library screen's filter directories (genres, first letters) and its listing pages no longer start the Browse store's own workers, and their fetches no longer read the server registry. Each read leaves as a typed store job that the app's StoreRunner starts:

  • a genre or letters read is a StoreJob::BrowseDirectory;
  • a grid page is a StoreJob::BrowsePage.

The step captures the section's ClientKey from the borrowed ClientKeys, as the section hubs' read does (#1021). The runner resolves the key at launch and hands the body the client. This PR is the second Browse PR of the Sans-IO series, covering design rows B-B and B-C (docs/sans-io.md, "The store job lane").

What changed

The jobs (data/src/browse/listing_jobs.rs is new; data/src/browse/mod.rs, data/src/stores/{browse,mod}.rs):

  • StoreJob::BrowseDirectory(Job<BrowseDirectoryReq>, BrowseDirectoryPort) carries a which that names the genres or letters read. Each read keeps its own claim and mailbox, as before.
  • StoreJob::BrowsePage(Job<BrowsePageReq>, BrowsePagePort) reads one listing page.
  • Both kinds are Direct and belong to StoreId::Browse. Each admission arm comment says why a controlled run never emits it and names the test that pins it.
  • BrowseAdapter holds three Fetch claims (page, genres, letters). They replace the three *_fetching flags and the three Mutex<Option<..>> mailboxes.
  • The catch_unwind guard stays in the body, and the landing stays outside it. A panicking page lands as a failed page and arms retry_cd, as before. A panicking directory read lands as an empty list.

The client:

  • The answer carries the client the runner resolved and the key's token generation.
  • Both landings keep commit_if_current / commit_reachability_if_current, apply_source_outcome, the generation check and items.land exactly as they were. No second identity check was added.
  • The landings take the claim with Fetch::take(), not take_current. On a live adapter, only a request's own answer or refusal lowers its claim, since Reset and a roster retire swap in a fresh adapter. The answers carry no request id, so a take_current keyed on the query generation would leave the claim up with nothing in flight.

Refusal (S2), the B-A shape:

  • A refused job lowers its claim in the call that refused it.
  • The store settles it at its next step, from an adapter-side refused list that is never recorded:
    • a refused directory read is owed again, with its *_done false as before;
    • a refused page leaves fetching false, so the next pump asks again for the then-first missing page with the then-current key.
  • The settlement moves to the store's next step, one pump after the old in-step !spawned arm.
  • The fixtures are unaffected: no recording has admitted:false, and no controlled run reaches these reads.

Drains (S3). Every path that reaches these reads already had a B-A drain. The table lists each one:

Path Reaches Drain
Bridge::browse_run (aim_library commit, addressed Genres/Letters) kick_genres / kick_letters start_store_jobs_of(Browse)
the dispatcher's StoreWork::Browse arm pump_with_gate → maybe_spawn_owned refill, step, start_store_jobs_of(Browse)
reconcile_pump's requery pump_with_gate start_store_jobs_of(Browse)
viewstate_pump, notify_pump hubs reads only already in VIEWSTATE_FILLS / NOTIFY_FILLS
browse_discover_pump discovery only none needed

The command path emits directory reads only, and the pump emits page reads only. B-A's drain rigs now assert the page read too.

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

  • start_browse_directory / launch_browse_directory and start_browse_page / launch_browse_page resolve the key or refuse through the port. They do the same when the system refuses the thread.
  • The run_held_where arms resolve the key or refuse.

The test runner. The rigs decided which reads run live:

  • held() runs BrowsePage live. Four library_route_tests rows and session_dispatch_tests::production_bridges_do_not_share_browse_state_or_landings fail with the page read parked, because they wait for a page landing.
  • Every held runner parks BrowseDirectory. Every suite is green with it parked, and the few rigs that need it run it from the parked set.
  • held_all() parks both. park_page_reads(), a new test-only mode, parks only the page read; the drain rigs use it.
  • LiveKind is now {Hubs, MetaSeason, BrowsePage}.

Gates: ci/check-deps.sh's wall (clock) gate now also covers listing_jobs.rs, as B-A did for section_hubs.rs. This tightens the gate and adds no ledger line.

Ledgers

Before After
ci/allow/workers/data-browse.txt 3 1 (kick_directory, maybe_spawn_owned spawn_small gone)
ci/allow/globals/data-browse.txt 17 15 (the same two functions' client_for gone)
PINNED_LEDGER_TOTALS (workers/globals/forks/fxlanes) 11/68/58/11 9/66/58/11

No ledger line was added or edited. The branch merges main at d51aff4, which includes Metadata M2 (#1023) and ViewState (#1026). The totals were recomputed from the # count: headers on the merged tree.

Tests

Fails-first. 3948e5c was committed first and ran red on the base, with 2 failed: a grid step emits a BrowsePage job and starts no worker, and a filter-menu step emits a BrowseDirectory job.

New tests:

  • Refusal (listing_jobs_tests.rs):
    • a refused page or directory job is settled by the next step, and the step after asks again with the new key;
    • a refused page is asked again at the same offset;
    • a refused genre read leaves the letters read in flight.
  • Runner, per kind:
    • started and answered once;
    • client gone: refused once, then asked again;
    • the system refuses the thread: refused once, then asked again;
    • held: parked, then run;
    • held with the client gone by then.
  • Controlled runs (browse_listing_admission_tests.rs):
    • a controlled Home run's Browse commands emit no page or directory read, in both record and replay mode;
    • the controlled encoder refuses every way to ask for one.
  • Panics: a panicking page lands as a failed page and arms the retry; a panicking directory read lands as an empty list.
  • Reset: reset_clears_the_single_flight_flags_with_the_mailboxes no longer clears the page claim by hand before reset(). It now fails when BrowseAdapter::clear stops releasing the page claim.

Mutation checks. 30 mutations were run against the committed tree, and 29 were killed. That one added a genre kick to run_owned's Discovery arm, which a controlled run never reaches: the controlled arm routes Discovery to apply_discovery, which takes no keys and no outbox. The same mutation placed on the controlled arm itself is killed.

Targeted suites at d9956c7:

  • plx_data: 1246 passed, 0 failed.
  • the app crate: 1048 passed, 0 failed.
  • hostsim, the whole app crate: 1161 passed, 0 failed (return_hold 6, lifecycle 86).
  • The ledger tests and ci/check-deps.sh are green.
  • plx_screens: 1706 passed, 0 failed, before the main merge. Nothing under screens is in this diff.

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. No Makefile, Cargo or workflow file changed, so no build-bench table is needed. There is no FFI or linkage change.

Review. One review, verdict FIX FIRST: one should-fix finding and six notes.

  • F1: the branch conflicted with main (M2's LiveKind and pins). Fixed by the main merge described above.
  • N2: some /// docs named only the hubs read. They now name the directory or page read each path emits.
  • N3: jobs of different kinds can share an Addr. listing_addr now says an Addr is not an identity across kinds. Nothing routes by it.
  • N4: the one-pump-later refusal settlement, stated above.
  • N1, N5, N6: no change needed, as recorded above.

Doc-claim audit. It found eight sentences made false, and all eight are fixed:

  • the Direct admission lists in docs/sans-io.md and the runner's module doc;
  • the "Browse emits four" count, which now names the three kinds;
  • the worker table and a kick_directory sentence in docs/poster-scheduler-design.md;
  • docs/parity-gaps.md's two "Where:" lines;
  • two test-support docs;
  • "the store's one claim", which now reads "the section hubs' one claim" at its four sites.

Live path

Checked in the macOS simulator at 960x540 against a fresh tests/mock_pms.py --movies 200 (four pages of 60), with plex.tv and Discover pointed at the mock and a placeholder token. The identity was read before any key: version=1.41.0.0000-synthetic, owned=1. The run used real remote keys through the instance FIFO.

  • Scrolling the Movies grid past three page windows read /library/sections/1/all at start=0, 60 and 120 once each.
  • The letters directory (/firstCharacter) was read once when the grid booted.
  • Opening Sort & Filter → Genre read /genre once, and the list drew the mock's genres. Nothing was asked again while the menu stayed open.
  • There was no stores: WARN, no BADTRIGGER and no panic.

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

Not in this PR

  • Discovery (B-D), the roster and gate reads (B-E) and the pins (B-F).

🤖 Generated with Claude Code

GLinnik21 and others added 9 commits October 25, 2026 01:34
A grid step must leave its first page as a BrowsePage job and a filter-menu
step its genre and letter reads as BrowseDirectory jobs, starting no worker of
their own. Both are red on this base: the step still takes client_for and
spawns the worker itself, so the store's job outbox stays empty.

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

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The Library's genre and first-letter lists (kick_directory) and its grid pages
(maybe_spawn_owned) stop starting their own workers and stop reading the server
registry in the step. Each read leaves on Browse's outbox as StoreJob::BrowseDirectory
or StoreJob::BrowsePage (both Admission::Direct), carrying the section's ClientKey
captured from the borrowed ClientKeys; the app's StoreRunner resolves it at launch and
refuses the job when the client is gone or the thread is refused. The claim is raised
at the step, lowered by the refusal in the refusing call, and settled at the head of the
store's next step, which asks again with the then-current key.

BrowseAdapter's three AtomicBool claims and Mutex mailboxes become Fetch<..>. The
landings keep commit_if_current / commit_reachability_if_current unchanged.

Ledger: workers 14 -> 12, globals 75 -> 73 (kick_directory and maybe_spawn_owned lose
their spawn_small and client_for lines). The Held test runner starts the page read on a
worker (the library route and dispatch rigs wait for its landing) and parks directory
reads; the drain rigs park both.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ed-run pin

Tests for the page and directory job kinds:
- a refused job is settled by the store's next step (claim down, record consumed) and the
  step after asks again with the registry's current key, for the page and both directory lists;
- the runner's branches per kind: answered once by a worker, client gone (refused once, asked
  again), thread refused (refused once, asked again), held park and run, held with the client
  gone by the time it runs, and Admission::Direct leaves a Home ledger untouched;
- the held runner starts the page read on a worker and parks the directory read;
- a controlled Home run's Browse commands (Reset, a Discovery landing) start no page or
  directory read in record and replay mode, and the controlled encoder refuses every other way
  to ask for one.

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

docs/sans-io.md gains the listing lanes (the filter menus' directory read and the grid's
page read: the keys, the three claims, the refusal settle, the panic guard) and the held
runner's per-kind live set; docs/stores-as-machines.md names the adapter's four Fetches and
the new step-to-job row. The StoreJob admission match states, per kind, why a controlled run
never emits the read and where the pin lives (app/browse_listing_admission_tests.rs; the old
comment named a file that does not exist). browse/mod.rs's top prose no longer says the page
is filled by a spawn_small worker with a Mutex mailbox, or that the client is captured at the
spawn site for every read.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…est per turn

It built both requests before its loop, and the second one's registry replaced the first's, so
the page job's client was gone when the runner resolved it and the job was refused instead of
started. It passed under no filter that matched its name until the whole suite ran.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Metadata M2 (#1023) and ViewState (#1026) landed after the base. Both lanes and this one
added their own test-only LiveKind, took PINNED_LEDGER_TOTALS down from the same base, and
extended the same exhaustive StoreJob matches.

- LiveKind = {Hubs, MetaSeason, BrowsePage}. held() runs all three live, so the season
  switch stays live for menu_play_season_tests and the page read for the library route
  rigs and session_dispatch_tests. park_page_reads() sets {Hubs, MetaSeason}: it parks
  only the page read. held_all() stays [].
- Every StoreJob match in adapters/stores.rs (start, admit_home, retire_parked_details,
  run_held_where) lists both lanes' kinds.
- PINNED_LEDGER_TOTALS = workers 9, globals 66, forks 58, fxlanes 11, recomputed from the
  `# count:` headers of the merged tree (main is 11/68; this lane takes 2 and 2), with
  every lane's comment kept.
- docs/sans-io.md and the stores.rs //! paragraph carry every lane's prose.
- Review notes N2 (the /// docs that named only the section-hubs read now also name the
  directory or page read) and N3 (one sentence: an Addr is not an identity across kinds).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The doc-claim audit of the B-B+C lane found eight sentences the change made false.
Each is reworded in the surrounding style, only the false clause:

- the admission lists (docs/sans-io.md, the adapters/stores.rs //!) name the Library's
  directory and page reads among the Direct kinds;
- LiveKind is "a kind and not a store" because Browse emits several kinds, named, not four;
- docs/poster-scheduler-design.md: the `directory` and `page` workers are started by the
  app's runner (launch_browse_directory, launch_browse_page), only `sources` stays in
  browse/mod.rs; kick_directory reads its list's `*_done` flag, not a `done` argument;
- docs/parity-gaps.md: kick_directory reads one of a closed set of value lists
  (listing_jobs::Directory), and a new axis adds a variant, a Fetch mailbox, a counter
  and a landing;
- browse_dump_tests.rs names the claims that exist (`genres`, `letters`, `page`);
- browse_test_support.rs: the loopback page source leaves its read as a job;
- "the store's one claim" is the section hubs' one claim (BrowseAdapter::hubs.fetch) at
  its four sites, now that the store holds four.

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

The B-B+C lane called `browse.adapter.page.clear()` before `browse.reset()`. Fetch::clear
releases the claim, so the "page fetch stayed latched" assertion passed without reset ever
running against it; the old line only emptied the mailbox. The mailbox is empty already
(nothing was posted), so the line goes. With `self.page.clear()` removed from
BrowseAdapter::clear the test now fails on the page assertion.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…d page reads

browse_directory_addr and browse_page_addr built the same Addr; they are one listing_addr
with the doc that says an Addr is not an identity across kinds. Also the merged runner
paragraph says "every held runner" parks episode-page jobs (Live parks nothing).

Considered and left alone, because each changes a shared signature or a test assertion, or
sits outside this diff: the per-kind launch/run_held arms (the same resolve-else-refuse
shape every other kind has), the two struct literals of finish_directory_with (they differ in
the result type), and section_hubs.rs's own address helper (B-A's file, not in this diff).
This was a single inline pass without the agent fan-out.

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: the Library's directory and listing-page reads leave as store jobs

1 participant