# Phase 0 — the workspace 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 covers what CLAUDE.md §2 calls "confirmed when Phase 0 scaffolds it" and what §3 calls "proposed until Phase 0 scaffolds them", and nothing more. **No game code.** `docs/GAMEPLAY.md` must be read before any, and it has not been written. --- ## 1. Why and what, in the player's terms The player gets nothing they can see. This is deliberate. When they open the link, they get a quiet page with the rose's name, and it still opens with the network off. What Phase 0 buys is the ground everything else stands on. It proves four things before anything exists that could hurt a person: - **The app opens with no network at all.** It is served from a sub-path, as GitHub Pages will serve it, and checked against the built bundle. - **Nothing leaves the device.** No third-party request, no cookie, no `localStorage`, enforced by a CSP in a `` tag. - **No word can reach a player that the rules forbid.** `lint:copy` and `validate:library` run, and they are proved to fire. - **The engine cannot read a clock or a die.** A lint rule refuses it, and a test proves the rule refuses it. ## 2. Technical architecture ```mermaid flowchart LR subgraph apps app["apps/rosea
@rosea/app
Svelte 5 + Vite + PWA"] end subgraph packages ui["packages/ui
@rosea/ui
copy/ + shell components"] content["packages/content
@rosea/content
library validator, forbidden words"] engine["packages/engine
@rosea/engine
time/localDay.ts"] schema["packages/schema
@rosea/schema
JSON Schemas, generated types, constants"] end lib[("content/library/*.json
content/fixtures/*.json")] scripts["scripts/
lint-copy, validate-library,
git hooks"] e2e["e2e/
Playwright: built bundle,
server killed for offline"] 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 | |:--|:--|:--| | D1 | Create `schema`, `engine`, `content`, `ui` and `apps/rosea` now. **Defer** `storage`, `identity`, `sync`, `services/lucerna` and `tools/art-prep` to their first feature. | An empty package has a test suite that runs nothing and exits 0. That is the `pnpm test` trap (§3) built into the layout on purpose. Each package arrives with the feature that gives it a test. | | D2 | The build's base path is `/Rosea/` by default and `ROSEA_BASE` overrides it. The test server serves `dist/` **under that prefix**, never at `/`. | GitHub Pages serves a project at `//` (§8, predicted). If Vite `base`, the manifest `scope`/`start_url` and the service-worker scope disagree, the installed app opens a 404. Testing at `/` would never see it. | | D3 | Engine purity is an **ESLint rule** scoped to `packages/engine/src`, plus a test that lints a deliberately impure snippet and asserts each ban fires. | CLAUDE.md §7 says "lint rule". Ludus said the same and shipped a source-scanning test instead. Here it really is a lint rule, and the test is what keeps it honest. The ban includes `Intl.DateTimeFormat().resolvedOptions()`: it reads the device's time zone, which must be a parameter. | | D4 | `content/library/` ships **empty**. The validator prints its counts and passes on zero entries, but it fails if any fixture passes. | Every sentence needs `verifiedBy` from the author (§6.1). An agent writing "verified" entries would be inventing a fact. The 365-sunset-sentence requirement is a release gate, not a Phase 0 gate. | | D5 | The event schema defines only the `care` kind, with `act: water \| shade \| weed \| petals`. | §6.2 contradicted itself: the example listed `wind \| light` and the comment listed `weed \| petals`. §1 describes weeds and fallen petals, so the comment wins, and CLAUDE.md is corrected in the same branch. The other kinds (`sunset`, `fox`, `harvest`…) wait for `docs/GAMEPLAY.md`, because their fields are game design. | | D6 | One forbidden-word list, in `packages/content/src/forbidden.ts`, used by **both** `lint:copy` and the library validator. Whole-word, case-insensitive. `treat` is banned outright. | Two lists drift. Banning `treat` means the fox's food is always *berries*, never *treats*. That is a little inconvenient and much cheaper than a medical-claim review. | | 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 Here "risk" means a person feeling worse, a person's location, or a person being reachable who did not ask to be. | Risk | Where it could enter in Phase 0 | Defence | |:--|:--|:--| | A forbidden or medical word reaches a player | Shell copy, manifest description, `index.html` | `lint:copy` scans `packages/ui/src/copy/`, `apps/rosea/index.html`, the manifest fields in `vite.config.ts` and `store/`. Fixtures prove it fires. | | *Lonely* / *loneliness* appears in the product | Same | On the forbidden list (§5.6 rule 4). Allowed only in `.agents/` and `docs/`, which `lint:copy` does not scan. | | A byte leaves the device | Fonts, icons or a CDN pulled in by a dependency | CSP `default-src 'self'`. The e2e suite records every request and fails on any origin other than the test server's. | | Storage outside IndexedDB | A library writing `localStorage` | The e2e suite asserts `localStorage.length === 0` and `document.cookie === ''` after load. | | A day computed in UTC | The engine, later | D9, a purity-lint ban on `toISOString().slice`, and DST golden tests for `localDay`. | | The empty shell feels like a broken app | The placeholder page | One calm line from `copy/`, no spinner, no "coming soon". It says what is true and asks nothing. | Looked for and not found in Phase 0: guilt, comparison, rejection, dependence. There is no mechanic yet that could carry any of them. ## 4. Gap analysis and the designed solution | Gap | Solution in this branch | |:--|:--| | No workspace, no commands | `pnpm-workspace.yaml`, `turbo.json` and root scripts for every command in §3 that has something to run. | | `pnpm test` can exit 0 having run nothing | `test` is not cached (`cache: false`). Every package has at least one real test. Counts are quoted in the review. | | No proof the PWA works offline under a sub-path | `e2e/offline.spec.ts` starts a real static server at `/Rosea/`, waits for the worker to control the page, **kills the server**, reloads, and asserts the shell rendered. Ludus learned that `context.setOffline` acts before the service worker and tests the harness, not the cache. | | No guard on commits | `scripts/pre-commit` (5 MB) and `scripts/commit-msg` (AI attribution), installed by `pnpm install`. | | CRLF churn on Windows (`core.autocrlf=true` on this machine) | `.gitattributes` with `* text=auto eol=lf`. | ## 5. Verification matrix | Case | Kind | Where | |:--|:--|:--| | 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, 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*, *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 | | CSP meta present; no inline script in the built `index.html` | e2e | same | | No axe violations on the shell | e2e | same | | Shell loads with the server gone | offline | `e2e/offline.spec.ts` | | **Manual**: install from Chrome on a phone; open in airplane mode | manual | not done — needs a hosted build (D8) |