[ui] LetterSlot: Add the page for A Letter from the Gardener, shown once the author writes it

docs/LETTER.md holds slots as comments only, so the player sees no change
until the author writes. The app bundles the letter at build time, a small
Markdown subset renders without {@html}, only https: and tel: become links,
and lint:copy now reads the letter. Review found turbo replaying a stale
build after the letter changed; docs/LETTER.md is now in its cache key.
This commit is contained in:
2026-11-01 15:39:17 +01:00
parent b871ab9899
commit a200832cfb
23 changed files with 639 additions and 21 deletions
+74
View File
@@ -0,0 +1,74 @@
# Review — `feature/letter-slot`
Adversarial self-review (CLAUDE.md §5.3). Analysis:
[`features/letter-slot.md`](../features/letter-slot.md). Reviewed 2026-11-01 on
Node 22.11.0, Windows 10. There is no PR: the only remote is Gitea, and this session
cannot open one there.
## Gates — counts, not exit codes
| Gate | Result |
|:--|:--|
| `pnpm lint` | exit 0 |
| `pnpm typecheck` | exit 0; `svelte-check` 0 errors **0 warnings** in ui and app (a bare `href="#"` warning was fixed) |
| `pnpm test` | **130 passed**: schema 15, content 47, engine 52, ui 16 (was 3) |
| `pnpm lint:copy` | **12 files** checked (was 9: `parse.ts`, `Letter.svelte`, `docs/LETTER.md`), 0 problems |
| `pnpm validate:library` | 0 entries; 13 of 13 fixtures rejected |
| `pnpm test:e2e` | **7 passed** (was 6), on the scaffold letter |
| `pnpm test:offline` | **1 passed** |
**Built, not deployed** (§5.4): there is no host. The change is **deliberately
invisible**: with the scaffold letter, the built page looks exactly as before. The
bundle is 8 precache entries, 42.74 KiB.
**The written-letter branch, run once.** `docs/LETTER.md` was given a temporary sample
letter (headings, a paragraph across lines, *emphasis*, an `https:` and a `tel:` link).
e2e: 7 passed, including the page opening from the link, axe with no violations, and
*Back*. Offline: 1 passed. The scaffold was then restored and both suites ran again
green. That run found finding 1.
## Test honesty — bugs put back
| Bug put back | Suite | Result |
|:--|:--|:--|
| `ALLOWED_HREF = /.*/` (any link scheme) | ui unit | CAUGHT: 2 failed |
| The letter link shown while the letter is empty | ui unit | CAUGHT: 2 failed |
| same | e2e | CAUGHT: `toHaveCount(0)` failed |
| The focus effect reads `heading` only after `if (moved)` | ui unit | CAUGHT: focus stayed on `<body>`. This was the first draft's real bug (finding 2). |
| *heal* in the body of `docs/LETTER.md` | `lint:copy` | CAUGHT: `docs/LETTER.md:36 'heal' (medical)` |
| `docs/LETTER.md` missing from turbo's cache key | e2e, written letter | CAUGHT, as the real finding 1 |
Not caught by any test: removing `docs/LETTER.md` from `lint:copy`'s file list. Only
the quoted file count (12) would show it. See finding 6.
## Findings
| # | Area | Finding | Resolution |
|:--|:--|:--|:--|
| 1 | **Correctness** | Turbo hashed only the app package, so after the letter changed, `test:e2e` printed `cache hit` and tested the **old bundle**. A deploy from a warm cache would ship the old letter. | **Fixed**: `docs/LETTER.md` is in `globalDependencies` (L8). Shown as `cache miss` after the change. Lesson: `technical.md`. |
| 2 | Correctness | The first focus effect returned before reading `heading`, so it never re-ran and focus never moved. | **Fixed** before review, caught by the Shell test. Lesson: `code.md`. |
| 3 | **Offline** | The letter opens offline, because it is bundled. A support line given as an `https:` link does **not** work offline, but a `tel:` link does. | **Deferred** to G0.27, with the advice that each support line has a phone number. |
| 4 | **Privacy** | An `https:` link in the letter takes the player to another site. Nothing leaves without their tap, the referrer is stripped (`no-referrer` on the page and `noreferrer` on the link), and it opens in a new tab. Which sites the letter links to is the author's choice. | **Accepted.** |
| 5 | Correctness | The parser has blind spots. A numbered list (`1. …`) without blank lines collapses into one paragraph, and `snake_case_word` makes *case* italic. | **Accepted.** The scaffold says which Markdown works, and anything else shows as text, never as markup. |
| 6 | Test honesty | No test proves `lint:copy` reads `docs/LETTER.md`. It was shown by the *heal* mutation, but deleting the path from `FILES` would pass silently. | **Accepted for now**: the review quotes the file count. Revisit if `lint:copy` grows a file list worth testing. |
| 7 | Correctness | *Back* leaves `#garden` in the address bar. A bookmark at `#garden` or any unknown hash opens the garden. | **Accepted**: harmless, and any hash but `#letter` is home by design. |
| 8 | **Soul** | Once the letter exists, the home view offers one link, *A Letter from the Gardener*. Looked for guilt, comparison, rejection and dependence: the page asks nothing, counts nothing, and is never required (GAMEPLAY §4). Found none. | — |
| 9 | Copyright | The scaffold's comments mention "the book". They are stripped before the page and skipped by `lint:copy`. Whether the letter's own words may name the book is **Q9**, for the author. | **Open**, Q9. |
Looked for and found none:
- **Reachability.** The letter is one-way, from the author to every player. There is
no input.
- **Injection.** No `{@html}` anywhere. Raw HTML and `<script>` stay text (tests), and
only `https:` and `tel:` become links (tests, plus a mutation). Svelte escapes
attribute values.
- **Correctness cases from §5.3.** Clock, DST, partial write and two tabs do not apply:
there is no state. A tab closed on `#letter` reopens on the letter (test: *opens
straight at #letter*).
## What was NOT verified
- **A screen reader.** axe passes on both views, and the focus move is unit-tested.
Nobody has listened to it.
- **Firefox, WebKit and a phone.** Desktop Chromium only.
- **The author's real letter.** Only a sample has rendered.