From 8ee3e1ce28b932d58faf3130a6f9ccd54c87c320 Mon Sep 17 00:00:00 2001 From: mnovak Date: Mon, 2 Nov 2026 00:51:46 +0100 Subject: [PATCH] [docs] CpuGuard: Record the guard in CLAUDE.md 5.7, its review, and G0.28 closed --- .agents/FEATURES.md | 1 + .agents/GAP_ANALYSIS.md | 1 + .agents/lessons/process.md | 6 +-- .agents/reviews/feature-keep-her-safe.md | 2 +- .agents/reviews/fix-cpu-guard.md | 47 ++++++++++++++++++++++++ CLAUDE.md | 6 ++- HANDOVER.md | 7 +++- 7 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 .agents/reviews/fix-cpu-guard.md diff --git a/.agents/FEATURES.md b/.agents/FEATURES.md index 550d42f..e629d49 100644 --- a/.agents/FEATURES.md +++ b/.agents/FEATURES.md @@ -8,6 +8,7 @@ One row per feature, with its analysis document (CLAUDE.md §5.1). Gaps live in | Workspace, contracts, gates, PWA shell | 0 | Merged to `main` 2026-11-01 (`d11d242`); built, not deployed. Phase 0 gate still open | [phase0-workspace.md](features/phase0-workspace.md) | [feature-phase0-workspace.md](reviews/feature-phase0-workspace.md) | | Roadmap and gameplay docs, read against the code | 0 | Merged 2026-11-01; Q1–Q7 answered by the author | — | [docs-roadmap-gameplay.md](reviews/docs-roadmap-gameplay.md) | | The Letter slot: page at `#letter`, empty `docs/LETTER.md` | 0 | Merged to `main`; built, not deployed. Invisible until the author writes | [letter-slot.md](features/letter-slot.md) | [feature-letter-slot.md](reviews/feature-letter-slot.md) | +| The CPU guard: full runs wait for, then refuse, a busy machine | 0 | Merged to `main` | — | [fix-cpu-guard.md](reviews/fix-cpu-guard.md) | | Keep her safe: the browser's promise, save her to a file, bring her back | 0–1 | Merged to `main`; built, not deployed | [keep-her-safe.md](features/keep-her-safe.md) | [feature-keep-her-safe.md](reviews/feature-keep-her-safe.md) | | The rose: care by feel, growth from days of care, drift, moods, her numbers; the care log and the identity | 1 | Merged to `main`; built, not deployed. Tuning is the author's | [rose.md](features/rose.md) | [feature-rose-care.md](reviews/feature-rose-care.md) | | Where the sunset is: choose a town (or skip to a guess from the device's zone), kept on the device; tonight's sunset in the garden | 1 | Merged to `main`; built, not deployed | [sunset-place.md](features/sunset-place.md) | [feature-sunset-place.md](reviews/feature-sunset-place.md) | diff --git a/.agents/GAP_ANALYSIS.md b/.agents/GAP_ANALYSIS.md index 1232e6e..6879955 100644 --- a/.agents/GAP_ANALYSIS.md +++ b/.agents/GAP_ANALYSIS.md @@ -42,6 +42,7 @@ board exist, and the first real picture is the author's to make. | 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'`. | | G0.24 | No art pipeline: `docs/ART.md`, `art/STYLE.md` (drafted with the author), `art/manifest.json` for Phase 1 assets, SVG placeholders, `tools/art-prep` | **Pipeline built 2026-11-01** (`feature/art-board`): docs/ART.md, the Phase 1 manifest (25 pictures), 29 generated stand-ins, `tools/art-prep` (50 tests; 5 of 5 put-back bugs caught), the art board published. STYLE.md approved by the author 2026-11-01 (S1–S5 kept as drafted; `docs/style-approved`). The board grew to 53 pictures with Phases 2–3 (`art/phase2-3-pictures`); the fox's look F1–F4 approved with a deep red-orange coat (`art/fox-coat`). **Still open:** the **Phase 0 gate**, one real picture through every step into `art/final/`. | | ~~G0.25~~ | ~~No slot for *A Letter from the Gardener*~~ | Closed 2026-11-01, merged to `main`. `docs/LETTER.md` holds slots as comments only; the page opens at `#letter` once it has words. 16 ui tests, and e2e on both the empty and a temporary written letter. Mutations caught: the link while empty, any link scheme, focus not moving, *heal* in the letter. | +| ~~G0.28~~ | ~~CLAUDE.md §5.7's CPU limit was only read, and broken three times on 2026-11-02~~ | Closed 2026-11-02 on `fix/cpu-guard`: `pnpm guard:cpu` runs before every full run, waits up to 3 min, then refuses. 13 tests; seen waiting 51 s on a busy machine, refusing, and stopping `pnpm test` before any test ran. | | G0.27 | The quiet door to real help has no numbers (§5.6 rule 5) | Open. The slot is in `docs/LETTER.md`. Support lines are real-world facts the author must verify, per country, so the door exists only once the letter does. | | ~~G0.26~~ | ~~Not decided: how the sunset invitation reaches the player on the web~~ | Closed 2026-11-01 by the author (Q6): in-app only on the web, no push server; local notifications through the Tauri shell in Phase 6. Recorded in ROADMAP Phase 0 and CLAUDE.md §8. | diff --git a/.agents/lessons/process.md b/.agents/lessons/process.md index e3c1c6e..1d39d79 100644 --- a/.agents/lessons/process.md +++ b/.agents/lessons/process.md @@ -42,6 +42,6 @@ because the check and the run were chained in one command that did not depend on **Why it bit.** A rule that relies on a person reading a number before acting holds only while nothing else is competing for attention. -**How to apply it.** Make the run refuse to start: a gate script that samples the load -and exits above 80 %, waiting or saying so. Until it exists, read the number in its own -step and decide before starting the run. +**How to apply it.** Make the run refuse to start. Done: `pnpm guard:cpu` (in +`tools/cpu-guard`) runs before every full run, waits up to three minutes, then refuses. Do +not set `ROSEA_CPU_MAX` to get past a busy desktop; it is for dedicated machines. diff --git a/.agents/reviews/feature-keep-her-safe.md b/.agents/reviews/feature-keep-her-safe.md index 962c2e4..3d1a121 100644 --- a/.agents/reviews/feature-keep-her-safe.md +++ b/.agents/reviews/feature-keep-her-safe.md @@ -32,7 +32,7 @@ Counts are on the merge; HANDOVER repeats them. New here: engine +4, storage +6, | 5 | Privacy | The file is a diary of when someone was in the app. | Made only on request; the screen says what it holds; no town and no private key (tested in unit and e2e). It goes wherever the player puts it, which Rosea cannot see. | | 6 | Privacy | A file brought back could have been edited by hand to give her days she was never given. | It only changes the player's own garden; nothing is counted against anyone (CLAUDE.md §1). Phase 3 must not treat imported care as proof towards friends: noted in the analysis. | | 7 | Soul | "This browser may clear her" can frighten. | Shown only behind *Keep her safe*, with the remedy in the same sentence; a refusal is said calmly. Nothing reminds or nags. | -| 8 | Process | The first e2e run **and the full gate run** both started with the CPU at 100 %, above the 80 % rule (CLAUDE.md §5.7). The load was another project's test run on this machine. The second time the reading was taken, but the run was chained after it without depending on it. Both passed. | **Not fixed by intention alone**: a gate script that refuses to start above 80 % would make the rule real. Lesson: `process.md`. | +| 8 | Process | The first e2e run **and the full gate run** both started with the CPU at 100 %, above the 80 % rule (CLAUDE.md §5.7). The load was another project's test run on this machine. The second time the reading was taken, but the run was chained after it without depending on it. Both passed. | **Fixed on `fix/cpu-guard`**: `pnpm guard:cpu` now runs before every full run. Lesson: `process.md`. | | 9 | Accessibility | A file input styled as a button. | The real input stays in place, labelled by its text, keyboard-operable; axe passes on the restored garden. Not tested with a screen reader. | ## What was not verified diff --git a/.agents/reviews/fix-cpu-guard.md b/.agents/reviews/fix-cpu-guard.md new file mode 100644 index 0000000..3cce4ca --- /dev/null +++ b/.agents/reviews/fix-cpu-guard.md @@ -0,0 +1,47 @@ +# Review — `fix/cpu-guard` + +Adversarial self-review (CLAUDE.md §5.3). Reviewed 2026-11-02 on Node 22.11.0, Windows 10. +There is no PR: the only remote is Gitea. + +## Why and what + +CLAUDE.md §5.7: *do not start a full run above ~80 % CPU.* On 2026-11-02 that was broken three times +(lessons/process.md), twice right after reading the number. Now `pnpm test`, `test:e2e` and +`test:offline` first run `pnpm guard:cpu` (`tools/cpu-guard`): + +```mermaid +flowchart LR + run["pnpm test / test:e2e / test:offline"] --> guard["guard:cpu
sample 2 s with os.cpus()"] + guard -->|"≤ 80 %"| go["the run starts"] + guard -->|"> 80 %"| wait["wait 10 s, sample again"] --> guard + wait -->|"after 180 s"| stop["exit 1: not starting"] +``` + +Node's `os.cpus()`, not a shell command, so it works the same on Windows, Linux and macOS. A +dedicated machine sets `ROSEA_CPU_MAX` (100 never refuses) and `ROSEA_CPU_WAIT_SECONDS`; a value +that is not a whole number in range is refused, never quietly the default. + +## Checks + +| Check | Result | +|:--|:--| +| Unit tests, `tools/cpu-guard` | **13 passed**: the busy share between two readings (not since boot), system time as busy, no NaN on equal readings, defaults, overrides, five bad settings, start / wait / refuse | +| On this machine, busy with another project's tests | waited 51 s at 93–100 %, then started at 61 % | +| Forced refusal (`ROSEA_CPU_MAX=1`, no wait) | exit 1 with the reason | +| `pnpm test` behind a refusal | stopped before Turbo ran a single test | +| The guard's reading beside Windows' own counter, sampled together | 64 / 75, 93 / 96, 96 / 98 % | + +## Findings + +| # | Finding | Resolution | +|:--|:--|:--| +| 1 | The guard measures before the run, not during it: a machine that becomes busy mid-run is not seen. | Accepted: §5.7 is about starting. Stopping a run halfway would leave browsers and servers half-closed, the very mess §5.7 exists to avoid. | +| 2 | `ROSEA_CPU_MAX=100` is a way round the rule. | Documented as for dedicated machines only, in CLAUDE.md §5.7 and the lesson. An override nobody can use would push people to edit the script instead. | +| 3 | The guard adds 2 s to every full run on a quiet machine. | Accepted. | +| 4 | Filtered runs (`pnpm --filter X test`) and drills are not guarded. | By design: they are not full runs. | +| 5 | Its own 2 s sample could read its own start-up as load. | It samples after Node has started. Not measured on a quiet machine: this one was busy all session. Beside Windows' counter it read 2–11 points lower, never higher. | + +## Not verified + +- macOS and Linux (only Windows 10 here). +- A CI runner: there is none yet (G0.22). diff --git a/CLAUDE.md b/CLAUDE.md index cc31084..dbedc07 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -220,6 +220,7 @@ pnpm test:e2e # builds, then Playwright against the B 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) +pnpm guard:cpu # waits for, then refuses, a machine above 80 % CPU (§5.7) pnpm art:board # prompts + stand-ins -> tools/art-prep/dist/board/ (docs/ART.md) pnpm art:accept # an accepted picture -> art/final/*.webp, sheets cut tsx scripts/build-places.ts # rebuilds the town list from downloaded Natural Earth + tzdb (by hand) @@ -412,7 +413,10 @@ happened twice.)* ### 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.)* +start a full run above ~80% CPU. *(Imported from Ludus and Aeterna.)* **Enforced, not trusted:** +`pnpm test`, `test:e2e` and `test:offline` first run `pnpm guard:cpu`, which waits up to three minutes +for the machine to calm and then refuses (`tools/cpu-guard`, lessons/process.md). A dedicated machine +such as CI sets `ROSEA_CPU_MAX` (100 never refuses); never set it to get past a busy desktop. --- diff --git a/HANDOVER.md b/HANDOVER.md index 6528f2a..feedf67 100644 --- a/HANDOVER.md +++ b/HANDOVER.md @@ -12,8 +12,8 @@ Rewritten at the end of each session (CLAUDE.md §5.1). Gitea hashes match. Analysis: [`.agents/features/phase0-workspace.md`](.agents/features/phase0-workspace.md). Review, with counts and the mutation results: [`.agents/reviews/feature-phase0-workspace.md`](.agents/reviews/feature-phase0-workspace.md). -- **Gates:** all pass on this machine. Unit tests: 373 (identity 5, schema 16, content 71, - storage 51, art-prep 56, engine 136, ui 38). E2E: 13. Offline: 1. `lint:copy`: 19 files, 0 problems. +- **Gates:** all pass on this machine. Unit tests: 386 (cpu-guard 13, identity 5, schema 16, + content 71, storage 51, art-prep 56, engine 136, ui 38). E2E: 13. Offline: 1. `lint:copy`: 19 files, 0 problems. `validate:library`: 13 of 13 fixtures rejected. - **Built, not deployed:** there is no host yet. - **Roadmap and gameplay docs:** `docs/ROADMAP.md` and `docs/GAMEPLAY.md` are on @@ -91,6 +91,9 @@ The notification decision is made: in-app only on the web (G0.26). **How this machine works** (not in the code): +- **The CPU guard:** the full runs wait for this machine to drop to 80 % CPU (§5.7). Other projects' + test runs share it, so a wait of a minute or two is normal; three minutes, and the run is refused. + - **Commit identity:** `mnovak `, set in this repository only. - **Pushing:** it uses a repo-local `credential.helper`, copied from Ludus. Do not