[docs] CpuGuard: Record the guard in CLAUDE.md 5.7, its review, and G0.28 closed
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<br/>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).
|
||||
Reference in New Issue
Block a user