82 lines
5.8 KiB
Markdown
82 lines
5.8 KiB
Markdown
# The Letter slot
|
|
|
|
Status: merged to `main`, reviewed in
|
|
[`feature-letter-slot.md`](../reviews/feature-letter-slot.md). Gap: G0.25. Roadmap: Phase 0, *a slot for A Letter
|
|
from the Gardener — the author writes it; agents only scaffold the page.*
|
|
|
|
---
|
|
|
|
## 1. Why and what, in the player's terms
|
|
|
|
*A Letter from the Gardener* is the help section. It holds the deeper why, it can be
|
|
re-read at any time, and it is never needed to play (GAMEPLAY §4). It also holds the
|
|
quiet door to real help (CLAUDE.md §5.6 rule 5).
|
|
|
|
This branch makes the place for it, not the letter itself. The author writes
|
|
`docs/LETTER.md` in plain Markdown, and the app shows it as a page. **Until the author
|
|
writes something, the player sees no change at all**: there is no link to an empty
|
|
page, no "coming soon" and no dead control.
|
|
|
|
## 2. Technical architecture
|
|
|
|
```mermaid
|
|
flowchart LR
|
|
letter[("docs/LETTER.md<br/>the author's words")]
|
|
app["apps/rosea<br/>App.svelte<br/>imports it ?raw at build time"]
|
|
ui["packages/ui<br/>letter/parse.ts → blocks<br/>Letter.svelte, Shell.svelte"]
|
|
lint["scripts/lint-copy.ts"]
|
|
letter -- "bundled, precached" --> app --> ui
|
|
lint -. scans .-> letter
|
|
```
|
|
|
|
### Decisions
|
|
|
|
| # | Decision | Why |
|
|
|:--|:--|:--|
|
|
| L1 | `docs/LETTER.md` is the only copy of the letter. The app imports it with Vite's `?raw` at build time. | No runtime fetch, so the letter is in the precached bundle and opens offline. One file means the author edits one place, in Markdown. |
|
|
| L2 | The scaffold holds only HTML comments: one slot per thing the docs say the letter carries. Comments are dropped when the page is built, so the scaffold renders as nothing. | Agents never write the letter's voice. A heading is voice too, so the slots are comments, not headings. |
|
|
| L3 | A small Markdown subset is parsed into blocks in `packages/ui/src/letter/parse.ts`: headings, paragraphs, lists, *emphasis* and links. Everything else is shown as plain text. The component renders the blocks with Svelte, **never `{@html}`**. | No HTML is ever built from text, so nothing in the file can inject markup or script, and the CSP stays `'self'`. The parser lives in `ui` because it is presentation, and `ui → content` is not an allowed dependency. |
|
|
| L4 | Only `https:` and `tel:` become links. Anything else, including `http:`, `javascript:` and `data:`, stays text. External links open in a new tab, with `rel="noopener noreferrer"`. | The support door needs web and phone links. Nothing else does. |
|
|
| L5 | The page is reached by a link on the home view, at `#letter`. The link exists **only when the letter has content**. With an empty letter, `#letter` shows the home view. | Hash routing works offline without a server rule. An entry point to an empty page is a dead control. |
|
|
| L6 | `lint:copy` scans `docs/LETTER.md` with the full list, though it lives in `docs/`. | It is player-facing. The `docs/` exemption (§5.6 rule 4) is for design documents, where the words are being discussed. |
|
|
| L7 | When the view changes, focus moves to the new view's heading. | A screen-reader user hears where they are. A hash change alone announces nothing. |
|
|
| L8 | `docs/LETTER.md` is in turbo's `globalDependencies`. | Found in review: without it, a changed letter replayed the cached build (`lessons/technical.md`). |
|
|
|
|
## 3. Risk analysis
|
|
|
|
| Risk | Where | Defence |
|
|
|:--|:--|:--|
|
|
| A forbidden or medical word reaches a player through the letter | `docs/LETTER.md` | L6, with a test that the script reads the file. |
|
|
| The letter names the book | The "one sentence of inspiration" (GAMEPLAY §7) | `lint:copy` refuses *Saint-Exupéry* and the title in the letter as everywhere else. If the author wants the letter to name its source, that is a decision to write down (Q9), not an exemption made by an agent. |
|
|
| Markup or script injected through the file | The renderer | L3 and L4, with tests for `<script>`, `javascript:` and raw HTML. |
|
|
| An empty page feels broken or turns the player away | Before the author writes | L5: there is no way to reach it. |
|
|
| A link sends the player's address somewhere | Support links | `referrer: no-referrer` is already set, and `noreferrer` is on each link. Leaving the app is the player's own choice, made with a tap. |
|
|
| Someone in crisis cannot find the door | Support lines | Not solved here: the numbers are real-world facts the author must verify. The slot exists, and G0.27 tracks the rest. |
|
|
|
|
Guilt, comparison, rejection, dependence: looked for and none found. The page asks
|
|
nothing and counts nothing.
|
|
|
|
## 4. Gap analysis and the designed solution
|
|
|
|
| Gap | Solution |
|
|
|:--|:--|
|
|
| No page for the letter | `Letter.svelte`, reached at `#letter` (L5) |
|
|
| No file for the author | `docs/LETTER.md`, slots only (L2) |
|
|
| The letter escapes `lint:copy` | L6 |
|
|
| No support lines | Slot only; verified numbers are the author's (G0.27) |
|
|
|
|
## 5. Verification matrix
|
|
|
|
| Case | Kind | Where |
|
|
|:--|:--|:--|
|
|
| The scaffold, being only comments, parses to zero blocks | unit | `packages/ui/test/letter-parse.test.ts` |
|
|
| Headings, paragraphs across lines, lists, emphasis, links parse as blocks | unit | same |
|
|
| `<script>` and raw HTML stay text; `javascript:`, `data:`, `http:` links stay text | unit | same |
|
|
| `https:` and `tel:` links render as links with `noopener noreferrer` | unit | `packages/ui/test/Shell.test.ts` |
|
|
| Empty letter: no link to it, and `#letter` shows home | unit + e2e | `Shell.test.ts`, `e2e/shell.spec.ts` |
|
|
| A letter with content: the link appears, opens the page, *Back* returns, focus moves | unit | `Shell.test.ts` |
|
|
| `lint:copy` reads `docs/LETTER.md` and fails on a forbidden word in it | script, run | the review |
|
|
| The built app still renders, offline included | e2e, offline | existing suites |
|
|
| The written-letter branch of the e2e test, with a temporary sample letter | e2e, run once | the review |
|
|
| A changed letter rebuilds the app (`cache miss`) | e2e, run | the review |
|