[docs] DaySentence: Analysis, review, lessons, and G1.5 closed for the code
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
# The day's sentence — the rose's folded petal
|
||||
|
||||
Status: built on `feature/day-sentence`. ROADMAP Phase 1: *the day's sentence comes from the rose: she
|
||||
waits with a folded petal; sunset is the best moment to open it, but it is never lost and no streak
|
||||
exists.* GAMEPLAY.md §1: *coming back on nearby days gives a little more (e.g. an earlier sentence
|
||||
remembered). A gap is never punished.* CLAUDE.md §1, §5.5 (*an unopened sentence is never lost*),
|
||||
§6.1, §6.2. Review: [`feature-day-sentence.md`](../reviews/feature-day-sentence.md).
|
||||
|
||||
## 1. Why and what, in the player's terms
|
||||
|
||||
When the rose needs nothing, she says *I am keeping a folded petal for you.* A folded petal lies by
|
||||
her, and one button: **Open her petal**. It opens into one sentence of hope, with where it comes from in
|
||||
small print.
|
||||
|
||||
- **One a day.** Once opened, it stays open for the rest of the local day (*Today's petal*); a new
|
||||
one is folded tomorrow.
|
||||
- **Never lost.** A petal not opened today is the same petal tomorrow, and next week. There is no pile
|
||||
of missed petals and nothing says how many days passed.
|
||||
- **Sunset is the best moment.** Around the real sunset (the same moment the sunset line names; in
|
||||
polar day the lowest light, in polar night the brightest twilight) she says *The sun is low now.
|
||||
Would you open my petal?* Opened then, she adds: *Go and look at the sky. I will be here.* It can
|
||||
be opened at any other time too, with no difference in what it gives.
|
||||
- **Nearby days give a little more.** If the last petal was opened at most three days ago, she also
|
||||
remembers one opened before: *Do you remember this one?* After a longer gap she simply gives the
|
||||
day's petal. The gap is not mentioned.
|
||||
- **No library, no petal.** Until the author has verified sentences, she holds no petal and says
|
||||
nothing about one. Nothing on screen points at the absence.
|
||||
|
||||
Nothing is counted: there is no number of petals, no list of all of them, no record of when.
|
||||
|
||||
## 2. Technical architecture
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
lib["content/library/*.json<br/>(verified by the author)"] -->|"build: validate:library,<br/>then virtual:rosea-library"| app["apps/rosea<br/>App.svelte"]
|
||||
cand["content/candidates/*.json<br/>(proposed, unverified)"] -->|"pnpm library:verify id… --by Name<br/>(the author only)"| lib
|
||||
app --> ui["packages/ui<br/>Rose.svelte + Petal.svelte"]
|
||||
ui --> engine["packages/engine<br/>petal/petal.ts: petalAt, goodMoment"]
|
||||
engine --> schema["packages/schema<br/>sentence-opened.schema.json"]
|
||||
ui -->|"appendOpened"| storage["packages/storage<br/>events store, rose file v2"]
|
||||
```
|
||||
|
||||
| # | Decision | Why |
|
||||
|:--|:--|:--|
|
||||
| P1 | **The petal is the next sentence in one fixed order**, and the order moves only when a petal is opened. The order: sunset sentences never opened, by `verifiedAt` then a hash of the id; once all are opened, the one opened longest ago. | *Never lost* (CLAUDE.md §5.5) follows from the order: nothing advances by itself. Verifying new sentences adds them after the ones already verified, so it never swaps the petal she holds. With ≥ 365 sentences, none repeats within a year of daily opening. The hash mixes traditions, so the first days are not all one book. |
|
||||
| P2 | **One opening per local day.** The first `sentence-opened` event of a local day is that day's petal; a second tab's later one changes nothing. | No farming, no reason to stay. `localDay` is the one recorded in the event (CLAUDE.md §7). |
|
||||
| P3 | **Remembering** needs the previous opening ≤ `PETAL.nearDays` (3) local days before today and an earlier sentence to recall; which one is a pure, seeded choice per day. | GAMEPLAY §1. A gap is never shown: the extra line is simply absent. Tuning is the author's, in `PETAL`. |
|
||||
| P4 | **The good moment** is `PETAL.beforeMinutes` (60) before to `PETAL.afterMinutes` (60) after the sun module's `invitation`. It changes only her words. | One sun module (CLAUDE.md §7); the best moment is offered, not rewarded (*Gentle*). |
|
||||
| P5 | **The library is bundled at build time** through a Vite virtual module that reads `content/library/*.json`; the app build first runs `validate:library` and fails if it fails. The app never validates in the browser. | Sidesteps G0.12 (Ajv needs `new Function`; the CSP forbids it) without a second validator: what ships is exactly what passed the gate. `ROSEA_LIBRARY_DIR` swaps the folder for the e2e build. |
|
||||
| P6 | **A new event kind, `sentence-opened`** (`ts`, `localDay`, `from`, `messageId`, `clientVersion`), appended to the same `events` store. | CLAUDE.md §6.2: adding a kind is the only sanctioned way to make something derivable. |
|
||||
| P7 | **The rose file becomes version 2** with an `opened` list beside `events`; version 1 files are still read. | Her petals move with her to a new device, so the order continues instead of starting over. |
|
||||
| P8 | **Candidates live in `content/candidates/`**, in the library's shape without `publicDomain`, `verifiedBy`, `verifiedAt`, and with a `check` (where to read it). `validate:library` holds them to every rule but verification, so the author is never asked to verify a line that would fail. `pnpm library:verify <id…> --by <name>` moves them into the library with today's date. **Agents never run it.** | D4 of phase0-workspace: `verifiedBy` is a person. The command only saves the author hand-editing JSON. |
|
||||
| P9 | The source is shown under the sentence (work, author, translation). | Honesty about where words come from; it also tells a believer and a non-believer what kind of line it is. |
|
||||
|
||||
## 3. Risk analysis
|
||||
|
||||
| Risk | Answer |
|
||||
|:--|:--|
|
||||
| **Guilt**: a pile of unopened petals after an absence. | P1: there is only ever one petal. Nothing names the days between. |
|
||||
| **Streak creep**: remembering on nearby days is a streak in disguise. | P3 rewards nothing visible and counts nothing; after a gap the day's petal is exactly as full. It is a small gift, not a bar to keep up. Reviewed in `soul.md` terms in the review. |
|
||||
| **Dependence**: a reason to stay in the app. | One petal a day; at the good moment her words send the player outside. |
|
||||
| **Comfort becomes wallpaper** (CLAUDE.md §8). | No repeat until every sentence has been opened once (P1). |
|
||||
| **A hollow or harmful sentence**: a promise, a medical word, the unnamed state. | The validator's rules (§5.6), held for candidates too (P8); the author verifies every line. |
|
||||
| **Copyright**: a modern translation slips in. | The translation list in `validator.ts`; additions need a dated reason. Candidates carry `check.publicDomain`. |
|
||||
| **Privacy**: which sentences were opened. | Stays on the device; the rose file holds it, never the town. Nothing is sent. |
|
||||
| Reachability | None: nothing reaches another person. |
|
||||
| **Offline** | The library is precached in the bundle; opening appends to IndexedDB. |
|
||||
|
||||
## 4. Gap analysis
|
||||
|
||||
- **G1.5** (the day's sentence) closes with this, except that the library is still empty: the petal
|
||||
appears in the shipped app only once the author verifies sentences (G0.18).
|
||||
- **G0.12** narrows: the app does not need to validate content in the browser while the library is
|
||||
bundled. It reopens if the library is ever fetched at runtime.
|
||||
- **Not done:** Czech text (`text.cs`) is not shown yet (Czech copy arrives as a whole, G1.3); a
|
||||
collection of past petals (an album) is not designed.
|
||||
|
||||
## 5. Verification matrix
|
||||
|
||||
| Case | Kind | Where |
|
||||
|:--|:--|:--|
|
||||
| No sentences: nothing; first visit: the first in order is folded | unit | `engine/test/petal.test.ts` |
|
||||
| Opening today: open for the rest of the day; tomorrow: the next one folded | unit | same |
|
||||
| **Property:** with no opening, the folded petal is the same on every day | property | same |
|
||||
| **Property:** adding sentences verified later never changes the folded petal | property | same |
|
||||
| **Property:** at most one opening per local day counts; a second changes nothing | property | same |
|
||||
| **Property:** no repeat until every sentence was opened; then the least recent | property | same |
|
||||
| Remembering: at 1–3 days a recalled earlier one; at 4+ none; never today's own | unit | same |
|
||||
| Good moment: inside ±60 min of the invitation; polar day and polar night | unit | same |
|
||||
| Events from other roses' keys are ignored; past keys count | unit | same |
|
||||
| The schema accepts the event and rejects free text in `messageId` | unit | `schema/test` |
|
||||
| Storage: append and load opened; `loadCare` ignores them quietly; rose file v2 out, v1 and v2 in, additive | unit | `storage/test` |
|
||||
| Candidates: held to every rule; `library:verify` moves, stamps, refuses an unknown id or a failing line | unit | `content/test` |
|
||||
| UI: says the petal line only when she needs nothing; Open; source shown; today's petal again; remembered line; sky line at the good moment; empty library shows nothing | unit | `ui/test/petal.test.ts` |
|
||||
| Built app with a fixture library: open the petal, reload, still open; axe | e2e | `e2e/petal.spec.ts` |
|
||||
| Built app with the real (empty) library: no petal | e2e | same |
|
||||
| Offline: open the petal with the server gone | offline | — (the shipped library is empty; covered by e2e reload. Added when the first sentences are verified.) |
|
||||
Reference in New Issue
Block a user