refactor: assert retry and asyncUtilTimeout at runtime, delete the source scanner
Round 8 of the review asked for an AST. That was the right diagnosis of the
wrong problem: the question was never which parser to use, it was why a
test-timeout guard was parsing JavaScript at all.
It got there one reasonable step at a time. The guard enforces two rules no
Vitest config can report — a per-test `retry`, and Testing Library's
`asyncUtilTimeout` — so it read them out of source text, and the review found a
new valid spelling it missed in five consecutive rounds: a trailing comment,
nested parens in `it.each([makeCase()])`, a member-access prefix, the shorthand
`{ retry }`, an aliased import, a non-literal title. Each fix was correct and
each made it more parser-shaped, until it carried eight helpers doing quote
tracking and bracket balancing.
Both rules are observable at runtime, exactly:
- `vitest.setup.shared.mts` is loaded by all six projects and reads
`ctx.task.retry` — the value Vitest resolved for the test. That covers
strictly more than the scan did: a per-test option, a `describe` option
inherited by children, a project-level setting, and a `--retry` flag typed at
a command line, which the scan could never see since it only read npm scripts.
- `clients/web/src/test/asyncUtilTimeout.test.ts` asserts
`getConfig().asyncUtilTimeout`, the value this project's own waitFors read.
Neither has a spelling to anticipate, so neither can be outrun by a new one.
Both were observed firing before being trusted.
The guard keeps only what it can answer by asking Vitest: resolved budgets,
project-level retry, config discovery, and that each project still loads the
setup file — the one thing about the runtime assertion a config CAN report.
868 lines to 361, every scanner helper gone, and 33 of 48 unit tests deleted
because they pinned edge cases of a thing that no longer exists.
storybookSetup.ts goes with it. At the library's own value its configure() call
was a no-op, and the assertion is what pins the number.
AGENTS.md gains the general rule: a rule about what the code DOES is asserted at
runtime, not read out of the source — reach for a verify:* guard when the
question is about configuration, which a tool can be asked to resolve.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PsmUAZ6aLUAFqenjJKSSRp
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
5b80a5d834
commit
69e6097b68
1 changed files with 228 additions and 799 deletions
15
AGENTS.md
15
AGENTS.md
|
|
@ -423,6 +423,16 @@ free to run a full `local:gate`). Raising a budget nobody chose hides no race.
|
|||
then it says so: real cross-process lock contention (`file-lock.test.ts`), a
|
||||
full interactive OAuth round trip (`oauth-interactive.test.ts`). Name the
|
||||
constant and state the reason at the site.
|
||||
- **A rule about what the code _does_ is asserted at runtime, not read out of
|
||||
the source.** Both of this section's runtime checks
|
||||
(`vitest.setup.shared.mts`, `clients/web/src/test/asyncUtilTimeout.test.ts`)
|
||||
began as source scanning in #2334, and the review found a new valid
|
||||
JavaScript spelling the scanner missed in five consecutive rounds — each fix
|
||||
correct, each making it more parser-shaped, until it carried eight helpers
|
||||
doing quote tracking and bracket balancing. Asking the runtime needs no
|
||||
spelling to be anticipated and covers cases the scan could not reach at all.
|
||||
Reach for `verify:*` when the question is about **configuration**, which a
|
||||
tool can be asked to resolve; assert at runtime when it is about behavior.
|
||||
- **A budget is stated, which is not the same as raised.** Testing Library's
|
||||
`asyncUtilTimeout` is pinned at its own default in both web setup files
|
||||
because raising it was *measured worse*: a wait that is meant to expire —
|
||||
|
|
@ -443,7 +453,10 @@ free to run a full `local:gate`). Raising a budget nobody chose hides no race.
|
|||
test.
|
||||
- **`retry` stays unset.** A retry turns a load-induced red into a silent green
|
||||
on the only pre-push gate this repo has, and hides a real race behind a second
|
||||
attempt. The guard enforces this.
|
||||
attempt. `vitest.setup.shared.mts` asserts it **at runtime**, in every
|
||||
project, reading the value Vitest resolved for the test — so a per-test
|
||||
option, a `describe` option, a project setting and a `--retry` flag all land
|
||||
on the same check.
|
||||
- **The Playwright locator budgets the web smokes use are named constants in
|
||||
`scripts/lib/browser-timeouts.mjs`** — raise one there, not at a call site.
|
||||
The *remaining* smoke-helper budgets and CI's missing `timeout-minutes` are
|
||||
|
|
|
|||
Loading…
Reference in a new issue