From 6885a217cd220593b8639cb47074148ac9a87085 Mon Sep 17 00:00:00 2001 From: mnovak Date: Sun, 1 Nov 2026 00:36:06 +0100 Subject: [PATCH] [repo] Workspace: Review Phase 0 and record gaps, lessons and handover MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adversarial review with per-package counts and 13 reintroduced bugs, all caught. Fixes from the review: the trace geocell is capped at 6 characters (~1 km; 16 allowed centimetres), one forbidden-word hit per place, and an e2e guard that meta charset stays within the first 1024 bytes. CLAUDE.md §6.2 no longer contradicts itself about care acts; §2 and §3 say what Phase 0 actually built. --- .agents/FEATURES.md | 8 ++ .agents/GAP_ANALYSIS.md | 36 ++++++++ .agents/features/phase0-workspace.md | 32 +++++-- .agents/lessons/README.md | 20 +++++ .agents/lessons/code.md | 22 +++++ .agents/lessons/process.md | 33 +++++++ .agents/lessons/technical.md | 42 +++++++++ .agents/lessons/testing.md | 45 ++++++++++ .agents/reviews/feature-phase0-workspace.md | 96 +++++++++++++++++++++ CLAUDE.md | 33 ++++--- HANDOVER.md | 40 +++++++++ e2e/shell.spec.ts | 7 ++ packages/content/src/forbidden.ts | 15 ++-- packages/content/test/forbidden.test.ts | 5 ++ packages/schema/schemas/trace.schema.json | 4 +- packages/schema/test/schemas.test.ts | 6 ++ 16 files changed, 417 insertions(+), 27 deletions(-) create mode 100644 .agents/FEATURES.md create mode 100644 .agents/GAP_ANALYSIS.md create mode 100644 .agents/lessons/README.md create mode 100644 .agents/lessons/code.md create mode 100644 .agents/lessons/process.md create mode 100644 .agents/lessons/technical.md create mode 100644 .agents/lessons/testing.md create mode 100644 .agents/reviews/feature-phase0-workspace.md create mode 100644 HANDOVER.md diff --git a/.agents/FEATURES.md b/.agents/FEATURES.md new file mode 100644 index 0000000..b3ba0f5 --- /dev/null +++ b/.agents/FEATURES.md @@ -0,0 +1,8 @@ +# Features + +One row per feature, with its analysis document (CLAUDE.md §5.1). Gaps live in +[`GAP_ANALYSIS.md`](GAP_ANALYSIS.md). + +| Feature | Phase | Status | Analysis | Review | +|:--|:--|:--|:--|:--| +| Workspace, contracts, gates, PWA shell | 0 | Built on `feature/phase0-workspace`, not merged | [phase0-workspace.md](features/phase0-workspace.md) | [feature-phase0-workspace.md](reviews/feature-phase0-workspace.md) | diff --git a/.agents/GAP_ANALYSIS.md b/.agents/GAP_ANALYSIS.md new file mode 100644 index 0000000..d3c9770 --- /dev/null +++ b/.agents/GAP_ANALYSIS.md @@ -0,0 +1,36 @@ +# Gap analysis + +What the product needs that it does not have yet, and what was closed. A closed gap +is struck through **with its evidence in the row** (CLAUDE.md §5.1). + +Ids are `G.`. `docs/ROADMAP.md` does not exist yet, so the phases here are +provisional. Phase 0 is defined in +[`features/phase0-workspace.md`](features/phase0-workspace.md). + +## Phase 0 — the workspace + +| Id | Gap | Status / evidence | +|:--|:--|:--| +| ~~G0.1~~ | ~~No workspace, no commands~~ | Closed 2026-11-01 on `feature/phase0-workspace`. Every §3 command except `art:prep` and `cargo test` runs; counts in the review. | +| ~~G0.2~~ | ~~Contracts §6.1–6.3 only in prose~~ | Closed 2026-11-01. `packages/schema/schemas/*.json` with generated types; `schemas.test.ts` 15 tests. §6.2's contradictory `act` list resolved (D5). | +| ~~G0.3~~ | ~~No single place computes a day~~ | Closed 2026-11-01. `engine/src/time/localDay.ts`; 18 golden, refusal and property tests. The UTC-day trap measured: Anchorage Monday 20:00 is UTC Tuesday. | +| ~~G0.4~~ | ~~Engine purity enforced by good intentions~~ | Closed 2026-11-01. ESLint rule in `eslint.config.mjs`; `purity-lint.test.ts` proves 16 bans fire inside the engine and not outside. | +| ~~G0.5~~ | ~~No library validator~~ | Closed 2026-11-01. `content/src/validator.ts`, 13 negative fixtures, each rejected with its named rule; every rule proved by a fixture. Mutation: disabling the length cap fails `validate:library`. | +| ~~G0.6~~ | ~~No `lint:copy`~~ | Closed 2026-11-01. One forbidden list shared with the validator; 9 files checked, 0 problems. | +| ~~G0.7~~ | ~~No commit guards~~ | Closed 2026-11-01. `pre-commit` blocked a 5.7 MB probe; `commit-msg` blocked a `Co-Authored-By: Claude` trailer; both passed clean input. | +| ~~G0.8~~ | ~~Never tested under the Pages sub-path~~ | Closed for the local build 2026-11-01. `shell.spec.ts` serves `dist/` at `/Rosea/` and asserts manifest scope = start_url = SW scope. Mutation: scope `/` fails it. **On real GitHub Pages: still predicted** (G0.13). | +| ~~G0.9~~ | ~~No proof the app opens offline~~ | Closed for the shell 2026-11-01. `offline.spec.ts` closes the server, then reload, cold start and a deep link all render. Mutations: `clientsClaim: false` and no `navigateFallback` both fail it. | +| G0.10 | No calm *refresh* control for a waiting service worker (CLAUDE.md §8, stale SW) | Open. `registerType: 'prompt'` and `skipWaiting: false` are set, so a new worker waits. Nothing tells the player yet. | +| G0.11 | IndexedDB eviction: no `navigator.storage.persist()`, no export-my-rose (§8) | Open. Arrives with `packages/storage`. | +| G0.12 | The app cannot validate content in the browser | Open. Ajv compiles with `new Function`, which the CSP forbids. Needs standalone pre-compiled validators before the app reads the library. | +| G0.13 | No GitHub remote, no Pages deploy workflow, no mirror check (§5.2) | Open. Only the Gitea remote exists. | +| G0.14 | Author-owned docs missing: `docs/ROADMAP.md`, `docs/GAMEPLAY.md`, `docs/PRINCIPLES.md`, `docs/ART.md`, `art/STYLE.md`, `docs/LETTER.md`, `HANDOVER.md` predecessor | Open. **GAMEPLAY.md blocks all game code.** Agents scaffold LETTER.md; they never write its voice. | +| G0.15 | Deferred packages: `storage`, `identity`, `sync`, `services/lucerna`, `tools/art-prep` | Open by design (D1). Each arrives with its first feature. | +| G0.16 | The outcome-phrase heuristic has no reviewed override | Open. A real sentence that trips it (a false positive) cannot enter the library. Design: a `reviewedBy` field on the entry, set only by a person. | +| G0.17 | Manual: install on a phone, open in airplane mode | Open. Needs a hosted build (G0.13). | +| G0.18 | The library is empty | Open by design (D4). Release needs ≥ 365 sunset sentences, each verified by the author. | +| G0.19 | Event kinds other than `care` | Open. Wait for GAMEPLAY.md: their fields are game design. | +| G0.20 | Node 22.11 on the dev machine is below what some pinned dependencies declare | Open. All gates pass on 22.11 today. Upgrade to ≥ 22.13 and unpin (D11). | +| G0.21 | No PNG icons | Open (predicted trap). iOS ignores SVG for `apple-touch-icon`. Comes through the art pipeline. | +| G0.22 | No CI | Open. Every gate ran on this machine only. With G0.13. | +| G0.23 | Source maps are built and would be published | Open. `sourcemap: true`; maps are not precached. Decide with G0.13 whether the repository is public. If not, use `'hidden'`. | diff --git a/.agents/features/phase0-workspace.md b/.agents/features/phase0-workspace.md index 1a3a6df..5d7cefb 100644 --- a/.agents/features/phase0-workspace.md +++ b/.agents/features/phase0-workspace.md @@ -1,6 +1,7 @@ # Phase 0 — the workspace -Status: **built on `feature/phase0-workspace`**, not yet merged. +Status: **built on `feature/phase0-workspace`**, not yet merged. Review: +[`feature-phase0-workspace.md`](../reviews/feature-phase0-workspace.md). Gates closed and still open: [`GAP_ANALYSIS.md`](../GAP_ANALYSIS.md). `docs/ROADMAP.md` does not exist yet, so this document defines Phase 0 itself. It @@ -44,15 +45,19 @@ flowchart LR scripts["scripts/
lint-copy, validate-library,
git hooks"] e2e["e2e/
Playwright: built bundle,
server killed for offline"] - app --> ui --> engine --> schema - app --> content --> schema - content --> engine + app --> ui --> schema + engine --> schema + content --> schema app --> schema scripts --> content content -. reads .-> lib e2e -. serves .-> app ``` +`ui → engine` (CLAUDE.md §2) is not drawn because nothing in `ui` calls the engine yet, and an unused +dependency is a dependency nobody tested. It arrives with the first component that renders a value +the engine computes. `app → content` likewise. + ### Decisions | # | Decision | Why | @@ -66,6 +71,9 @@ flowchart LR | D7 | The CSP lives in a `` tag: `default-src 'self'`, no inline script. The service worker is registered from an emitted file, not an inline snippet. | GitHub Pages cannot set headers (§8, predicted). An inline registration script would need `'unsafe-inline'` and quietly widen the policy for everything. | | D8 | No deploy workflow yet. | There is no GitHub remote. A workflow for a host that does not exist is configuration nobody can test. | | D9 | `localDay(epochMs, timeZone)` is the only day computation. It formats with `Intl.DateTimeFormat` for an explicit IANA zone. | §7: one module computes a day. The zone is always passed in. A city the player chooses maps to a zone, and so does the device fallback, which the app reads and the engine never does. | +| D10 | `apps/rosea/vite.config.ts` imports the name constants by **relative path** (`../../packages/schema/src/constants.js`), not as `@rosea/schema`. | Vite bundles a config's relative imports but externalises anything under `node_modules`, and Node cannot load a workspace package's `.ts`. `--configLoader runner` fixed `vite build` but not `svelte-check`, which still printed *failed to load config* inside a green run. The constants module is pure and has no imports. | +| D11 | Every direct dependency is **pinned exactly** to the version Ludus's lockfile resolved, and `engine-strict` is off. | This machine runs Node 22.11. Fresh resolution pulled `@axe-core/playwright@4.14` (needs ≥ 22.12) and `eslint-visitor-keys@5` (declares ≥ 22.13). Ludus runs the same packages on the same Node. Upgrading Node is G0.20. | +| D12 | The trace's `geocell` is capped at 6 characters. | Found in self-review: the first draft allowed 16, and a 16-character geohash is centimetres. Six is ~1.2 × 0.6 km, the ~1 km of CLAUDE.md §4. Anything finer is rejected by the schema, before any code could send it. | ## 3. Risk analysis @@ -101,13 +109,19 @@ is no mechanic yet that could carry any of them. | Hope-sentence schema accepts a valid entry | unit | `packages/schema/test/schemas.test.ts` | | Care event rejects an unknown `act`, a missing `localDay`, free text in `messageId` | unit | same | | Trace rejects a timestamp finer than a day and extra properties | unit | same | -| `localDay` in Prague on both 2026 DST days, Sydney, Anchorage, UTC±14 | unit (golden) | `packages/engine/test/localDay.test.ts` | -| Monday 23:30 in Prague is Monday, not Tuesday | unit | same | -| `localDay` is the same for every ms within one local day (property) | property | same, fast-check | +| `localDay` in Prague on both 2026 DST days, Sydney, Reykjavík, UTC+14, UTC−12 | unit (golden) | `packages/engine/test/localDay.test.ts` | +| Monday evening in Anchorage is Monday, though the UTC day is Tuesday (the trap, measured) | unit | same | +| An unknown zone throws instead of falling back to UTC | unit | same | +| Days never go backwards, always advance within 26 h, are deterministic (8 zones, 2000–2100) | property | same, fast-check | | Each purity ban fires on an impure snippet; clean code passes | unit | `packages/engine/test/purity-lint.test.ts` | | Every fixture in `content/fixtures/` fails with its named message | unit | `packages/content/test/validator.test.ts` | -| Forbidden words: whole-word, case-insensitive; no false hit on *treaty* or *cured meat*… | unit | `packages/content/test/forbidden.test.ts` | -| Shell copy passes `lint:copy` | unit + script | `packages/ui/test/copy.test.ts`, `pnpm lint:copy` | +| Forbidden words: whole-word, case-insensitive; no false hit on *treaty*, *healthy*, *patience* | unit | `packages/content/test/forbidden.test.ts` | +| `lint:copy` core: strings and markup caught, comments ignored, *Domi* never alone | unit | `packages/content/test/copy-lint.test.ts` | +| Shell copy passes `lint:copy` | script | `pnpm lint:copy` | +| Shell names the product from the constant, has a `main` landmark and no controls | unit | `packages/ui/test/Shell.test.ts` | +| Trace rejects a geocell finer than ~1 km | unit | `packages/schema/test/schemas.test.ts` | +| `` stays within the first 1024 bytes after the CSP | e2e | `e2e/shell.spec.ts` | +| Hooks block a > 5 MB file and an AI trailer, and pass a clean commit | manual, run | `.agents/reviews/feature-phase0-workspace.md` | | Built app renders its name at `/Rosea/` | e2e | `e2e/shell.spec.ts` | | No request to any other origin; no cookie; no `localStorage` | e2e | same | | Manifest `scope`/`start_url` and service-worker scope equal the base | e2e | same | diff --git a/.agents/lessons/README.md b/.agents/lessons/README.md new file mode 100644 index 0000000..c1772a2 --- /dev/null +++ b/.agents/lessons/README.md @@ -0,0 +1,20 @@ +# Lessons + +One file per category of problem (CLAUDE.md §5.1b). Read these first when something +behaves strangely. Each entry has three parts: **what happened**, **why it bit**, +and **how to apply it**. + +| File | Entries | What belongs in it | +|:--|:--|:--| +| `soul.md` | none yet | What comforts and what only looks like comfort. **The most important file here.** No mechanic exists yet that could teach anything. | +| `architecture.md` | none yet | Layering, ownership, seams. | +| `design.md` | none yet | Wording, silence, empty states. | +| `art.md` | none yet | The image pipeline. | +| [`code.md`](code.md) | 1 | TypeScript, Svelte, async ordering, Rust. | +| [`technical.md`](technical.md) | 3 | The browser and the build as platforms. | +| [`testing.md`](testing.md) | 3 | What makes a test worth having, and how a passing test lies. | +| `privacy.md` | none yet | What could leave the device or make a person findable. (The geocell finding is in the review, not here: it was caught before it cost anything.) | +| [`process.md`](process.md) | 2 | Workflow, commits, credentials, honesty about what shipped. | + +A file is created with its first real entry. An empty lessons file only looks like +knowledge. diff --git a/.agents/lessons/code.md b/.agents/lessons/code.md new file mode 100644 index 0000000..5485310 --- /dev/null +++ b/.agents/lessons/code.md @@ -0,0 +1,22 @@ +# Code + +## An agent's write tool can turn `\u00a0` into a real non-breaking space + +**What happened.** `packages/content/src/copy-lint.ts` was written with the regex +`[\s\u00a0]`. On disk the file held `[\s` + the bytes `C2 A0` + `]`: an actual U+00A0. +ESLint's `no-irregular-whitespace` caught it. Fixing it with `sed`, then with a +`node -e` replace, then with a quoted heredoc each wrote the same character back. The +fix that worked built both strings from char codes (`String.fromCharCode(160)`, +`String.fromCharCode(92) + 'u00a0'`). + +**Why it bit.** Somewhere between the agent and the file, a single-backslash +`\uXXXX` in the input was decoded. A double-backslash `\\u00a0` inside a JS string +(`forbidden.ts`) survived. The bug is invisible on screen: the two forms look the same. + +**How to apply it.** Prefer `\s` or a named class over a literal Unicode escape in a +regex. When one is needed, check the bytes after writing. +This entry was itself written with two literal NBSPs where it named the escape, and was +fixed the same way. Check with `grep -n $'\xc2\xa0' file` (the two UTF-8 bytes) or +`sed -n Np file | od -c`. Do not use `grep -P '\xA0'`: it matches the last byte of `≠` +and other characters, and raised a false alarm on the review document. Keep +`no-irregular-whitespace` on. diff --git a/.agents/lessons/process.md b/.agents/lessons/process.md new file mode 100644 index 0000000..6681dd8 --- /dev/null +++ b/.agents/lessons/process.md @@ -0,0 +1,33 @@ +# Process + +## Never "try" a credential helper to see if it works + +**What happened.** On 2026-10-31 the first push to Gitea failed for lack of +credentials. The agent retried with `-c credential.helper=manager`. Git Credential +Manager returned a stored login for `gitea.marek-novak.cz`, Gitea rejected it, and git +then told GCM to erase that login. The push finally worked once the author copied +Ludus's repo-local `credential.helper` into this repository. + +**Why it bit.** Git calls `credential reject` after an authentication failure. With +GCM that deletes the stored credential, so a failed probe is not harmless: it can +break every other repository that relied on the entry. + +**How to apply it.** When a push needs credentials, ask the author how this machine +authenticates for that host. Never probe with a different helper, and never read, +print or search for token values. On this machine, each repository carries its own +`credential.helper`. + +## Pin to a sibling's lockfile when the machine's Node is old + +**What happened.** The first `pnpm install` resolved the newest versions. +`@axe-core/playwright@4.14` needs Node ≥ 22.12, and `typescript-eslint@8.72` pulled in +`eslint-visitor-keys@5`, which declares ≥ 22.13. This machine runs 22.11. Pinning every +direct dependency to the versions in Ludus's `pnpm-lock.yaml` and turning +`engine-strict` off gave an install that every gate passes on. + +**Why it bit.** A caret range is a promise about the future, and the future had moved +past this machine's Node. Ludus, a known-good sibling on the same machine, was a +better source of versions than the registry. + +**How to apply it.** Start a new repository from a sibling's resolved versions, and +pin them exactly. Unpin deliberately, in its own commit, after upgrading Node (G0.20). diff --git a/.agents/lessons/technical.md b/.agents/lessons/technical.md new file mode 100644 index 0000000..22abc02 --- /dev/null +++ b/.agents/lessons/technical.md @@ -0,0 +1,42 @@ +# Technical + +## A Vite config cannot import a workspace package's TypeScript source + +**What happened.** `apps/rosea/vite.config.ts` imported the name constants from +`@rosea/schema`, whose `main` is `src/index.ts`. `vite build` failed with +`ERR_UNKNOWN_FILE_EXTENSION ".ts"`. `--configLoader runner` fixed the build. But +`svelte-check` loads the same config on its own, still failed, and printed +*failed to load config* while reporting 0 errors. + +**Why it bit.** Vite bundles a config's relative imports but externalises anything +resolved through `node_modules`. Workspace packages are symlinks there, so Node +loads them natively, and Node 22.11 does not strip types. A tool that reads the config +for you has its own loader. + +**How to apply it.** In a Vite config, import workspace code by **relative path** +to a dependency-free module. Treat a failure message inside a green run as a +failure: find which tool printed it. + +## Vite escapes the quotes in an injected `` CSP + +**What happened.** The built `index.html` carries `content="default-src 'self'…"`. +A regex over the raw HTML looking for `'self'` would never match it. + +**Why it bit.** The HTML is valid and the browser decodes the entities. Only a test +that reads the bytes sees the difference. + +**How to apply it.** Read attributes from the DOM: +`page.locator('meta[http-equiv=…]').getAttribute('content')`. Keep raw-HTML checks for +byte-level questions, such as whether there is an inline `