Skip to content

Wave-3 (partial): fix cross-account leak + dead warning indicator + stale hierarchy - #8

Merged
spdotdev merged 3 commits into
mainfrom
ralph/polish-wave3
Jul 4, 2026
Merged

spdotdev merged 3 commits into
mainfrom
ralph/polish-wave3

Conversation

@spdotdev

@spdotdev spdotdev commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Third-wave fixes from a fresh 3-agent audit of the twice-hardened MVP. Loop stopped by request after X1–X5; see inventory-docs/GAP-ANALYSIS-3.md.

  • X1 (HIGH) Logout/login leaked the previous user's data — every repo + HierarchyStore + favorites/default-household prefs are @Singleton and survived logout, so an account switch rendered User A's households/products/missing-items/favorites to User B (loadFromCache repopulates from stale caches before the network returns). Added clear() to each cache (default no-op on the interface so test fakes are unaffected) + a SessionCleaner called on logout and at each new sign-in (covers the reactive-401 path too).
  • X2 (HIGH/MED) Per-location "⚠ needs attention" was dead on load — only a composed ProductsPane populated it, so a missing item on a non-visible shelf showed nothing until the user swiped to it. HierarchyStore now computes locationWarnings authoritatively from server data in loadFromCache + buildFromNetwork.
  • X4 (MED) Household create/join/leave never refreshed HierarchyStore → stale drawer/home/dashboard. Both VMs now refresh() after a successful mutation.

New pure-JVM tests: SessionCleanerTest, HierarchyStore.clear()/warning computation, household-mutation refresh. Gated by compile + testDebugUnitTest.

spdotdev added 3 commits July 4, 2026 17:03
logout() cleared only the bearer token, but every repository +
HierarchyStore + favorites/default-household prefs are @singleton, so an
account switch on the same process rendered User A's households/products/
missing-items/favorites to User B (loadFromCache repopulates from stale
caches before the network returns). Add clear() to each cache (default
no-op on the interface so test fakes are unaffected), HierarchyStore
(reset + cancel in-flight job), and FavoritesStore; centralize in a
SessionCleaner called on logout AND at the start of each new sign-in
(covers the reactive-401 path too). In-memory/prefs only. Tests added.
Home + drawer rendered the needs-attention warning purely from
state.locationWarnings, populated only by a composed ProductsPane, so a
missing mandatory item on a non-visible shelf showed no warning until the
user opened that location and swiped to the shelf — the at-a-glance
rollup silently showed 'all good'. HierarchyStore now computes
locationWarnings in loadFromCache + buildFromNetwork by grouping the
missingItems it already builds by locationId, and refresh takes the
server-computed map as truth. Tests added.
Household mutations updated only the HouseholdRepository cache + their own
UI state, so the drawer/home/dashboard (driven by the @singleton
HierarchyStore) stayed stale until a manual refresh or relaunch. Inject
HierarchyStore into HouseholdsViewModel + JoinHouseholdViewModel and call
refresh() after a successful create/join/leave. Tests assert the store
reflects the mutation via a shared TestHierarchy helper.
@spdotdev
spdotdev merged commit 447950b into main Jul 4, 2026
3 checks passed
@spdotdev
spdotdev deleted the ralph/polish-wave3 branch July 4, 2026 15:17
spdotdev added a commit that referenced this pull request Jul 18, 2026
- HierarchyStore.refresh(): rethrow CancellationException before the
  fold. A superseded refresh painted a stale 'failed to load' over the
  newer load, and a load cancelled by clear() on logout could write the
  PREVIOUS account's hierarchy back after the wipe — the one shared
  store was missing the CE guard every ViewModel already has.
- DrawerViewModel: same CE guards on the list/confirm/undo delete
  pipeline; a session reset mid-flight no longer surfaces a spurious
  'failed to delete' snackbar to the next signed-in account.
- LiveUpdates/PusherRealtimeGateway: every arrival at CONNECTED
  (including the client's internal auto-reconnects) now triggers a
  silent refresh — events broadcast while backgrounded or during a
  network blip were lost and data stayed stale until a manual pull.
  A refused /broadcasting/auth was swallowed (Unit) and killed live
  updates for the process lifetime; it now logs and retries with a
  freshly-read token after a 5s pause.
- Products/ProductDetail: the Undo snackbar is suppressed for plain
  Members — product delete is open to any member but restore is
  restructure-gated server-side, so their Undo tap was a guaranteed
  403 mislabelled 'already restored' (the web gates its Undo flash
  the same way, GAP-7 #8).

Tests: reconnect-refresh + auth-retry cases added to LiveUpdatesTest.
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.

1 participant