Skip to content
Hiep Lam
Go back

Beyond Coverage, Part 6: The Agentic Merge-Gate Readiness Rubric

Edit page 🇻🇳 Tiếng Việt

“Beyond Coverage: Test Quality for the Agentic Loop” - Part 6 of 7 (closing part). Six parts of metrics, evidence, tooling, and AI-test grading converge here into one scorecard and a rollout plan - scored on the diff, module by module, never on the repo as a whole.

Score the diff, not the repo. A change is safe to merge without manual testing when, on the lines it touches: mutation score ≥ 80%, diff coverage ≥ 90%, zero test smells, ~0% flakiness, and critical paths carry strong (mutation + property) oracles. You reach the loop module-by-module, hardening the crown jewels first - never by chasing one repo-wide number.


The scorecard (apply per PR, to changed code)

DimensionMetric🔴 Not ready🟡 Workable🟢 Loop-ready
Oracle strength ★Mutation score on the diff< 50%60–75%≥ 80%
Change exercisedDiff / changed-line coverage< 60%70–80%≥ 90%
Assertions existAssertion density + smell scansmells present≥1 assert/test0 smells, behavioural
ReliabilityFlakiness (5× rerun)> 1%≤ 0.5%≈ 0%, flakes quarantined
Critical pathsMutation + property tests on money/auth/data-lossgapscovered≥ 90% mutation + invariants
SpeedSuite + diff-mutation runtimehours~10 mindiff-scoped, minutes

Agentic merge-gate readiness scorecard, scoring six dimensions from not-ready to loop-ready “Is my legacy suite good enough to merge AI changes without manual testing?” Score the diff, not the whole repo.

These are starting defaults (Stryker.NET’s high:80 / low:60 baseline; Meta/industry diff gates), to be tuned per module risk - not laws of nature. The payment path should be stricter; a logging helper can be looser.

The autonomy ladder - earn each rung with evidence

You don’t flip a switch to “autonomous.” You climb:

The jump that actually buys you the loop is L1 → L2: adding the mutation gate. Coverage gates (L1) stop obviously-untested merges; mutation gates (L2) stop vacuously-tested merges - including the AI’s vacuous tests (Part 5).

”Is my legacy suite good enough?” - the decision procedure

Run this, in order, scoped to the code a given change touches:

  1. Coverage zeros? Any changed/critical line at 0% → not ready. (Coverlet / go test -cover.) Cheap, do it first.
  2. Surviving mutants? Run diff-scoped mutation (stryker --since / gremlins --diff). Read the survivors. Each is a missing assertion or case. Zero non-equivalent survivors on the diff = the strong signal you want.
  3. Smell scan clean? No assertion-free, magic-number, conditional-logic, or act-assert-mismatch tests on the change.
  4. Critical path hardened? For money/auth/data-loss, is there a property/invariant test, not just examples?
  5. Flake-free & fast? 5× rerun stable; run completes in minutes.

If 1–5 pass on the diff, that change is loop-ready even if the rest of the legacy repo is a swamp. That’s the whole point: you don’t have to fix the legacy repo to start the loop - you have to fix the blast radius of each change.

Rollout strategy for a legacy codebase

  1. Pick the crown jewels. Identify the modules where a silent bug is catastrophic. For a billing/payments system, for example: money calculation, the scheduled batch-run orchestration, payment idempotency (a unique reference), due-date rules, money rounding (decimal(18,2)).
  2. Baseline them. Run mutation once on those modules. The survivor list is your test-hardening backlog - prioritized by risk, handed to you (or the agent) for free.
  3. Turn on the diff gate (--since / --diff) in CI for those modules at L2 thresholds.
  4. Add properties to the math. Invariants over generated inputs (“paid ≤ owed”, “rounding conserves cents”, “due date always lands on the configured business day”) catch the classes of bug examples miss.
  5. Quarantine flakes ruthlessly. A flaky gate is no gate. Time-dependent logic (DateTime.Now, a scheduled-date calc) is the usual culprit - inject the clock so tests are deterministic.
  6. Expand outward module by module. Track coverage of the diff and mutation score of the diff over time, not a repo-wide percentage.
  7. Wire in the AI gauntlet (Part 5): agent-generated tests must kill a new mutant to merge.

What “enough tests” finally means

Not a coverage number. Enough is when, for the code you’re changing:

there are no surviving non-equivalent mutants, the assertions are behavioural and smell-free, the critical invariants are properties, and the suite is fast and flake-free - so a passing build is genuine evidence the change is safe.

When that holds on a module, you can let the agent change that module and merge on green without manually testing - because the measurement, not the model’s confidence, is what’s vouching for the change. That is the full agentic loop, earned rather than assumed.

One-screen checklist (pin this)

PER-PR MERGE-GATE (scoped to the diff)
[ ] Diff coverage ≥ 90%            (Coverlet / go test -cover)
[ ] No coverage zeros on changed/critical lines
[ ] Diff mutation score ≥ 80%      (Stryker --since / gremlins --diff)
[ ] Zero surviving non-equivalent mutants on changed lines
[ ] Smell scan clean (no assertion-free / magic-number / cond-logic / act-assert mismatch)
[ ] Critical paths: property/invariant tests present (FsCheck/CsCheck · gopter/rapid)
[ ] Flakiness ≈ 0 (5× rerun stable); time/network injected, not ambient
[ ] Gate runs in minutes (diff-scoped, baseline/incremental)
[ ] AI-generated tests: each kills ≥1 new mutant; oracle traces to spec, not current code

The whole series in one line: coverage tells you what you’re blind to; mutation score tells you what your tests would actually catch; neither is a silver bullet alone - but scoped to the diff, combined, and used as a gate rather than a grade, they’re enough to let an agent merge on green.


Sources


← Previous: Part 5 - Grading AI-Generated Tests · This closes the series.

The series - Beyond Coverage: Test Quality for the Agentic Loop: 0 · Why Coverage Lies · 1 · The Metric Catalog · 2 · Mutation Testing, Properly Explained · 3 · What the Empirical Research Actually Says · 4 · Tooling for Go and .NET · 5 · Grading AI-Generated Tests · 6 · The Readiness Rubric (you are here)


Edit page
Share this post:

Previous Post
Beyond Coverage, Part 5: Grading AI-Generated Tests
Next Post
Shrinking the Agent Loop, Part 1: How RTK and Caveman Attack Opposite Ends of the Pipe

Keep reading

A few more pieces in the same vein.

Rather read on your own time? Subscribe via RSS