协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
test-mutation【开发与工程】Run mutation testing (StrykerJS, mutmut) to measure whether tests assert behavior, not just execute lines. Use when "add mutation testing", "are our tests real", "can our test suite be gamed", or after an agent bulk-generated tests.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Degree of freedom: MIXED — scope and triage [HIGH freedom]; first run
and CI floor [LOW freedom — measure, then ratchet]. Never start with the
whole repo.
Install and run the gate coverage cannot close. Coverage proves the test
ran the code; mutation testing proves the test would notice if the
code were wrong. The tool makes hundreds of small deliberate bugs
(mutants) — flip > to >=, delete a statement, replace a return — and
reruns the tests. Survivors mark code the tests execute but verify
nothing.
This is the specific counter to agent-generated suites: an agent can trivially produce 90% coverage with no meaningful assertions, and every coverage ratchet will wave them through. Mutants do not care about coverage theater.
| Skill | Owns |
|---|---|
| test-mutation (this) | Install / run / triage mutation testing; score ratchet |
plan-test-coverage | What should be tested — plan only, no harness |
test-unit | Write the tests |
audit-gate-logic / housekeep-gates | Ratchet policy this score plugs into |
enhance-agent-guardrails | Wording of the agent-rule hook |
Observe: Stryker flipped
>to>=inentitlements.tsexpiry check; suite green; mutation score 62% on a 94% coverage file. Interpret: tests execute the line but never assert the boundary. Classify: missing assertion. Severity: high — paid access could extend a day. Fix: assert expired-at-exact-boundary is denied; then re-run incremental.
Identify the runner and pick the tool: StrykerJS (Jest / Vitest / Mocha, TS-aware), mutmut / cosmic-ray (Python), or the ecosystem built-in. Then scope — this step decides whether mutation testing survives in the repo:
Never start with the whole repo. Each mutant is a test run. A 6-hour
first run gets the tool deleted. Scope the first pass to where a silent
bug costs most: money movement, auth, entitlements, data mutation, core
business logic. Explicitly exclude: generated code, config, type-only
files, UI glue better covered by test-visual-regression, and third-party
wrappers.
Record the suite's baseline runtime. Mutation runtime ≈ (mutants × affected-test runtime). Turn on per-test coverage analysis from day one so only tests covering the mutated line rerun.
mutate: globs.--incremental): later runs only
re-test mutants in changed code — this is what makes per-PR runs
feasible.high / low for reporting, and break (CI-failing
floor) at or slightly below the measured first score. Never invent an
aspirational floor; measure, then ratchet. Same
auto-tighten-with-reviewed-resets policy as housekeep-gates.Run, then classify every surviving mutant — this triage is the deliverable:
plan-test-coverage).workflow-housekeep).< vs <= on a boundary that cannot occur). No test can kill it;
mark ignored with a comment. Expect a small percentage; a large one
means the mutator is mutating the wrong things.Prioritize by blast radius: a survivor in entitlements.ts outranks
fifty in a formatting helper.
housekeep-gates).break rises as the score does (flake tolerance);
lowering it is a separate reviewed PR, never bundled.enhance-agent-guardrails
installs the wording.break threshold set from the measured score and wired to auto-tighten; resets require a separate reviewed PRbreak floor from the first measured score, not an aspirationtest-unit; delete dead code → plan-dead-code → housekeep-dead-codeImplement the harness and triage. Strengthen tests only on approval — each fix is a reviewable change.