Files
Rosea/CLAUDE.md
T

524 lines
35 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CLAUDE.md
Operating manual for AI agents working in the **Rosea** repository.
Read this together with [`HANDOVER.md`](HANDOVER.md) (where the last session left off),
[`docs/GAMEPLAY.md`](docs/GAMEPLAY.md) (the play loop — **decided; read before any game code**),
[`docs/ROADMAP.md`](docs/ROADMAP.md) (the phase plan and its gates),
[`docs/PRINCIPLES.md`](docs/PRINCIPLES.md) (why the game is the way it is),
[`docs/ART.md`](docs/ART.md) and [`art/STYLE.md`](art/STYLE.md) (how every illustration is made).
[`docs/LETTER.md`](docs/LETTER.md) belongs to the author — agents scaffold it, never write its voice.
For the engineering picture read [`.agents/GAP_ANALYSIS.md`](.agents/GAP_ANALYSIS.md), then
[`.agents/FEATURES.md`](.agents/FEATURES.md), then the per-feature documents in
[`.agents/features/`](.agents/features/).
> **This repository is new, and this manual is partly borrowed.** Most of §5 was paid for in
> NoAlgoTube, Aeterna, Ludus and Panda Domi, not here. Where a rule is imported, the source is named.
> Where a trap is predicted rather than observed, it says **(predicted)** and must be confirmed with a
> measurement or struck out. A predicted trap that survives six months unmeasured is superstition.
> **The name is a working name.** `Rosea` (Latin, *rose-coloured*) is provisional. The product is
> always **Rosea Domi** in public, and *Domi* never appears alone. In source the name lives in exactly
> three places — `packages/schema/src/constants.ts`, `apps/rosea/index.html` and the web manifest —
> plus the `@rosea/*` package scope and the IndexedDB database name, which change together with them.
> Renaming must stay a one-commit operation until the name is confirmed.
---
## 1. What this project is
**Rosea Domi** is a small web game, installable as a PWA, about a living rose, a fox, and the time we
give to people. It belongs to the Domi ecosystem and is linked from the parent mode of Panda Domi; the
fox is a quiet nod to Ulfík the red panda (they look alike — an Easter egg, never an explanation).
It is made **for lonely people**, and the word *loneliness* never appears anywhere in the product.
Lonely people often do not call their state by that name; the game does not name it for them. It only
lets them feel seen and needed.
It **comforts the soul, not the mind.** It offers wisdom, hope and companionship. It is not therapy,
it diagnoses nothing, it treats nothing, and no screen, store listing or help text may claim
otherwise (§5.6).
It is **its own game, by purpose**: practice for real friendship that leads into **Amicitia Domi**. It is
not a *Little Prince* game. From Saint-Exupéry it takes one idea — taming makes you responsible, and
tending is how you live that — plus a quiet echo of the book's structure (rose, fox, planets of lonely
grown-ups; the desert pilot is skipped). **Never its text, title, names or drawings** (§5.6, §8). Tolkien is used
the same way: Gandalf's spirit (comfort, wisdom and hope as his only weapons; patience as the cure;
encouraging, never ruling), never a name or a quote.
### The shape of the game
- **The rose** — one per player, with a soft cartoon face in the petals (small, often half-closed
eyes, a tiny mouth, a blush when tended). She is alive and a little vain, with thorns that are part of
her. Care has a touch of skill: water by feel (too much is as bad as too little), shade her from wind,
pull weeds, gather fallen petals. She grows from the **total** time of care, never from a streak.
Neglect makes her **drift** — turn away, close a little — never break. Short visits hold her; real
time — calendar days on which care helped, never minutes on screen — brings full bloom. One tap
shows her real numbers (water, warmth, days of care, trend).
- **The planets** — a journey through lonely grown-ups (the king, the vain man, the businessman, the
lamplighter, the geographer…). Each planet lets the player feel one shape of loneliness.
- **The fox** — follows at a distance from the first planet and comes closer through touch (pet,
brush) and food. The rose tells you what he wants today. His food is **berries**: first from the wild bush
beside the player's own rose, later also from tending other players' forgotten roses — an addition,
never a requirement (one harvest per bush per day, only when the care helped).
Your own rose's growth sets berry quality: wild strawberries → blueberries → raspberries →
blackberries → rose hips. After the taming he leads the player to real people.
- **Teaching in play** — the rose and the fox explain and remind in speech bubbles, with text from the
curated copy library. Nothing requires reading the Letter.
- **Friends** — you tend their roses, they tend yours. When you tend someone's rose, their fox brings
them a real trace of you and, now and then, words of comfort from the library. The person you
helped can thank you with one gesture: their fox visits your rose. Between two roses a path grows —
footprints, then a trail, then a road.
- **The bridge to Amicitia** (promoted openly) — once a path is a road, either player may light a
**lantern**. A one-sided lantern is invisible; when both are lit, the game says so and the two apps
swap anonymous keys device to device. The lantern never passes through `lucerna`. Before a match,
sentences carry the Amicitia icon and *a taste of Amicitia* — never "sent through Amicitia". Players are known only by their rose's name. Free conversation
happens only in Amicitia, never in Rosea. Rosea has no doors: paths only grow, a lit lantern stays lit.
- **The shared sky** — every act of care toward someone else adds light to one night sky that all
players share. The sky is the **real** sky: real constellations. Every day at local sunset a wave of
lamps follows the sunset around the globe.
- **The sunset** — every day at the player's real local sunset the game invites them to put the phone
down and look at the real one. **The day's sentence of hope comes from the rose**: she waits with a
folded petal. Sunset is the best moment to open it, but it is **never lost** — no streak, and coming
back on nearby days gives a little more. The in-game sunsets (move the chair, watch it again) are
comfort and rehearsal.
- **A Letter from the Gardener** — the help section: every feature, every principle, and the author's
own philosophy, signed by him.
### The properties that are not negotiable
These are load-bearing. A feature that needs one of them bent is the wrong feature.
| Property | What it means in practice |
|:--|:--|
| **Local-first** | The rose, the planets, the fox, the sunset and the library all work with the network off. Network features degrade to a calm disabled state with an explanation, never a spinner or an error page. |
| **Anonymous** | No account, no email, no password, no phone number, no real name. Identity is a locally generated keypair and a chosen display name. |
| **No free text, ever** | Not between strangers, not between friends. Every word one player can send another is picked from the curated library (§6.1). There is no input field that reaches another person. |
| **Never count people** | No follower counts, no like counts, no leaderboards, no "N people tended your rose". Numbers are about the player's own rose and time only — one tap away, never shouted, never compared. |
| **Progress never disappears** | No streak resets, no decay that takes away what was earned. At worst the rose drifts — turns away, closes into a bud — and waits. The day's sentence waits too. |
| **Gentle** | Hope is offered, never pushed. Comfort never promises an outcome. No guilt, no nagging, no notification about someone else's rose being neglected. |
| **Points beyond the screen** | Every beauty in the game has a real twin outside: the real sunset, the real sunrise, the real constellations. The game's best moments send the player away from the screen. |
| **Contributions only add** | Nothing a player does can overwrite, remove or diminish another player's work. |
### The author's philosophy — where it lives
The author's own philosophy — *we do not choose the time we are given, only what we do with it*; the
river of life in which every person is a whirlpool that shapes the flow and is shaped by it; Cicero's
friendship and duty — lives **openly in the Letter from the Gardener, signed by him**. The mechanics
stay universal: a river, stars and a sunset speak to a believer and a non-believer alike. Agents do not
write the Letter; they leave clearly marked slots for the author.
**What this is not**, so scope creep has somewhere to bounce off: not a social network, not a chat,
not a dating or meeting app, not a therapy or wellness-tracking app, not a streak machine, not a
feed of anything.
---
## 2. Repository layout
Phase 0 scaffolded `schema`, `engine`, `content`, `ui` and `apps/rosea`. `storage`, `identity`,
`sync`, `services/lucerna`, `tools/art-prep` and `art/` arrive with their first feature, because an
empty package has a test suite that runs nothing ([`phase0-workspace.md`](.agents/features/phase0-workspace.md) D1).
```
pnpm-workspace.yaml
turbo.json
packages/
schema/ # THE source of truth: JSON Schemas for the hope library, care events, traces.
# Generated TS types. Validator. Zero runtime deps beyond ajv.
engine/ # Pure. No I/O, no DOM, no Date.now(), no Math.random().
# growth/ (rose stages from total care; drift from absence, never loss)
# care/ (skill acts: watering by feel, wind, weeds, petals)
# forage/ (berries from forgotten roses; quality from own growth)
# taming/ (fox distance from touch and food)
# sky/ (shared-sky light, constellation completion)
# sun/ (sunset/sunrise times, polar day/night) — astronomy is pure maths
# time/ (localDay.ts — the ONLY place a day is computed)
content/ # the hope library + planets' scripts as data, and their validator
storage/ # Dexie. The ONLY module that touches IndexedDB.
identity/ # keypair lifecycle. The ONLY module that holds key material.
sync/ # friend-to-friend care "letters" over WebRTC; merge on meet (Phase 3)
ui/ # Svelte components + tokens + copy/. No business logic.
apps/
rosea/ # the PWA (Svelte 5 + Vite + workbox) -> @rosea/app
services/
lucerna/ # OPTIONAL discovery service (Phase 4), Rust (Axum) + SQLite.
# Anonymous traces only (§4). Self-hostable. Must be deletable.
art/
STYLE.md # the style system prompt — see docs/ART.md
manifest.json # every illustration the game needs, with size, purpose and status
placeholders/ # Claude-made test art (SVG) for testing form and layout only
final/ # approved, optimised illustrations (WebP/AVIF)
tools/
art-prep/ # the art preparation page (docs/ART.md §3). Local only, 127.0.0.1.
content/
library/ # hope sentences, one file per source tradition
fixtures/ # deliberately invalid entries the validator must reject
.agents/ # agent contract, per-feature analysis, reviews, lessons
docs/ # ROADMAP.md, ART.md, numbered milestone feature docs
```
`lucerna` — *lantern*: it only ever shows that someone was there. The lantern gesture (§1) shares the
name and never passes through it.
**Dependency direction (never violate):**
```
apps/rosea ──► packages/ui ──► packages/engine ──► packages/schema
├───────► packages/content ─────────┴──────────────┘
├───────► packages/storage ──► packages/engine
├───────► packages/sync ──► packages/schema
└───────► packages/identity ──► packages/schema
services/lucerna ──► packages/schema (trace shape only, via generated JSON Schema)
tools/art-prep ──► art/manifest.json (never imported by the app)
```
- `packages/engine` is pure. Time and randomness are parameters. This is what makes growth, taming and
the sunset maths testable and what makes a replay of the care log deterministic.
- `apps/rosea` contains zero growth, taming or sky logic. It renders what the engine returns.
- `services/lucerna` must be deletable. If removing it breaks the rose, the planets, the fox, friends
or the sunset, the shared sky has stopped being optional and that is a **blocker**.
### Why Svelte, and where Rust earns its place
Web first is the decision: the game must run from a link, on any phone, with no store. So the app is
**Svelte 5 + Vite as a PWA**, the same stack as Ludus and Panda Domi. Rust is used only where it pays:
- **`services/lucerna`** — a small, long-running, internet-facing service. Rust (Axum) gives memory
safety and a tiny footprint on a home server. Its contract is the JSON Schema in `packages/schema`.
- **A Tauri 2 shell, later (Phase 6)** — same Svelte code, packaged for Android and iOS, matching the
ecosystem's move to Tauri. Its main gift is **local notifications without a server** (see the
notification trap in §8).
- **Not** a Rust UI framework (Leptos, Dioxus, Yew) and **not** Rust→WASM for the sunset or star
maths: both are small and fast in TypeScript. WASM enters only with a measurement that says it must.
---
## 3. Commands
```bash
pnpm install --frozen-lockfile # also installs the git hooks (§5.2)
pnpm --filter @rosea/schema build # schema first, always (generates the contract types)
pnpm --filter @rosea/app dev # 127.0.0.1:5173 — never --host (§5.7)
pnpm build # turbo: schema -> engine/content/ui -> app
pnpm lint # ESLint, incl. the engine-purity rule (§7)
pnpm typecheck # tsc + svelte-check, every package plus e2e/ and scripts/
pnpm test # vitest, all packages — quote counts per package
pnpm --filter @rosea/engine test # incl. fast-check property tests (sun golden tests: later)
pnpm test:e2e # builds, then Playwright against the BUILT app under /Rosea/
pnpm test:offline # builds, loads once, CLOSES the server, reloads
pnpm validate:library # every hope sentence; fixtures must FAIL
pnpm lint:copy # forbidden words and names (§5.6)
# Not yet — they arrive with their first feature:
pnpm art:prep # opens tools/art-prep on 127.0.0.1
cargo test --manifest-path services/lucerna/Cargo.toml # Phase 4 onward
```
The build's base path is `/Rosea/` (GitHub Pages' project sub-path); `ROSEA_BASE=/x/` overrides it
for the build and for both Playwright suites together.
> **The `pnpm test` trap, imported from Aeterna.** Exit code 0 says the command succeeded, not that
> tests ran. A filter that matched nothing and a green run look identical. **Quote the counts per
> package, or do not claim green.**
> **The offline suite is the product's central claim.** It loads the app once, cuts the network, then:
> tends the rose, walks one planet, watches an in-game sunset, closes the tab, reopens it, and asserts
> that everything survived. A local-first app tested only against a dev server has never been tested
> offline — the dev server *is* the network.
---
## 4. Runtime state
**On the device — IndexedDB database `rosea` (Dexie):**
| Store | Contents | Written by |
|:--|:--|:--|
| `events` | **append-only** log: care given, care received, planet steps, sunsets seen or missed, gestures | `packages/storage`, from the game loop |
| `derived` | rose stage, fox distance, paths, sky light — rebuilt from `events` | `packages/storage`, from values the engine returns |
| `profile` | the rose's name (the only name Rosea knows), chosen city for sunset (skippable; fallback is the device time zone; never GPS), settings, opt-ins | settings screen |
| `keys` | the identity keypair | `packages/identity` |
| `library` | the cached hope library and planets' content, versioned | `packages/content` |
**`events` is the truth; `derived` is a cache.** Anything in `derived` must be reconstructible by
replaying `events` through the engine. A number that cannot be derived from the log does not belong in
`derived`.
**Nothing else is written anywhere.** No cookies, no `localStorage`, no analytics of any kind, no
third-party origin, no fonts or images from a CDN.
**On `services/lucerna`, only when the player has opted in to the shared sky (Phase 4):** an anonymous
trace id, a coarse geocell (~1 km), a day bucket (never a timestamp finer than a day), and the gesture
kind. Traces auto-delete after a fixed window (assumption: 14 days — decided in the Phase 4 feature
doc). No IP log, no user agent, no referrer, no push token joined to a location. A proposed extra column
is a design discussion, not a migration.
---
## 5. Non-negotiable workflow rules
### 5.1 Every feature needs an analysis document **before it is done** — (D)TDD
Documentation → tests → code. A feature is not complete until its analysis is committed alongside it.
- **Location**: `.agents/features/<name>.md`, or `docs/NN_<name>.md` for numbered milestones.
- **Required sections**: (1) why and what, in the player's terms; (2) technical architecture with a
Mermaid diagram naming the packages; (3) **risk analysis** — here "risk" means *a lonely person
feeling worse*, *someone's location*, or *someone being reachable who did not ask to be*; (4) gap
analysis and the designed solution; (5) the verification matrix — happy-day **and** bad-weather
cases mapped to unit / integration / e2e / offline, plus manual steps.
- Then update `.agents/FEATURES.md` and `.agents/GAP_ANALYSIS.md`. A closed gap is struck through
**with the evidence in the row**. There is no changelog file; `HANDOVER.md` is rewritten at the end
of each session.
### 5.1b Lessons — one file per category of problem
`.agents/lessons/<category>.md`, indexed in `.agents/lessons/README.md`:
| File | What belongs in it |
|:--|:--|
| `soul.md` | **The most important file here.** What comforts and what only looks like comfort. Every mechanic that turned out to cause guilt, comparison, rejection or dependence. Every sentence that rang hollow. |
| `architecture.md` | Layering, ownership, seams. |
| `design.md` | What the player is shown and why: wording, silence, empty states. |
| `art.md` | What the image pipeline taught: prompts that drift, checks that missed, style that broke. |
| `code.md` | TypeScript, Svelte reactivity, async ordering, Rust in `lucerna`. |
| `technical.md` | The browser as a platform: storage eviction, service workers, notifications, timers. |
| `testing.md` | What makes a test worth having, and how a passing test lies. |
| `privacy.md` | Anything that could leave the device or make a person findable. |
| `process.md` | Workflow, commits, reviews, releases, honesty about what shipped. |
Shape of an entry: a heading, then **what happened** (concrete, with the file or measurement),
**why it bit** (general enough to recognise elsewhere), **how to apply it** (imperative, testable).
These files are the first thing to read when something behaves strangely.
### 5.2 Commit protocol
```
Format : [<Package>] <FeatureName>: <one-line description>
Example: [engine] RoseGrowth: Grow from total days of care, never from consecutive days
Remote : GitHub (primary) — branch main; mirrored to gitea.marek-novak.cz, as in Panda Domi
Deploy : GitHub Actions builds apps/rosea and publishes it to GitHub Pages on every merge to main
```
PRs are opened and merged on GitHub. The Gitea mirror is a backup and must stay in sync — after every
push, verify the mirror's `main` matches (`git ls-remote` on both remotes prints one hash).
#### NO AI ATTRIBUTION IN COMMITS — EVER
No `Co-Authored-By: Claude…`, no `Claude-Session:` link, no "Generated with" line — in any commit,
merge commit, PR body or tag message. A commit message ends with its last substantive line. If a
harness appends such a trailer, strip it. *(Imported from NoAlgoTube, which needed a history rewrite.)*
#### Build output and oversized files are never committed
`dist/`, `.turbo/`, `node_modules/`, `target/` and raw image exports are git-ignored from the first
commit. A pre-commit hook installed by `pnpm install` rejects any staged file over 5 MB. Final art is
committed only as optimised WebP/AVIF under `art/final/` (budget per image decided in `docs/ART.md`).
`git add -f` on an ignored file is wrong on every branch. *(Imported from NoAlgoTube's 2 GB `.git`.)*
### 5.3 Branch, self-review, merge — every feature
1. **Branch**: `feature/<name>`, `fix/<name>`, `refactor/<name>`, `docs/<name>`, `art/<set>`,
`content/<library-part>`.
2. **Build it**, committing as you go. The analysis doc is part of the branch.
3. **Open a PR and review it adversarially** in `.agents/reviews/<branch>.md`. A self-review that
finds nothing is a failed review. Cover at minimum:
- **Correctness** — second run, clock change, DST change, partial write, tab closed mid-action,
two tabs open.
- **Soul** — *can this make a lonely person feel worse?* Look for guilt (a neglected thing that
blames), comparison (anything ranked or counted), rejection (a gesture that can go unanswered
in a visible way), and dependence (a reason to stay in the app instead of going outside). Answer
with a concrete scenario or say you looked and found none.
- **Privacy** — every path by which a byte leaves the device: trigger, contents, what the player
was told. "It sends nothing" needs evidence.
- **Reachability** — can this let one person reach another who did not ask to be reached?
- **Offline** — does it work with the network off? If not, what does the player see?
- **Test honesty** — does each test fail when the bug is reintroduced? Say if you did not check.
- **Scope** and **what you did NOT verify**, stated plainly.
4. **Address every finding** — fixed with the commit, or deferred with a reason. Never dropped silently.
5. **Merge with `--no-ff`**. 6. **Push immediately** and verify `git rev-parse HEAD origin/main` prints
one hash twice. 7. **Run e2e and offline against the BUILT app** before calling anything done.
Do not claim a PR was opened when it was not. The access token is a secret and never enters the
repository, a review document or command output.
### 5.4 The deployed bundle is the only thing the player sees
The player opens an installed PWA served from a precached shell. Source changes are invisible until
the app is rebuilt, the service worker's bytes change, and the client picks up the new worker. When
reporting a fix, **say whether the bundle was rebuilt and redeployed**. If a change is deliberately
invisible (a refactor, a library update), say so explicitly — a fresh build that looks identical is
otherwise indistinguishable from a stale one. *(Imported from NoAlgoTube and Aeterna, where it
happened twice.)*
### 5.5 Test discipline
- `pnpm test`, `test:e2e`, `test:offline`, `validate:library` and `lint:copy` are green before any
commit, with counts quoted per package.
- **The engine gets property tests.** `fast-check`: growth is monotonic in total care and never
decreases; fox distance never jumps more than one step per day; replaying the same log twice gives
byte-identical `derived` state; a missed sunset never changes the rose's stage; an unopened
sentence is never lost; at most one harvest per bush per local day, and none when the care
did not help; drift never lowers the stage earned.
- **Sun maths gets golden tests** against published sunrise/sunset tables for a spread of cities:
Prague, Reykjavík, Tromsø (polar day and polar night), Quito, Sydney, Anchorage — including both DST
transition days. Tolerance is stated in the test, in minutes.
- **The library validator's negative fixtures are the validator.** `content/fixtures/` holds entries
that must fail, each with a message naming the problem: no source; source not verified public
domain; a modern translation that is still under copyright; over the length cap; a promise of an
outcome (flagged for human review); a forbidden name (§5.6); missing tradition tag. Adding a rule
without the fixture that proves it fires is a **blocker**.
- **E2E and offline run against the built bundle**, never the dev server.
- **Tests needing a missing capability degrade to a no-op and say so** in the report.
- **No test touches real user data or a real location.**
### 5.6 Content, words and privacy — absolute rules
1. **No free text reaches another person.** Every message between players is a library id (§6.1).
There is no input field whose contents leave the device toward a person.
2. **The library is curated and sourced.** Every sentence has a source, an author or tradition, and a
verified public-domain status (or is written by the author for Rosea). Bible quotations use only
public-domain translations (e.g. KJV, Bible kralická). Hope may come from any tradition; the
library stays mixed so a non-believer is at home too. No sentence promises an outcome.
3. **Forbidden in the product**: any name, quote or recognisable drawing from *The Little Prince* or
from Tolkien's works; the words *therapy, therapeutic, treat, treatment, heal, cure, diagnose,
symptom, patient, disorder* in any player-facing copy or store listing (EU medical-device scope is
triggered by claims — the same positioning rule as Quies). `pnpm lint:copy` enforces the list.
4. **The word *loneliness* (and *lonely*) never appears in the product.** It may appear in `.agents/`
and `docs/`.
5. **A quiet door to real help.** The Letter from the Gardener contains a calm, always-reachable link
to real support lines. It is not advice and makes no clinical claim; it is a door.
6. **Location is a city the player chooses**, or a guess from the device time zone if skipped — never
GPS, and never an IP lookup without a written decision (it is a network call). The shared sky (Phase 4)
uses a coarse geocell and a day bucket only.
7. **Strangers are never reachable directly.** The path to strangers is a ladder of mutual consent
(traces → a light → foxes meet only if both agree → group meetings in public places only). The game
never arranges a one-to-one meeting.
### 5.7 A test run leaves the machine as it found it
Nothing binds to anything but `127.0.0.1`. Every browser a test starts is closed in `finally`. Do not
start a full run above ~80% CPU. *(Imported from Ludus and Aeterna.)*
---
## 6. The contracts
A mismatch in any of these fails silently at runtime, which is why they are listed here.
### 6.1 A hope sentence (the library entry)
```jsonc
{ "id": "ps-23-4",
"text": { "en": "…", "cs": "…" },
"source": { "work": "Psalms 23:4", "author": null, "tradition": "biblical",
"translation": "KJV", "publicDomain": true, "verifiedBy": "Mark", "verifiedAt": "2026-…" },
"use": ["sunset", "comfort", "thanks"], // where it may appear
"tone": "gentle",
"promisesOutcome": false }
```
Sunset sentences: at least 365, so none repeats within a year. Comfort lines are the only words a
player can send another player, and the sender picks one.
### 6.2 The care event (append-only, never edited)
```jsonc
{ "kind": "care", "ts": 1761500000000, "localDay": "2026-10-24",
"from": "<pubkey>", "to": "<pubkey>", "act": "water" | "shade" | "weed" | "petals",
"trace": "petal:<colour>", "messageId": "ps-23-4" | null, "clientVersion": "0.1.0" }
// act applies to the player's own rose or another player's. (This example once
// listed "wind" | "light"; §1's weeds and fallen petals won — phase0-workspace.md D5.)
// Only "care" is in packages/schema so far; each other kind arrives with the feature doc that uses it.
// other kinds: "sentence-opened", "sunset" (seen), "planet-step", "fox" (pet | brush | feed),
// "harvest" (berry kind), "thanks", "lantern" (lit — never unlit)
```
Every number on screen is a pure function of this log, computed by `packages/engine`. Adding an event
kind is the only sanctioned way to make a new thing derivable.
### 6.3 The trace (Phase 4, opt-in only)
```jsonc
{ "traceId": "<random, rotates>", "geocell": "<~1 km cell>", "dayBucket": "2026-10-24",
"gesture": "petal" | "light", "sig": "<signature>" }
```
No timestamp finer than a day, no precise location, no free text, no link to the friend graph.
---
## 7. Conventions
- **TypeScript strict everywhere** (`strict`, `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`).
Types for the contracts are generated from JSON Schema, never hand-written.
- **The engine is pure** — enforced by a lint rule, not by good intentions.
- **One module computes a day** (`engine/src/time/localDay.ts`) and **one computes the sun**
(`engine/src/sun/`). Never `toISOString().slice(0,10)`.
- **Svelte 5 runes, no state library.** A component that decides growth, taming or anything in the sky
is a layering violation and a review **blocker**.
- **Three taps to action, one preferred.** From a cold open, tending the rose is one tap.
- **Every string a player reads lives in `packages/ui/src/copy/`**, and passes `lint:copy`. The
interface language is plain English (Czech later). Latin is for the brand only.
- **Silence is a feature.** Sunset, the thanks visit and the end of a planet have moments with no
buttons at all. Do not fill them.
- **Accessibility is not a phase.** Every action is keyboard- and screen-reader-operable from the
commit that introduces it; motion respects `prefers-reduced-motion`.
- **Never swallow an error.** `catch {}` without a logged reason is a review failure.
- **Art comes only through the pipeline in `docs/ART.md`.** No image enters `art/final/` without the
automatic checks, Claude's review and Mark's visual approval.
---
## 8. Known traps
| Trap | Why it bites |
|:--|:--|
| **A PWA cannot schedule a local notification** *(predicted — verify first)* | The sunset invitation is time-based. A web app generally cannot fire a notification at a set time while closed without a **push server** sending it, and a push server that knows when someone's sunset is knows roughly where they are. On iOS, web push works only for a site added to the home screen. **Decided in Phase 0 (2026-11-01):** in-app sunset only for the web build — no push server — and local notifications through the Tauri shell later (Phase 6). |
| **Polar day and polar night** *(predicted)* | Above the Arctic Circle the sun does not set in summer or rise in winter. "Every day at sunset" has no answer there. The engine must return a defined state and the game must have a gentle alternative (e.g. the hour the light is lowest). |
| **DST and the local day** *(predicted)* | Sunset jumps an hour twice a year under a player who did nothing; a day boundary computed in UTC records Monday-evening care as Tuesday's. One module computes the day. |
| **Comfort becomes wallpaper** | The same words every day stop meaning anything. Comfort words are occasional; the real trace of a real person is constant. Track repetition in tests. |
| **Guilt sneaks in through "gentle" reminders** | "Your rose misses you" is guilt wearing a ribbon. No notification ever refers to neglect — the player's or anyone else's. |
| **Streak creep** | Someone will propose "just a small streak". Growth is from total care; a missed day never resets anything. |
| **Drift that reads as blame** | A rose turned away can feel like an accusation. Drift is shown as waiting, never as hurt caused; she brightens on the first touch, and no copy ever says *you forgot*. |
| **Berry farming** | Tending roses for food invites mindless tapping. One harvest per bush per local day — the player's own and each forgotten rose's — only when the care actually helped, enforced in `engine/forage`, property-tested. |
| **A lantern as rejection** | A lit lantern that is visibly unanswered is the rejection this game exists to avoid. One-sided lanterns are invisible to the other player, always. |
| **Location makes people findable** | Coarse cells next to a sparse population identify a house. Cell size must adapt to density, traces must be delayed and auto-deleted, and stranger contact is consent-only (§5.6). |
| **The library as a scam channel** | If any field lets a sender attach free text, a lonely recipient can be manipulated. The id-only contract (§6.1) is the defence. |
| **Copyright through the back door** | An image prompt "in the style of" the book's drawings, a fox or rose that looks like the original, or a famous line "paraphrased" too closely. All forbidden (§5.6); the art pipeline checks likeness (`docs/ART.md`). |
| **Medical claims in a store listing** | One word like *heal* in marketing copy can pull the product toward medical-device rules. `lint:copy` also runs on store text kept in the repo. |
| **IndexedDB is evictable** *(predicted)* | WebKit can discard origin storage after seven days without interaction — exactly the shape of a player who drifted away and comes back. 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. |
| **The stale service worker** | A precached shell keeps serving old JS to a player who has "updated". Detect a waiting worker and offer an explicit, calm *refresh* control. |
| **Two tabs, one database** *(predicted)* | Two event streams into one store; derived state drifts. Use a `BroadcastChannel` lock. |
| **GitHub Pages serves under a sub-path** *(predicted)* | A project site lives at `/<repo>/`, not `/`. Vite `base`, the web manifest `start_url` and `scope`, and the service worker scope must all agree, or the installed app opens a 404 or never updates. The offline suite runs against the same base path. |
| **GitHub Pages cannot set response headers** *(predicted)* | No custom CSP or cache headers. The content-security policy goes in a `<meta>` tag; caching is controlled by the service worker and hashed filenames. |
| **Pages hosts files, not services** | `services/lucerna` cannot live on Pages. It runs on Mark's own server (Phase 4), and the app must work fully without it. |
| **`pnpm test` exits 0 having run nothing** | Quote counts per package. |
| **Playwright against the dev server** | It never registers the service worker and has never reproduced a caching bug. |
---
## 9. Where to look first
| I need to… | Start here |
|:--|:--|
| Understand why something behaves strangely | `.agents/lessons/` — `soul.md` first |
| Know what is planned and which gate we are at | `docs/ROADMAP.md` |
| Make or replace an illustration | `docs/ART.md`, then `pnpm art:prep` |
| Change how the rose grows | `packages/engine/src/growth/` |
| Change how the fox comes closer | `packages/engine/src/taming/` |
| Change the sunset or sunrise | `packages/engine/src/sun/` — read the polar and DST traps first |
| Add or edit hope sentences | `content/library/` — then `pnpm validate:library` |
| Change what friends can send each other | `packages/schema` §6.1 — and re-read §5.6 rule 1 |
| Change the shared sky | `services/lucerna/` — and re-read §4 and §5.6 rules 6–7 |
| Understand a past decision | `.agents/features/*.md`, `git log`, `.agents/reviews/*.md` |