docs(agents): add a test-audit procedure with the mutation discipline that worked

Merged
TH
2mo ago
+58-0

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, satisfies compared after it stops existing at runtime), a lone typeof x === 'function' sitting directly above the test that calls x, an ordering claim with no ordering assertion, a switch written 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-error directives (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 status clean. 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 --test script (test:smoke, check:*:test), native XCTest, or a CHECK_CATALOG gate id. Vitest-project matching alone would have misclassified the healthy node:test integration 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 upstream run-vitest.mjs/check-changed.mjs helpers do not exist here. It also records a trap found the hard way: most scripts/** tests are in no tsconfig include, 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, and docs/agents/ totals 39,897 of 40,000 bytes with AGENTS.md at 7,989 of 10,000.
  • pnpm format, pnpm lint, pnpm check:quick
  • pnpm check:affected --run on the pushed head: selects only agent-guidance, passes