54 lines
3.5 KiB
Markdown
54 lines
3.5 KiB
Markdown
# Review — `fix/two-tabs`
|
|
|
|
Adversarial self-review (CLAUDE.md §5.3). Analysis: [`features/two-tabs.md`](../features/two-tabs.md).
|
|
Reviewed 2026-11-07 on Node 22.11.0, Windows 10. There is no PR: the only remote is Gitea.
|
|
|
|
## The measurement
|
|
|
|
CLAUDE.md §8 predicted *derived state drifts; use a BroadcastChannel lock*. Two e2e tests were
|
|
written first and run against the built app: both **failed** (a tab already open saw neither care
|
|
nor a town chosen in another tab). Reading the code explained why, and showed what the
|
|
prediction got wrong: there is no `derived` store and the log is append-only, so nothing stored
|
|
can drift and no lock is needed. What drifted was each tab's view, which can make the player water
|
|
her twice. Both tests pass after the fix.
|
|
|
|
## Gates
|
|
|
|
Counts are on the merge; HANDOVER repeats them. New: storage +7, ui +3, e2e +2 (the measurement).
|
|
|
|
**The app changed** (CLAUDE.md §5.4), invisibly in one tab: another open tab now follows it.
|
|
Rebuilt by the e2e and offline runs; **not deployed** (G0.13).
|
|
|
|
## Bug drills
|
|
|
|
| Put back | Result |
|
|
|:--|:--|
|
|
| Care is announced before it is written | CAUGHT |
|
|
| A petal is never announced | CAUGHT |
|
|
| A town is never announced | CAUGHT |
|
|
| Any message counts as a change | CAUGHT |
|
|
| The rose replaces her view with a stale read | CAUGHT |
|
|
| The rose does not listen | CAUGHT |
|
|
| The garden ignores a town from another tab | CAUGHT |
|
|
|
|
## Findings
|
|
|
|
| # | Area | Finding | Resolution |
|
|
|:--|:--|:--|:--|
|
|
| 1 | Correctness | A tab's own care can still be on its way to IndexedDB when another tab's news makes it read; a plain replace would drop that care from view, and nothing would bring it back. | The read is added to what the tab shows, never replaces it (the log only grows); drilled. |
|
|
| 2 | Correctness | Two reads overlapping, finishing out of order. | Same answer: each only adds, so order does not matter. |
|
|
| 3 | Correctness | Announcing before the commit would make the other tab read too early. | Announced after `add` / after the transaction resolves; drilled. |
|
|
| 4 | Correctness | A tab mid-pour when the other tab's care arrives: the can now measures against the new level. | Accepted: that is the true level. |
|
|
| 5 | Design | A town arriving while this tab is searching for one: the search closes and the new town shows. | Accepted: the player's choice in the other tab is the newer one. A tab in the middle of *Change town* keeps its open search (only the shown town updates). |
|
|
| 6 | Privacy | A `BroadcastChannel` message. | Same origin, same browser profile only; one word (`log`, `place`), no data. Nothing leaves the device. |
|
|
| 7 | Compatibility | Browsers without `BroadcastChannel` (Safari before 15.4). | Each tab keeps its own view, as before; no data is affected; tested with it removed. |
|
|
| 8 | Process | The measurement commit would have been red on its own. | The branch was regrouped before pushing so every commit is green: the tests land with the fix. |
|
|
| 9 | Process | On 2026-11-07 the root `node_modules` was missing (cause unknown; the code and history were intact). | Restored with `pnpm install --frozen-lockfile`, which also reinstalled the hooks. |
|
|
| — | Soul, reachability, offline | Looked; the fix removes a way the game could blame her care for its own mistake. Nothing new is shown or sent; works offline. | — |
|
|
|
|
## What was not verified
|
|
|
|
- Safari and Firefox (BroadcastChannel across an installed app and a tab); a phone.
|
|
- The KeepSafe path across tabs end to end (bringing her back in one tab, seen in the other):
|
|
covered by the storage test that a brought-back rose announces `log`, not by an e2e.
|