TestGuard
Technical Brief · v0.26.4 · Ricardo Accioly · MIT

Your tests pass. That is not the same as your tests working.

TestGuard takes the promises your code makes, breaks each one on purpose, and reports every promise your tests did not notice breaking.

The problem

Coverage tells you a line ran. It does not tell you that a test checked the result. A codebase can have full coverage and no defense, and CI gives no warning.

A real test, from this project's own fixture
expect(store.writeAudit).toHaveBeenCalledWith(
  expect.objectContaining({ action: 'MASK', scope: 'g1', ruleCount: 1 }),
);  // `content` is never named — so nothing checks it

objectContaining ignores keys it does not list. Replace the redacted text with the raw secret and this test still passes. Coverage of that line is 100%. The audit log now leaks the data it must protect.

Coverage asks “Did this line run?” 100% covered — and it is telling the truth TestGuard asks “If I break it, does anything notice?” 0 of the tests covering it would fail

Fig. 1 — One line of code, two questions. Only one question matters.

The method

killed

You broke it and a test failed. Good. The tests defend that behavior.

SURVIVED

You broke it and every test still passed. A blind spot.

The word confuses everyone once: the fault survived, not the test. SURVIVED is bad news. A healthy report shows mostly killed.

A tool that reports every fault as caught is worse than no tool, because nobody questions good news.

The design constraint everything else follows from
TestGuard
02 — What it found in the field

Two independent runs, two AI-authored codebases

Neither suite was sloppy. One had ~4,900 disciplined tests, no snapshots, and 0.4% zero-assertion. Both were green. Both had big blind spots.

Field report A — AI-authored production codebase, ~4,900 tests 8 of 9 real historical bugs the suite could not see 2,451 tests green, at once, on known-broken code 100% coverage on the compliance path that leaked Field report B — a different codebase, 458 tests, 24 security claims, 39 faults injected Before — every test green 21 faults SURVIVED a fully green suite 9 of them critical — super-admin gating, cookie flags, the whole authorization callback After — tests written against the survivors 39/39 killed The suite was not bad. It was unexamined. killed — defended SURVIVED — a blind spot

Fig. 2 — Measured, not modelled. Each dot is one injected fault.

The shape of the failure

It is not missing tests

One file copied the authorization logic into the test and checked its own copy. Fifteen tests were green, and all passed for the wrong reason. You could delete the production path and no test would notice.

It is assertions that name too little

The largest gap was in a compliance-critical path with 100% coverage. The one assertion that mattered used objectContaining and left out the field that holds the data. This is the example on page one.

A green suite is evidence that the tests agree with the code. It is not evidence that either one is right.

Why the question has to be asked adversarially
TestGuard
03 — Anatomy of a run

One fault, start to verdict

Isolate scratch worktree Baseline untouched code ×3 Inject apply the fault Probe same tests again ×3 Restore always Classify one of seven verdicts Must pass 3 of 3 — or the run stops here A suite that cannot stay green on untouched code cannot be asked anything about a fault. In → testguard.claims.json Out → evidence.json Your working tree is never modified — the fault is applied to a copy.

Fig. 3 — The probe loop. Every step repeats per fault; the baseline is cached per defender set.

How a verdict is decided

The order is the specification. Each check stops the checks below it. So the tool never gives a good answer from a question it should not have asked.

Does any test defend this claim? no NOCOVER nothing looks at this code Did the fault apply to exactly one place? no UNVERIFIABLE anchor moved, or matches twice Was the baseline green, 3 of 3? no FLAKY-DEFENDER too unstable to probe With the fault in, did the suite still load? no FAULT-INVALID the error is ours Did anything time out? yes TIMEOUT a hang is not a detection Did a test assert its way to failure, in all 3 runs? yes killed the only good outcome Everything passed, every run. SURVIVED a real blind spot Anything in between — some runs killed, some passed — is FLAKY-DEFENDER, never a kill.

Fig. 4 — Verdict order. Every ambiguity resolves downward, toward “unproven”.

What a run costs, and why it is predictable

Run time is predictable. For each claim:

(baseline runs + faults × N) × cost of the
                       claim's defender set

Measured, not estimated: testguard.cost-budget.json records the real CI cost of each set. --cost reports the cost per claim and per file.

The defender set is the unit, not the file. A run executes all tests of a claim at once. So one slow acceptance test named by five claims runs thirty times, and the report names that file.

Baselines are cached per defender set. A verdict is reused when the source, the defenders and the fault are unchanged.

TestGuard
04 — Verdicts & architecture

Seven verdicts, because “did the tests fail?” is a sloppy question

VerdictWhat it means
killedA test body ran and rejected the behavior. The only good outcome.
SURVIVEDEverything passed. A real blind spot in the tests.
NOCOVERNo test even looks at this code. Not “weak tests” — no tests.
UNVERIFIABLEThe fault did not apply: its anchor moved or matches twice. Nothing was learned.
FAULT-INVALIDThe injected fault did not compile. The error is ours, not yours.
TIMEOUTThe suite hung. A hang is not a detection.
FLAKY-DEFENDERThe tests are too unstable on untouched code to probe.

