Skip to content

Give each Bridge its own Hubs store - #112

Merged
GLinnik21 merged 4 commits into
mainfrom
stores/hubs
Sep 17, 2026
Merged

GLinnik21 merged 4 commits into
mainfrom
stores/hubs

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Third layer of the per-Bridge store-ownership migration (after Person #110 and Search #111). The Hubs catalog (pms.rs) is now owned per Bridge through HubsStore instead of process-wide statics.

  • PmsState, a plain main-thread state struct, holds the published Home catalog, per-server fetch/backoff sources, the roster fingerprint and the hub, sections and catalog generations.
  • Arc<PmsAdapter> holds the worker landing mailbox and the request counter. spawn_fetch captures its owner's adapter, and Reset rotates it, so a worker started before a reset can only land in the retired mailbox.
  • Bridge's hubs snapshot is sourced from its owner. Global facades, stores::hubs::apply* and the Hubs arm of the global stores::apply are gone. There is a new zero-tolerance hubs-owner gate in ci/check-deps.sh.
  • Detail captures its selected catalog row at construction instead of holding a &'static into the global catalog, and PlayIntent::Movie owns its movie.
  • Docs updated: only metadata still keeps compatibility globals.

Tests

  • stores::hubs::contract_tests::a_landing_reaches_only_the_owner_whose_adapter_it_was_minted_from checks that a landing queued in owner A's adapter never reaches owner B, and that after Reset the retired landing reaches neither. Simulated red: with a shared default adapter it failed at "it must never reach a different owner", and with rotation disabled it failed on the rotation and retired-landing assertions.
  • The six pms_* test files and the app/screens seeding were ported to owned stores.
  • Local: make check, --no-default-features check, ci/check-deps.sh and ARM make. SCREEN_SHAPES_PIN is unchanged.

Open questions

  • Stores::take_notices order is now Browse, Metadata, Hubs (was Browse, Hubs, Metadata). Nothing observed depends on it; recorded fixtures are re-recorded in the cleanup PR anyway.
  • controlled_with_directory(Some(Reset)) (replay path) does not rotate the adapter, unlike the production Reset. It is safe because the per-owner hub_gen fence drops stale landings, but the two paths differ.
  • The two-owner test covers mailbox isolation, not catalog state or notices across two owners.
  • From Copilot, both pre-existing on main before this PR, so they are not fixed here:
    • ui::landgate keeps its replay schedule per StoreId, not per Bridge. A two-Bridge replay would share the Hubs landing quota. Replay runs one Bridge.
    • capture_views queues a fallback StoreChanged(Hubs) without the hubs_notified suppression that Browse and Search have. When the store's own notice also fires, live screens reconcile a Hubs change twice. The cleanup PR will add the flag if a test shows the double delivery.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Em5yYDNi5A2peYR6oPMXwD

GLinnik21 and others added 4 commits September 17, 2026 19:31
…Movie owns its row

Give DetailScreen an owned `selected: Option<PmsMovie>` captured once at
construction, the same way `ground`'s blur envelope already is -- a
construction-time fallback used only before/if metadata::current() has a
Detail for this item, never re-read from the catalog afterward. `selected()`
now returns `Option<&PmsMovie>` borrowed from that field instead of a
`&'static` catalog read.

PlayIntent::Movie now owns its PmsMovie instead of borrowing it `'static`,
since it is nothing but a two-tuple until it crosses into an owned per-Bridge
store in the next stage, and there is no `'static` catalog row left for
DetailScreen to hand out once the row itself is owned. The one construction
site (play_hero) clones the borrowed selected() row into the variant;
request_play_movie and request_play_intent take PlayIntent::Movie by
reference regardless, so neither needed to change.

dev/scenarios.rs needed no change: its hub_item()/request_play_movie() call
does not construct a PlayIntent and both keep their existing signatures
through this stage -- pms.rs's own statics/lifetimes are untouched here,
per the stage boundary ("compiles on the current globals").

Behaviour-preserving plumbing, not a fix: 240 screens::detail tests plus the
full route::decision and dev::scenarios suites pass unchanged, and nothing
in this stage re-reads the catalog live while Detail is mounted, so no
republish-while-open refresh path was needed or invented.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Em5yYDNi5A2peYR6oPMXwD
Converts pms.rs's process-wide Hubs globals (catalog, sources, seen/
seen_facts, hub_gen, last_sections_gen, catalog_gen, the results mailbox,
next_request minter) into a main-thread PmsState plus an Arc'd PmsAdapter,
mirroring the SearchState/SearchAdapter/SearchStore pattern. stores/hubs.rs
becomes a HubsStore struct (state + rotated adapter + notice_gen/notice_dirty)
added as an owned field on Stores. Bridge's per-frame `hubs` snapshot and
every command/landing/tick dispatch route through Stores.hubs instead of the
retired stores::hubs::apply*/controlled* free functions; spawn_fetch now
takes the owning adapter Arc explicitly rather than reaching a global.
pms/initial.rs's boot restore/capture are now pure: `restore` produces a
(PmsState, PmsAdapter) pair for `Bridge::controlled_home` to seed a fresh
HubsStore from (via `HubsStore::from_parts`), and `capture` reads an
explicit state/adapter pair instead of a global.

