Repository navigation
chore(tests): re-measure the unit lane against its stated Tier 1 budget - #994
Conversation
`docs/rules/testing-reqs.md` gave Tier 1 `< 5 s` and Tier 2 `< 45 s`, and `tests/AGENTS.md` called the unit lane "~1–2 s for ~200 cases". Measured on 4 cores: the lane is 59 s for 198 files and 2575 tests, and the lean gate is 138 s. `README.md` and the root `AGENTS.md` both called the lane "fast". Both branches of #990 apply, to different tiers. Tier 2's target was stale, so it is raised to the measurement. Tier 1's is not stale — 5 s is what the per-edit hook needs, and one spec costs 1.9 s — so it is kept, and what misses it is the hook running all 198 files to answer about one. That gap is not latency. `.claude/hooks/unit-test.mjs` bounds the lane with a 30 s `execSync` timeout, so at 59 s the timeout always fires and the catch branch reports `Unit tests failed after editing <file>` with a tail holding no failure. Every src edit is told its tests broke while 2575 of them pass. The repair is #993: the hook sits under a protected path, which no unattended run may write. The numbers live in `tests/PERF.md`, which already held the integration lane's, with the machine, the date and the Vitest breakdown behind each. The four other docs now quote it and say so, so the next drift has one place to go red rather than four prose claims to contradict. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GF8TwbmG6sGqbDKXnommQN
The `/code-review high` pass found seven defects, all in what the first commit *derived* rather than in what it measured. Re-measuring settled each: - Vitest's non-watch default is `max(cores - 1, 1)`, so 59.2 s is a 3-worker figure, not 4. Dividing it by cores made the extrapolation several times too fast. `--maxWorkers=4` is 49.2 s, measured. - Fitting `wall = S + P/N` to the 1- and 4-worker runs gives S ≈ 19 s, P ≈ 122 s, and predicts the 3-worker run at 59.4 s against 59.2 s measured. The serial floor, not a core count, is why no machine reaches 5 s — a stronger claim than the one it replaces, and one three runs support. - The `53e4569` breadcrumb was this clone's shallow graft, not the commit it named. `git fetch --deepen=300` reaches `228c3a1` (2026-09-02), which moved `testing-reqs.md` to its current path carrying `< 5 s` over 113 spec files. - Tier 2's 138 s is `check.sh`, which also starts Postgres. The row's own four commands sum to 104 s. Both are now stated, each against what it measures. - `typecheck` "15–20 s" and `typecheck:tests` "6 s" are 8 s each, and were violating the invariant the same commit introduced. Measured and recorded. - One spec is 1.9–3.0 s, not 1.9 s, and a narrowed hook runs several. #993 now owes the per-edit number rather than inheriting a guess. - `/usr/bin/time -p` is absent on the routine containers (exit 127). All four measurement commands take the shell keyword. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GF8TwbmG6sGqbDKXnommQN
A second `check.sh` run came in at 103 s against the first run's 138 s, which lands the warm figure on the four commands' own 104 s sum. The 35 s is `scripts/ensure-test-db.sh` starting Postgres, which costs nothing once port 5432 answers — so the gate has two honest numbers, not one, and which you get depends on whether a database is already running. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GF8TwbmG6sGqbDKXnommQN
sydevs-bot
left a comment
There was a problem hiding this comment.
1 question for the reviewer, one per thread.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
|
🚅 Deployed to the SahajCloud-pr-994 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff matches #990: it measures the lane, records the result with machine and date, and makes the five stated numbers agree. Scope is right — the two surviving stale claims are under .claude/, a protected path, and #993 carries them rather than this PR stalling. Keeping Tier 1's 5 s and raising Tier 2's is the defensible split, and the question thread leaves that choice to you.
One gap against the ticket: it asked to keep the decision checkable, and the answer is prose — what went stale the first time. tests/PERF.md grew 92 lines for a figure, a core count and a date, a third of it the authoring run's own story.
Findings
consider— the measurement invariant has no enforcement, where #990 asked for checkable (tests/PERF.md:15).consider— Tier 2 targets < 120 s while the gate named in the same row measures 138 s cold (docs/rules/testing-reqs.md:26).consider— two paragraphs document the authoring session, not the lane (tests/PERF.md:91and 84–89).
What was checked
- Profile read. All 5 changed files read whole, plus the hook,
check.sh, #990, #993. - The ⚠ hook paragraph holds: the timeout is 30000 ms, and the catch branch prints
Unit tests failed after editing <file>. find tests/unit -name '*.spec.ts' | wc -l→ 198, matching the "198 files" claims.- Grepped every
*.md,*.shand*.mjsforfast unit,1–2 s,under 5 second,45 s. Only the two.claude/files #993 lists survive, so no writable claim was missed./usr/bin/timeis absent here, so that ⚠ holds too. - #993 carries both hook defects, the three stale claims and the rejected
isolate: falsealternative, so #990's third criterion is met. - Not verified: the
getDefaultThreadsCountcitation — nonode_moduleshere. Timings not re-run. No preview to open, no contract surface touched.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`tests/PERF.md` declared itself the single writer of every tier figure and nothing held it to that, which is how `< 5 s` came to describe a 59 s lane. #990 asked for the decision to stay checkable; the answer was prose. `tests/unit/perf-figures-pinned.spec.ts` reds on each of the three ways the figures can drift apart: the recorded file count against the specs on disk, a consumer doc that stops quoting PERF.md's lane figure, and a Tier 2 target below the cold cost of the gate its own row names. It asserts no wall-clock time on purpose. A timing bound inside the lane goes red on a loaded machine, and a check people learn to ignore is worth less than the prose it replaced. Addresses #994 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014mDVAnCGQKXxtEwbwXQ7Zq
The row targeted < 120 s while naming `check.sh` as what fires it, and `check.sh` measures 138 s on a session's first run: it also starts Postgres through `scripts/ensure-test-db.sh`, which the four commands' 104 s excludes. A target the named gate cannot meet is the drift this PR is about, one tier up. The target now bounds the gate, cold, and the row carries both figures so nothing has to re-derive which one it is. Addresses #994 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014mDVAnCGQKXxtEwbwXQ7Zq
Two passages described the run that wrote this file rather than the lane it measures, in a file whose new opening declares every figure a measurement. The `228c3a1` paragraph dated the staleness and then reported that the clone could not reach the figure's origin. Someone re-measuring uses neither, and the PR body carries the shallow-clone caveat already. The 15- and 63-worker numbers were extrapolations, not runs. The `S ≈ 19 s` fit they hung off stays: it is why no core count reaches 5 s, which is the claim the budget decision rests on. Addresses #994 (comment) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014mDVAnCGQKXxtEwbwXQ7Zq
Merging `main` brought #985's four specs in, so the recorded 198 files and 2575 tests described the branch before the merge. The new spec is a fifth. 203 / 2643 now, and the figure pinned in all four consumer docs follows. Re-measuring on the current base also turned up something about the figures themselves. Three runs give a 77.9 s median against the first session's 59.2 s, on the same container spec, the same day, for 2.5% more files — and the three runs fell monotonically from 82 s to 73 s as caches warmed. So a single container's reading is reproducible to about ±30% and no better. Both samples are recorded rather than one replacing the other, the slower median is what the consumers quote, and the file says not to read a 20% move as a regression. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014mDVAnCGQKXxtEwbwXQ7Zq
This session's own lean-gate run took 174 s, against the 138 s recorded from the previous one — so a 150 s target was already false when it was written, for the same reason the lane's two medians sit 30% apart. A target set on one reading of a varying measurement is the drift this PR exists to stop, so the rule is now stated: Tier 2's target bounds the slowest cold run on record, and both cold figures are in `tests/PERF.md`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014mDVAnCGQKXxtEwbwXQ7Zq
|
Three threads adopted,
The figures are less reproducible than this PR claimed ( Tier 1's question thread stays open. Lean gate green. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Tier 1 asked for a middle ground between 5 s and the lane, and the only per-edit cost that is reachable is a narrowed hook's. Measured it: the specs naming an edited module are 1 file for the median module (1.3 s), 7 for `@/plugins/login` (6.9 s) and 18 for the generated `@/payload-types` (7.8 s). The target is 12 s — it bounds the widest of those with room for the spread this file now records, and it matches SahajAtlasWeb's own measured per-edit budget on the same core count, whose hook this one would copy. 5 s sat below the widest real selection, so no hook could meet it. 65 s was the whole lane wearing the hook's name. The spec gains the claim that keeps it honest: Tier 1's target covers the widest recorded selection, the way Tier 2's covers its cold gate. Watched it red against the old 5 s before keeping it. A third session's measurement comes with it. The merged base added a spec, which the file-count claim caught, and the lane measured 47 s where the last session read 78 — three medians spanning 66% on one container spec in one day. The docs keep quoting the slowest as an upper bound. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGohWMMXeuCCytWsDLHL1N
The new Tier 1 claim is itself a case, so the lane runs 2653 and not the 2652 the previous commit recorded. Found by running the gate, which is the only thing that reports this figure — the spec pins the file count to disk and takes the test count on trust. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YGohWMMXeuCCytWsDLHL1N
|
Tier 1 targets Adopted — the Tier 1 thread, resolved. The target is a per-edit cost, so I measured what a narrowed hook costs: 1 spec for the median module (1.3 s), 7 for The base merged clean, and brought a fifth unit spec. The file-count claim caught it, so the counts are now 204 / 2653. One finding, not a thread. The lane measured 47 s here against 78 s last session — same container, same day, more files. A 66% span across three readings, so every target now bounds the slowest reading recorded for it, never a median. The docs keep quoting 78 s. Nothing is open. #993 still carries the hook itself. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
#994 re-measured the unit lane and rewrote every tier figure. Three files conflicted, and all three are files this branch touches only in 3b05cad, the pure `prettier --write` commit — so each took main's content and was re-formatted, rather than merged hunk by hunk: - README.md — #994's `test:unit` row, naming the 78 s figure - tests/AGENTS.md — #994's unit-lane speed cell - docs/rules/testing-reqs.md — #994's tier targets, its Tier 1 false-failure block and its 8 s typecheck figures, plus this branch's own two additions re-applied on top: `pnpm format:check` in the Tier 3 row, and the paragraph on why Tier 2 omits it README.md and tests/AGENTS.md are byte-for-byte `prettier(main's version)`. AGENTS.md auto-merged and differs from it only by this branch's three hand-written lines. #994 also adds tests/unit/perf-figures-pinned.spec.ts, which captures each figure out of tests/PERF.md with patterns written against single-space table pipes. Prettier pads a table's columns to its widest cell, so every capture missed and the suite threw at module scope — 11 cases, red before this commit and green after. The patterns now allow whitespace around a cell's pipes, which pins the same figures under either spelling. PERF.md's note on keeping the cell shapes says so too. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PboE8yeU78GsynhzDDTr2a
#1007 moved the per-block field notes out of `src/collections/AGENTS.md` into `src/lib/richEditor/blocks/AGENTS.md`, keeping only the `⚠` bullet reporting #989. This branch fixes #989, so that bullet is now false in both files it landed in: the condition reads `imagePosition`, and the checkbox renders. Took main's structure — the block table stays moved, not restored — and dropped the stale warning. `blocks/AGENTS.md` keeps the field note in the shape of its `textColor` twin, with the #989 breadcrumb and the reason `position` is the wrong name. #994's new `perf-figures-pinned` spec then went red on a conflict no textual hunk shows: it pins `tests/PERF.md`'s spec count to the files on disk, and this branch adds the 205th. PERF.md records the current tree's counts by its own rule, so it and the four consumer docs move together, as that spec requires. Lean gate green: lint, typecheck, typecheck:tests, 2657 tests across 205 files. `tests/int/translations-field.int.spec.ts` 26 passed. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMsfQPCwjEaRYV2sLpaeP9
Main's #1007 trimmed the agent guides; this branch extends two of the files it trimmed. Three hunks, resolved toward both sides: - `docs/rules/access.md`: took #1007's removal of the manager-role table, a config copy it cut deliberately. The dropped `atlas-manager` row carried one thing the config does not show — that `imports: create` is also what keeps the collection's admin pages visible — so that moved onto the `imports` paragraph, which already owns the collection's access block. - `docs/rules/admin-ui.md`: took #1007's trim of the `@payloadcms/ui` table and of the custom-field paragraph. `ProgressBar` is exported, so the warning below the table no longer had a curated list to be absent from; it now names what the component actually is. - `docs/rules/admin-ui.md`: kept the `WorkflowButtons` section. It documents `src/components/admin/WorkflowButtons/`, which only this branch carries, so #1007 never saw it. `tests/PERF.md` needed a count, not a resolution. #994 recorded 204 unit specs and #990's spec pins that figure to the tree, so the merged tree's 215 files and 2783 tests reddened it with neither side wrong. Re-recorded the two counts, and the three consumer docs that restate them. Timings are untouched: PERF.md keeps each one with the session that measured it. Lean gate green: lint, typecheck, typecheck:tests, 215 unit files / 2783 tests, in 83 s. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012KhBAi8xKwJspy75uAvmDV
Summary
< 12 sper edit, measured from what a narrowed hook costs rather than from the lane or from one spec.src/**edit is told its tests failed while 2653 pass. The repair is fix(tests): the per-edit hook times out and reports a false failure #993 — the hook is a protected path.tests/unit/perf-figures-pinned.spec.ts). It caught two live defects in this PR's own figures.Change outline
The three-tier contract is the thing that changed. One rule per line, from
docs/rules/testing-reqs.md§ Three-tier speed contract.Where a figure lives, who may state one, and what reds when they disagree.
tests/PERF.mdheld the integration lane's numbers already; it now holds theunit lane's, and is the single writer the other four quote.
Why Tier 1 targets 12 s
< 5 sand~65 swere the two options put to review. Neither survived themeasurement, for opposite reasons, so the reviewer's ask for a middle ground
is what the number now rests on.
Tier 1's target is a per-edit cost, so what it bounds is a narrowed hook's
selection — not the lane. Selecting the specs that name an edited module
measures:
@/plugins/login@/payload-types, the generated file12 s bounds the widest of those with room for the spread below, and matches
SahajAtlasWeb's own measured per-edit budget on the same core count — the
hook this one would copy (#993). 5 s sits below the widest real selection,
so no hook reaches it, which is a sharper objection than the one this PR first
made. 65 s was the whole lane wearing the hook's name.
What the spec holds, and what it deliberately does not
Four claims, each red on its own:
*.spec.tsfiles on disk. The one figure a machine settles without timing anything, and the proxy for the lane growing — 113 files carried< 5 sto 198 unnoticed.⚠ It asserts no wall-clock time. A timing bound inside the lane reds on a loaded machine, and a check everyone learns to ignore is worth less than the prose it replaced. Re-measuring therefore edits PERF.md and the four consumers in one commit, by design.
Preview
Docs and one spec — no route, field or behaviour changes, so the Railway preview
renders nothing this PR touches. The diff is the whole change.
Test results
.claude/skills/pr-prep/check.sh— lint,typecheck,typecheck:tests,test:unit. 110 s this session, against 138 s and 174 s before; the target still bounds the slowest.Manual verification
tests/PERF.mdwith your core count, and update the four consumer docs — the new spec reds until you do. The container's figures are an upper bound, not your number.Unit tests failed after editing src/lib/richEditor/index.tsafter 30 s, with only Vitest's banner in the tail.Notes for reviewer
926df32, and claim 4 above is what holds it there. No thread is open.check.shmoved the same way: 138, 174, 110 s. So every target bounds the slowest reading recorded for it, never a median, and PERF.md says not to read a 60% move as a regression. All three samples are kept..claude/hooks/unit-test.mjsand.claude/skills/pr-prep/check.share protected paths, so the hook repair and the last two "fast unit lane" claims need an attended session. fix(tests): the per-edit hook times out and reports a false failure #993 says so at the top, so the loop hands it back rather than stalling on it.wall = S + P/Nfitted to the first session's 1- and 4-worker runs gives S ≈ 19 s, and that fit predicts its 3-worker run to within 0.2 s. It is two points fitted and one point confirming, not a proof. Its unmeasured 15- and 63-worker extrapolations were cut. It is why narrowing the hook, not cutting the lane, is the route to any per-edit budget./code-review highreturned seven, all in derived claims rather than measurements, all confirmed by re-measuring and fixed in1195487. None dismissed. The adversarial review then returned three; all three are adopted. The one worth naming: the first commit's53e4569breadcrumb was this clone's shallow graft commit, not the commit it claimed;git fetch --deepen=300reaches the real one.Detail
Why Tier 2's target is 210 s and not 120. The row names
check.shas what fires it, andcheck.shalso starts Postgres throughscripts/ensure-test-db.sh— which the four commands' 104 s excludes. Cold runs measured 138, 174 and 110 s. A target set on one reading of a varying measurement is the drift this PR exists to stop, so the target bounds the slowest cold run on record and the rule is written down.Why not make the lane itself faster.
isolate: falseon the unit project would plausibly bring the lane under the hook's 30 s timeout, and was not measured or taken: it masks the false failure without reaching any per-edit budget, and it shares module state across spec files, which the lane'svi.resetModules()env-swap pattern and its five jsdom specs rely on not happening. Recorded in #993 as the rejected alternative.Measurements behind the claims (4 cores, Intel Xeon @ 2.80 GHz, 15 GB, routine container, 2026-10-20).
mainagain, 204 files / 2653 tests: lane 47.16 / 46.38 / 47.82 s, median 47.2 s; phases transform 10.0 s, import 90.5 s, tests 12.9 s, environment 3.6 s;check.sh110 s. Per-edit selections 1.3 s (1 spec), 6.9 s (7), 7.8 s (18).check.sh174 s cold.lint28.5 s,typecheck8.4 s,typecheck:tests8.2 s, the four summed 104 s;check.sh138 s cold, 103 s warm.The consumer docs still quote 78 s, the slowest median, because that is the upper bound the invariant asks for. A reader whose own lane runs in 47 s is not reading a stale doc.
How stale the figure was.
228c3a1(2026-09-02) moveddocs/rules/testing-reqs.mdto its current path carrying< 5 s, over 113 spec files. Its own origin is older than this clone reaches, deepened or not.Base merged twice.
origin/mainmerged in cleanly at the start of each session, so every commit builds on the current base. #985 brought four unit specs and #978 brought a fifth — each time the file-count claim is what caught the stale figure, which is the clearest evidence the spec earns its place.Tool limitation hit. The routine clone is shallow, so
git log -Sreports the graft commit as the origin of any string older than the window. It looks exactly like a real answer.git fetch --deepen=<n>and a re-run is the check.Closes #990
🤖 Generated with Claude Code
https://claude.ai/code/session_01YGohWMMXeuCCytWsDLHL1N