docs(agents): add a test-audit procedure with the mutation discipline that worked
Merged
TH
2mo ago+58+58+01234567890123456789-0-0-0123456789
Summary
Adds docs/agents/test-audit.md and routes it from the AGENTS.md task table. Adapted from the upstream openclaw test-audit card (https://github.com/openclaw/openclaw/blob/main/.agents/skills/test-audit/SKILL.md). This is the workflow that produced #2930-#2944; capturing it here so the next sweep starts from the repo's own rules instead of rediscovering them.
It lives under docs/agents/ rather than skills/, per AGENTS.md: skills stay minimal routing cards and task procedures go in docs. A test audit is not an app-driving capability the CLI skill routes to, so it does not need a card at all.
What is repo-specific versus upstream:
- Junk patterns are the shapes that turned up as real findings here: type pins surviving erasure (
Equal<A,B> = true,X ? true : never,satisfiescompared after it stops existing at runtime), a lonetypeof x === 'function'sitting directly above the test that callsx, an ordering claim with no ordering assertion, aswitchwritten inside a test body and compared to its own arms. - Retention bar is earned, not copied: registry/gate-manifest/layering completeness, golden tables and cross-language source inspection,
@ts-expect-errordirectives (an unused directive is a compile error — they do bite), exact-array facets where a membership scan can't see duplicates, identity pins deep-equal can't subsume, vocabulary pins that survive a production+fixture co-update. - Mutation discipline is the part worth keeping even if the rest gets rewritten: plant the production edit that represents the claimed bug, show old body green and new body red with both counts, revert, show
git statusclean. Arguing detection is not evidence; measuring it is. - Never-run detection asks which runner and gate actually executes a file — a Vitest project, a
node --testscript (test:smoke,check:*:test), native XCTest, or aCHECK_CATALOGgate id. Vitest-project matching alone would have misclassified the healthynode:testintegration and gate suites. - Validation commands are ours (
pnpm exec vitest --project unit-core/apple-runner,pnpm check:quick,pnpm check:affected --run,git diff --numstat origin/main...HEAD), and the doc records that the upstreamrun-vitest.mjs/check-changed.mjshelpers do not exist here. It also records a trap found the hard way: mostscripts/**tests are in notsconfiginclude, so helpers added there need an explicit check that they execute. - Dispatch plan for parallel subagent lanes is included (subsystem lanes + cross-cutting pattern sweep + never-run inventory), with the mandatory per-prompt rules: read-only, name the production bug, verify skip guards and runner/gate ownership, retention list verbatim, cap output.
Validation
pnpm check:agent-guidance— 5 pass. The doc is 3,943 bytes, inside the 10,000-per-file budget, anddocs/agents/totals 39,897 of 40,000 bytes with AGENTS.md at 7,989 of 10,000.pnpm format,pnpm lint,pnpm check:quickpnpm check:affected --runon the pushed head: selects onlyagent-guidance, passes