Where the pieces sit

Input — reviewed like code claims.json Claim: what must be true Faults: how it could be false Engine — testguard probe Scratch worktree isolation + restore Inject / run / N× budgeted processes Runner adapters — one report shape, five engines vitest jest playwright pytest unittest classify() pure; the check order is the specification Output — schema-validated evidence.json a verdict per fault, with its runs baseline.json today's blind spots, frozen gate → CI fails only on blind spots that are new since the baseline Why the baseline matters A legacy codebase does not start with four hundred failures. Freeze what is already blind, then gate only on what gets worse. Then a team can adopt the tool and keep it on.

Fig. 5 — Claims in, evidence out, and a gate that measures the delta rather than the debt.

Every ambiguity rounds toward “unproven”

  • Three runs, never one.
  • A green baseline before any fault is injected.
  • A timeout is never a kill.
  • A suite that fails to load is never a kill.
  • Mixed results across runs are not a kill.
  • A test that mocks what it defends is not a defender.
TestGuard
05 — The loop & calibration

The engine is one verb. The loop is the product.

Probing checks a claim. It does not say which claim to write next, whether a new test is worth keeping, or whether the agent that edits your code knows.

VerbWhy it exists
statusShows the project state and the one next action. --json is the machine entry point.
initInstalls the agent layer at the git root: skill, session-start hook, AGENTS.md section.
claimsLists the claims and reports drift against the @claim annotations in the code.
scaffoldProposes faults by rule for one file, as a draft claims document. A start, not an answer.
sweepThe cold start: probes files with no claim (a diff, the write surface, or a one-line concern).
probeThe engine. Injects each fault, runs its defenders, reports what survived.
admitThe two-gate rule as one verb: green on HEAD and failing on every fault of the claim. If not, the test is not a defender.
baselineFreezes today's unproven findings so only new ones gate.
gateFails when a changed source file carries no claim and no excusing entry. Unclaimed code is a blind spot before any test is.
briefOutputs the blind-spot block for an agent's session-start context.
mcpServes status, brief, claims and evidence read-only over MCP. The loop then works in any agent harness.
replayWould this suite have caught the bugs that already escaped? Reports, never gates.

The honest question: does an injected fault resemble a real bug?

Every mutation tool must answer this. Most do not. replay answers it with data: it takes real fix commits from your history, reverts each fix, runs the tests that exist now, and records whether they notice.

Calibration — a miss rate, so a high p is bad
guard-removed  missed 7/9  p=0.78  ci [0.45, 0.94]
field-dropped  missed 4/4  p=1.00  ci [0.51, 1.00]

Read as: when a real bug of this class escapes, how often does the suite miss it? Each bug gets the label of the fault class its diff most resembles. This label is the join key. It turns a score nobody can read into a statement with a sample size. You can recompute every p and interval from n, and the validator does.

  • Measurements enter the ratio: caught, blind, and nocover. The last counts as a miss, because no tests must not score better than weak tests.
  • Failed measurements enter neither side: flaky and unverifiable prove nothing, so they must not improve the number.
  • Flake counts against the suite: a flaky failure looks like detection, so mixed runs are never caught.
The open question this instrument exists to answer

Does a calibration from a repository with history work on a new repository that has none? AI-authored code has no history, so calibration is the only link. That transfer is unproven. It is the core product bet. This tool tests the bet. It is not the answer.

TestGuard
06 — Starting from zero

The bottleneck was never verification

A verifier with no claim about a feature says nothing about it. Every defect that escaped in the field reports was a claim gap, not a probe miss.

So the engine is not the scarce part. The oracle is: a sentence about what must be true, written by someone other than the code. gate lists the changed files that have no claim and stops. That is correct, because a human must state a claim. But a team that adopts it reads that list, has nothing to compare it with, and gives up.

Field report C — where a save button actually fails

Twenty-six faults on the persistence path of seven server actions in a real AI-authored application. They hit the write and its fields.

12 of 26 survived a fully green suite 46% of the persistence path 12 of 12 survivors were a dropped payload field — not one was anything else 32 of 37 files that write are defended only by tests that mock the database The worst case — user registration Each of email, username, password_hash, terms_accepted_at and terms_version can be removed from the row that is written, and no test fails. The tests assert that the write was called. They never assert what it was called with.

Fig. 7 — The save button reports success. The suite agrees. The column is empty.

The third number is the read-back answer. A test that replaces the database proves only the call shape. A where that matches no rows, a rolled-back transaction and a rejected constraint all pass against a mock. On this surface a clean probe is not evidence of persistence. It is evidence that no test could measure it, and the tool says so before any verdict. The evidence now names the mocked layer and the assertion shape (exact, partial or argument-free) beside the survivor’s verdict.

A ladder, so a repository with no claims is not stuck

Nothing written

sweep takes the files that gate reported as uncovered, proposes faults by rule, probes a limited selection, and reports what no test noticed. It orders candidates by what this project’s own runs show survives. This feedback took Google’s productive rate from 15% to 89%.