Deleted the RESULTS/NEXT_REQUEST/HUB_GEN/LAST_SECTIONS_GEN/CATALOG_GEN
statics and the free `catalog_gen()` selector outright (confirmed dead, no
remaining readers). The handful of explicit-state helpers that only
test/dev code still calls (`pms::run`, `movie`, `index_of_rk`, `hub_item`,
`catalog`, `Initial::snapshot`/`capture`, `Bridge::with_publications`) are
now `#[cfg(test)]` rather than deleted, since Stage 3 ports their callers
onto the owned rig.

Threaded a `HubsView` parameter through the few production screens that
read the hub catalog directly instead of through a Bridge snapshot:
`DetailScreen::new` (added `HubsView::find(sid, rk)`), `screens::family::
pre_home_ground`, `OnboardScreen::first_run`, and `screens::settings::
RouteSurface::new` (FirstRunConsent only).

Added a zero-tolerance `hubs-owner` gate to ci/check-deps.sh mirroring
search-owner. It currently fails on the six pms_*_tests.rs files and other
test call sites still using the retired stores::hubs::apply* free
functions (test-only, not compiled by `cargo check --lib`) — Stage 3 ports
those onto HubsStore and the gate goes green.

Verified: `cargo +nightly check --lib` clean on default features,
`--no-default-features`, and `--features hostsim`.

WIP: test targets (pms_*_tests.rs, stores/hubs.rs's contract_tests,
pms/initial.rs's tests, screens/detail/tests.rs, and the app/screens test
seeding this touches) do not yet compile — Stage 3.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Em5yYDNi5A2peYR6oPMXwD
Port the six pms_*_tests.rs-family files, pms/initial.rs's test module,
app/screens test seeding, and a two-owner regression test onto the owned
HubsStore/Stores rig, replacing the deleted process-wide pms/stores::hubs
facades at every call site.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Em5yYDNi5A2peYR6oPMXwD
stores/hubs stages 1-3 gave each production Bridge its own HubsStore
(PmsState/Arc<PmsAdapter>/notice), so pms.rs's remaining compatibility-
global claims in docs/stores-as-machines.md, docs/agent-reference.md and
pms.rs's own module doc are now false. metadata is the only store still
on the older compatibility arrangement.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 17, 2026 16:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Address the shared replay landing gate and duplicate Hubs notifications.

Pull request overview

Migrates Hubs/PMS catalog state from process-wide globals to per-Bridge ownership, including isolated worker mailboxes, snapshots, resets, and updated consumers.

Changes:

  • Adds owned HubsStore state and adapter rotation.
  • Updates application paths, screens, tests, replay, and documentation.
  • Adds dependency enforcement for Hubs ownership.
