Repository navigation
Give each Bridge its own Search store - #111
Merged
Merged
Conversation
Ports the Search layer to the store-ownership pattern established by Browse/Person/ViewState: SearchStore (stores/search.rs) now owns the SearchState, the rotated Arc<SearchAdapter> worker, and the store's notice, with one instance per Bridge. The process-wide compatibility facade (crate::stores::search::apply/snapshot and the crate::search free-function reads) is gone; callers go through owned SearchStore methods and screens receive per-owner query/shelf/snapshot reads. ViewState's optimistic local-edit fan-out (viewstate.rs) is updated to call the owning Bridge's Search store through an injected callback instead of the retired global apply(), so a watched/unwatched press still updates Search's roster within the same sync step. Adds a search_owner_matches gate to ci/check-deps.sh, mirroring person_owner_matches, and two regression tests in viewstate_directory_policy_tests.rs proving two Bridge owners share no Search state, notices, or adapter identity. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…e state P2 from Opus review: the two-owner test only compared query text and notices, both of which live on SearchState — neither exercises the adapter mailbox a real fetch actually lands through, so a shared Arc<SearchAdapter> across owners would have passed unnoticed. Adds land_for_test (search.rs) to post a landing straight into a given adapter's mailbox, bypassing the worker, without exposing the private Projection type outside the module. The two-owner test now lands a row into Bridge A's adapter and proves Bridge B's pump cannot see it, then that A's own pump does. The reset/fencing test now lands into the RETIRED adapter at the post-reset generation, proving the current store's pump structurally cannot reach it (previously it landed into an adapter nothing had spawned against, which passed even without rotation, since reset() also clears the live adapter's mailboxes regardless). Simulated RED (that pre-port shape no longer exists on disk to run directly): temporarily made SearchStore::default hand out one shared Arc<SearchAdapter> and disabled rotation in run_with_directory's Reset arm. The two-owner test failed at "Bridge A's own pump must land its own row" (B's earlier pump drained the shared mailbox first). With rotation alone disabled, the reset/fencing test failed at "reset must rotate the Search worker adapter". Both reverted after observing red. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The architecture documentation is stale and one recents regression test no longer compares snapshots from the same owner.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Moves Search state, worker transport, and notices from process-wide globals into each Bridge’s SearchStore, while routing ViewState optimistic edits through the owning Search store.
Changes:
- Introduces per-owner
SearchState,SearchAdapter, notices, and reset fencing. - Updates Bridge/ViewState/store wiring and tests.
- Adds the
search-ownerdependency gate.
File summaries
| File | Description |
|---|---|
rust-modules/src/viewstate.rs |
Routes optimistic edits through Search owners. |
rust-modules/src/stores/viewstate.rs |
Passes Search callbacks through ViewState. |
rust-modules/src/stores/search.rs |
Adds owned Search state, adapter, and notices. |
rust-modules/src/stores/mod.rs |
Integrates Search into Stores. |
rust-modules/src/search/view.rs |
Builds snapshots from owned state. |
rust-modules/src/search/recents.rs |
Updates owned-state test usage. |
rust-modules/src/search.rs |
Replaces global Search state with explicit owners. |
rust-modules/src/search_test_support.rs |
Adds owned Search fixtures. |
rust-modules/src/search_query_debounce_tests.rs |
Migrates debounce and reset tests. |
rust-modules/src/search_publication_tests.rs |
Migrates publication tests. |
rust-modules/src/search_account_scope_tests.rs |
Migrates roster and favourite tests. |
rust-modules/src/screens/search/tests.rs |
Uses per-test Search stores. |
rust-modules/src/dev/scenarios.rs |
Uses mutable Bridge Search commands. |
rust-modules/src/app/viewstate_directory_policy_tests.rs |
Adds multi-Bridge and reset-fencing tests. |
rust-modules/src/app/surface_navigation_tests.rs |
Uses owner-local generations. |
rust-modules/src/app/session_dispatch_tests.rs |
Updates ViewState pump calls. |
rust-modules/src/app/search_publication_tests.rs |
Tests owned publication delivery. |
rust-modules/src/app/search_owned_tests.rs |
Migrates owned Search scenarios. |
rust-modules/src/app/bridge.rs |
Routes Search through Bridge stores. |
rust-modules/src/app/bridge_test_support.rs |
Removes obsolete global cleanup. |
ci/check-deps.sh |
Adds zero-tolerance Search ownership checks. |
Review details
Suppressed comments (1)
rust-modules/src/search.rs:623
- This documentation names
SearchStore::runas the production caller, but that method is#[cfg(test)]; production routes throughStores::search_runtoSearchStore::run_with_directory. Please name the production wrapper here so the reset/adapter ownership contract is not misdocumented.
/// Synchronous command path. `stores::search::SearchStore::run` is the one caller in
/// production and is what rotates `adapter` on `SearchCmd::Reset`.
- Files reviewed: 21/21 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+337
to
+341
| let outer = crate::search::SearchState::default().snapshot(); | ||
| assert!(remember_with(first.generation(), "beta", || submissions += 1)); | ||
| assert_eq!(first.terms(), &["alpha"]); | ||
| assert_eq!(snapshot().terms(), &["beta", "alpha"]); | ||
| let changed = crate::search::view::snapshot(); | ||
| let changed = crate::search::SearchState::default().snapshot(); |
Comment on lines
+84
to
+86
| //! makes two `Bridge`s share neither a query, a landing nor a notice. `SearchStore::run` rotates | ||
| //! `adapter` to a fresh `Arc` on `SearchCmd::Reset`, so a worker spawned before the reset can only | ||
| //! ever complete into the retired mailbox it captured. |
Comment on lines
+1
to
+2
| //! The physically owned Search model and fetch transport (`docs/stores-as-machines.md`). Each | ||
| //! production `Bridge` owns one [`SearchStore`]; no free selector can connect two Bridges. |
- recents.rs test: take both snapshots from one retained SearchState owner instead of two independent defaults, so the query-generation equality actually proves stability rather than being trivial. - search.rs doc comments: point at the production entry point (SearchStore::run_with_directory) instead of the test-only SearchStore::run. - docs/stores-as-machines.md, docs/agent-reference.md: Search is now owned per Bridge (alongside Browse, Person, ViewState); only pms and metadata still retain compatibility globals/mailboxes. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This was referenced Sep 17, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second layer of the per-
Bridgestore-ownership migration (after Person, #110). Search's mutable state (query, shelves, phase, generation, roster fence, favourites snapshot, debounce), its worker adapter (per-source in-flight claims and mailboxes) and its notice are now owned by eachBridgethroughStores, not by process-wide statics.search.rsare gone;stores::search::applyand the free Search reads are deleted.SearchStorethrough an injected callback instead of the retired globalapply.Resetrotates the worker adapter, so a worker started before the reset can only write into the retired adapter.search-ownergate inci/check-deps.sh.Tests
separate_bridges_do_not_share_any_search_owner_state_or_notice: a row landed for Bridge A is invisible to B's pump and lands on A's. Simulated red: a shared default adapter failed it.search_reset_rotates_the_adapter_and_fences_a_late_old_worker: a late landing into the pre-reset adapter at the post-reset generation does not land. Simulated red: with rotation disabled it failed.make check,--no-default-featurescheck,ci/check-deps.sh, ARMmake(before the test-only fix round).Open questions
search/scope.rsstatic mut CACHEholds one entry. Content never crosses owners, but two Bridges pumping alternately would rebuild it every frame (an extraStoreChanged+ repaint each). Production runs one Bridge. Allowlist reason line or per-owner cache: decided in the cleanup PR.search/recents.rsSTORE/PENDINGstay process-wide: recents are disk-persisted per profile, so sharing them across Bridges on one profile is correct.search_facadesinci/check-deps.shexcludesresetbecausesearch.rskeeps a module-levelfn reset(state, adapter); revisit if that surface changes.🤖 Generated with Claude Code
https://claude.ai/code/session_01Em5yYDNi5A2peYR6oPMXwD