A sentence or ten

A concern names a kind of promise and where to look. Five lines of JSON, “every admin route refuses a caller without the admin role”, found a route whose owner/manager check can be forced to false with no test failing. One sentence covered twenty-four routes, with no model.

A claim

The survivors worth defending become the first claims: a statement, its faults, and a reproducer already in hand.

Four rules keep the lower rungs safe. A sweep never writes the claims file, because a sentence nobody wrote is not a claim. Its evidence never replaces the canonical record. It does not fail on its own bad guess: only a survivor or an untested file exits non-zero. It counts whatever it does not probe: past the cap, outside the concern, or presentational (an icon or a static wrapper nobody would test).

A sweep is weaker evidence than a probe, and says so. It is stronger than nothing, which is what a repository with no claims has.

Why the ladder has a bottom rung
TestGuard
07 — Prior art

What is not new, and who solved which part

Breaking code to test your tests is mutation testing, and it dates to the 1970s. Stryker, PIT, mutmut and Cosmic Ray all do it. Anyone who says that part is new is wrong. Two industrial programs solved the parts that make it usable. This tool takes both.

Google — making it affordable

Mutating two billion lines is infeasible. So Petrović et al. mutate only changed lines, suppress “arid” nodes nobody would test, show at most seven mutants per file, and order candidates by the measured productivity of the operator in similar context. Developer feedback over six years took their productive rate from 15% to 89%. A later study found that reported mutants link to real faults: the bugs it analyzed would have been caught if a mutant had been shown.

Taken here: the diff scope, the cap, and a productivity-ordered selection, measured on real probed faults, not assumed. We measured their arid-node suppression instead of copying it: Google's categories are under 1% of what the producers propose. The arid class here is presentational JSX, now set aside and counted.

Meta — making it specific

ACH inverts the generator: an engineer writes a concern in plain text, an LLM drafts faults for that concern. Each fault must build, survive the existing suite, and not be equivalent before a test is generated to kill it. Engineers accepted 73% of the resulting tests. Nothing is trusted because a model said it. Execution gates every step, and the reviewer sees the mutant as proof that the test catches something real.

Taken here: the concern as the unit a human writes, and an execution gate between every model step and the record.

Neither tool binds a fault to a stated promise. That gap remains, and the next section covers it.

What is different: the question being asked

Classic mutation testing

Mutates everything, mechanically

“How good are my tests?”

→ Mutation score: 73%

A number. You cannot act on it or audit it, and it does not say which promise is at risk.

TestGuard

Binds every fault to a stated claim

“Is this specific promise defended?”

→ “Your project says a missing scope fails closed. Nothing checks that.”

A finding. An assessor reads your claims, which you review like code, not a score.

Mutation score — thousands of syntactic mutants, one number 73% Which promise is at risk? Unanswerable. Claim-bound finding — each fault keeps its name REDACT-001/F1 · critical · src/redact.mjs SURVIVED “The audit row never contains the original input.”

Fig. 6 — A score compresses everything into one number; a claim keeps the finding attributable.

That is the difference between a metric and an audit, and it is the whole design.

TestGuard
08 — Difference

And one thing that was measured, not assumed

“No model decides a verdict” is a design rule elsewhere in this brief. It is also a result. A calibrated commercial decision model was shadow-evaluated against real probed verdicts on an AI-authored codebase. It had to say whether a given test would catch a given fault. It scored AUC 0.813. Its errors went in the forbidden direction: it confidently said that a test would catch a fault that in fact survived. On hand-built fixtures the same model looked far better. This is the second finding: a synthetic fixture flatters any judge, because its blind spots were written to be easy to see. Only execution may say killed.

What it deliberately is not

  • Not a test generator. It judges a test the agent wrote. The agent keeps the job of writing tests, as the market is doing.
  • Not a coverage tool. A line that ran does not show that an assertion would notice.
  • Not a mutation-score dashboard. No blanket mutants, no single number, no threshold to game.
  • Not a self-healing runner. A defender that adapts itself to a change did not observe the change.

One gap it names: a claim that disappeared is invisible to all of the above. probe verifies the claims that exist, and deleting a claim is cheaper than weakening it. So it reports removal too, against any reference, with the last verdict of the claim. Removal is allowed, because claims can be wrong, superseded or split. It is never silent.

Three more things that follow from it

Paranoid about itself

Most tools mark a mutant killed when the test command exits non-zero. That confuses “a test caught it” with “everything failed.” Here the verdict set is closed, and each verdict has its own meaning.

Evidence, not output

Schema-validated JSON with stable fingerprints, shared with the other Guard tools. Freeze today's blind spots, gate CI on new ones.

Built for AI-written code

When an agent writes the tests, the failure mode is not “no tests.” It is confident, plausible tests that assert nothing. This is exactly what it detects.

Coverage tells you a line ran. TestGuard tells you which of your promises nobody is actually defending.

github.com/raccioly/testguard · npm testguard-cli · MIT