File summaries
File Description
rust-modules/src/viewstate.rs Removes global Hubs usage.
rust-modules/src/stores/mod.rs Integrates owned Hubs storage.
rust-modules/src/stores/hubs.rs Implements per-Bridge Hubs ownership.
rust-modules/src/screens/settings.rs Passes owned snapshots.
rust-modules/src/screens/settings_root_navigation_tests.rs Updates settings fixtures.
rust-modules/src/screens/settings_pop_and_remember_tests.rs Updates settings fixtures.
rust-modules/src/screens/settings_draw_and_lifecycle_tests.rs Updates lifecycle fixtures.
rust-modules/src/screens/settings_composed_tests.rs Updates composed fixtures.
rust-modules/src/screens/registry.rs Uses owned Hubs data.
rust-modules/src/screens/onboard.rs Uses owned snapshots.
rust-modules/src/screens/home/tests.rs Ports Home fixtures.
rust-modules/src/screens/family.rs Uses supplied Hubs views.
rust-modules/src/screens/detail/tests.rs Updates detail fixtures.
rust-modules/src/screens/detail/mod.rs Captures selected catalog rows.
rust-modules/src/screens/detail/identity_tests.rs Updates selection state.
rust-modules/src/screens/detail/geometry_tests.rs Updates detail fixtures.
rust-modules/src/pms/initial.rs Restores owned PMS state.
rust-modules/src/pms_test_support.rs Adds owner-scoped helpers.
rust-modules/src/pms_multi_source_merge_tests.rs Ports merge tests.
rust-modules/src/pms_local_edit_tests.rs Ports edit tests.
rust-modules/src/pms_hero_pool_tests.rs Ports hero-pool tests.
rust-modules/src/pms_fetch_retry_tests.rs Ports retry tests.
rust-modules/src/pms_catalog_commit_tests.rs Ports catalog tests.
rust-modules/src/dev/scenarios.rs Reads Bridge-owned snapshots.
rust-modules/src/app/viewstate_directory_policy_tests.rs Uses owned Hubs operations.
rust-modules/src/app/session_dispatch_tests.rs Updates Hubs dispatch tests.
rust-modules/src/app/run.rs Routes refreshes through Bridge.
rust-modules/src/app/recorder.rs Records owned Hubs state.
rust-modules/src/app/home_retention_tests.rs Ports retention tests.
rust-modules/src/app/content.rs Uses owned catalog snapshots.
rust-modules/src/app/bridge.rs Integrates Hubs lifecycle and dispatch.
rust-modules/src/app/bridge_test_support.rs Removes obsolete cleanup.
rust-modules/src/app/bootstrap/tests.rs Updates controlled Hubs tests.
rust-modules/src/app/bootstrap.rs Threads Hubs ownership through execution.
rust-modules/src/app/boot.rs Restores and resets owned state.
docs/stores-as-machines.md Documents Hubs ownership.
docs/agent-reference.md Updates architecture guidance.
ci/check-deps.sh Adds the Hubs ownership gate.
Review details

Suppressed comments (2)

rust-modules/src/app/bridge.rs:1580

  • landgate keeps one replay schedule/counter per StoreId::Hubs, not per Bridge. With two Bridges in a replay, the first bridge to call this can consume the Hubs landing quota for the other bridge (or hold its mailbox based on the other owner's schedule), so the new per-owner mailbox isolation is lost at the delivery gate. Key the landing-gate state by the owning Bridge/adapter, or explicitly bypass the shared gate for non-production owners and add a two-Bridge replay regression test.
    fn take_hubs_results(&self) -> AppResults {
        let mut results =
            crate::ui::landgate::take_all(StoreId::Hubs.ord(), || self.stores.hubs.take_results());

rust-modules/src/app/bridge.rs:756

  • When a Hubs landing changes the catalog between frames, this comparison queues StoreChanged(Hubs) here, but HubsStore::land_with_directory has already marked its notice and the loop in frame_ingest drains that same notice immediately afterward. Unlike Browse/Search, there is no hubs_notified suppression flag, so every such landing is delivered twice to every live screen and reconciled twice. Track whether the Hubs notice was drained and only enqueue this fallback when it was not, as is done for the other captured stores.
        let before = (self.hubs.view().generation, self.hubs.view().state);
        self.hubs = self.stores.hubs.snapshot();
        let after = (self.hubs.view().generation, self.hubs.view().state);
        if before != after {
            // This is queued before input deliveries. Key projections catch up to the newly
            // captured publication before any action or draw can read it, including status-only
            // landings which the legacy pump's catalog-generation notice cannot see.
            d.store_changed(StoreId::Hubs.ord(), after.0);
  • Files reviewed: 39/39 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@GLinnik21
GLinnik21 merged commit 555589b into main Sep 17, 2026
6 checks passed
@GLinnik21
GLinnik21 deleted the stores/hubs branch September 17, 2026 17:18
GLinnik21 added a commit that referenced this pull request Sep 18, 2026
The store-ownership migration's last owed item was the device pass; layers
#110/#111/#112/#119 and the cleanup #121 were host-verified only until now.
The player-lane scrub legs (paused scrub, tap commit, dropped-keyup net) all
passed on the real pipeline. The ownership legs showed a clean boot-time
activation reset, but the reused-Bridge case #119 was actually about could
not be reached: the only in-app route to a second activation on a live
Bridge is the profile picker, and that route is broken for a managed user.

Two new findings came out of hitting that dead end: the profile chip and
account overlay name the account holder rather than the signed-in managed
user, and "Change profile" as a managed user spins forever on a 401 from
the home-roster endpoints with no error, nothing logged, and Back inert —
only Sign out escapes. Filed as separate issues, along with the pointer
scrub path having no device-drivable coverage at all (no held-pointer
token in the FIFO, and the one reachable synthetic click didn't engage the
scrub band).


Claude-Session: https://claude.ai/code/session_01Em5yYDNi5A2peYR6oPMXwD

Co-authored-by: Claude Opus 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.

2 participants