92 lines
5.9 KiB
Markdown
92 lines
5.9 KiB
Markdown
# Keep her safe — the browser's promise, a file, and bringing her back
|
|
|
|
Status: built on `feature/keep-her-safe`. Gap G0.11, CLAUDE.md §8: *IndexedDB is evictable … call
|
|
`navigator.storage.persist()` where it exists, prompt iOS players to install, and make export-my-rose
|
|
a first-class feature. A player returning to find their rose gone is the cruellest bug this product
|
|
could have.* Review: [`feature-keep-her-safe.md`](../reviews/feature-keep-her-safe.md).
|
|
|
|
---
|
|
|
|
## 1. Why and what, in the player's terms
|
|
|
|
Beside *Her numbers* there is now **Keep her safe**. It opens a small, quiet section:
|
|
|
|
- **What the browser has promised**, in one true sentence: that it keeps her, or that it may clear
|
|
her if the garden is not opened for a long time.
|
|
- **Ask the browser to keep her**, when it has not promised yet. If it says no, that is said calmly,
|
|
and the file is the answer.
|
|
- On an iPhone or iPad that has not added the garden to the Home Screen: *add it, to keep her.*
|
|
- **Save her to a file**: a small file the player keeps, named for the day. It holds her care and
|
|
when it was given; it never holds the town.
|
|
- **Bring her back from a file**: on a new phone, or after the browser cleared her. Everything she
|
|
had comes back, and nothing she has now is lost. Bringing the same file twice adds nothing twice.
|
|
|
|
An installed garden asks the browser to keep her by itself, once, after the first care of a visit.
|
|
|
|
## 2. Technical architecture
|
|
|
|
```mermaid
|
|
flowchart LR
|
|
subgraph app["apps/rosea"]
|
|
wire["App.svelte<br/>navigator.storage, file download"]
|
|
end
|
|
subgraph ui["packages/ui"]
|
|
keep["KeepSafe.svelte"]
|
|
rose["Rose.svelte<br/>keys = current + past"]
|
|
end
|
|
subgraph storage["packages/storage"]
|
|
exp["exportRose / importRose<br/>asRoseFile"]
|
|
past[("profile: pastKeys")]
|
|
ev[("events")]
|
|
end
|
|
subgraph engine["packages/engine"]
|
|
replay["roseAt(events, keys)<br/>one replay per key"]
|
|
dedupe["newCare: each act once"]
|
|
end
|
|
wire --> keep --> exp --> ev & past
|
|
exp --> dedupe
|
|
rose --> replay
|
|
```
|
|
|
|
### Decisions
|
|
|
|
| # | Decision | Why |
|
|
|:--|:--|:--|
|
|
| K1 | The file holds `{ format: 'rosea-rose', version: 1, keys, events }`: her public keys and her whole care log. **Never the private key** (it cannot be exported: rose.md R9), **never the sunset town**. | The town is the one location Rosea knows; choosing it again is one tap. The care log alone is what cannot be remade. |
|
|
| K2 | A rose is named by **a list of keys**: the current identity first, then the keys she had on other devices (`profile.pastKeys`). | The private key cannot move, so a rose brought back lives under a new key, and her old care names the old one. The log is never rewritten (CLAUDE.md §6.2). |
|
|
| K3 | **Each key's care is replayed on its own**; her days of care are the union. Water and today's needs come from the current key; stage, drift and warmth from all. | Replaying everything as one log could take a day away: one device's watering can make the other's "too much". Separate replays make bringing her back strictly additive, which is property-tested. |
|
|
| K4 | Import **appends only acts not already there** (same moment, giver, rose, act and amount) in one transaction, and **refuses a file that is not a rose** before writing anything. | Contributions only add (CLAUDE.md §1). A wrong file is an ordinary mistake, said calmly. |
|
|
| K5 | `persist()` is called **automatically only in an installed app**, once per visit, after the first care. Otherwise only when the player asks. | Chrome and Safari grant or refuse silently; Firefox shows a prompt. A prompt the player did not ask for, right after watering, would be a strange interruption. |
|
|
| K6 | The download is made on the device (`Blob`, `<a download>`), and the import reads a file the player picks. | Nothing is sent anywhere; the CSP stays `'self'`. |
|
|
|
|
## 3. Risk analysis
|
|
|
|
| Risk | Answer |
|
|
|:--|:--|
|
|
| **The cruellest bug**: her care gone. | The file brings it back on any device, tested end to end with a fresh browser profile. |
|
|
| **Privacy**: the file is a diary of when someone was in the app. | It is made only when the player asks, stays wherever they put it, and the screen says what it holds. No town, no private key (tested). |
|
|
| **Feeling worse**: "the browser may clear her" can frighten. | It is said once, only on request, with the remedy in the same sentence. |
|
|
| **A merged rose loses days.** | K3, property-tested: merging two logs never lowers either one's days of care. |
|
|
| **A tampered file** gives a rose days she was never given. | It only fools the player's own garden; nothing is compared with anyone (CLAUDE.md §1, *never count people*). Phase 3 must not trust imported care as proof towards friends. |
|
|
|
|
## 4. Gap analysis
|
|
|
|
| Gap | State |
|
|
|:--|:--|
|
|
| G0.11 eviction: `persist()`, export-my-rose | Built: persist on request and when installed; save; bring back |
|
|
| A reminder to save her now and then | Open: no nagging by design; the Letter can mention it |
|
|
| iOS install prompt beyond one sentence | Open: Safari has no install API |
|
|
|
|
## 5. Verification matrix
|
|
|
|
| Case | Kind | Where |
|
|
|:--|:--|:--|
|
|
| A moved rose keeps every day under her old key; her water starts afresh; care under the new key adds | unit | `engine/test/rose.test.ts` |
|
|
| A moved rose that is opening drops petals, and gathering them helps | unit | same |
|
|
| Merging two logs never takes a day from either | property | same |
|
|
| `newCare` adds each act once, however often | unit | same |
|
|
| The file holds keys and care, no town, no private key; survives JSON | unit | `storage/test/rose-file.test.ts` |
|
|
| Bringing her back on a new device, twice, onto a device with care of its own, from this very device; refusing seven kinds of not-a-rose and changing nothing | unit | same |
|
|
| Keep her safe: the browser's answer, asking, a refusal said calmly, saving a dated file, bringing her back, a wrong file | unit | `ui/test/rose.test.ts` |
|
|
| Save on one browser profile, bring her back on a fresh one, reload: one day of care; the file has no town; axe | e2e | `e2e/shell.spec.ts` |
|