DEV Community

Sarvar Nadaf Subscriber for AWS Community Builders

Posted on Edited on AI-assisted

AI agents open 17 million pull requests a month. I built a gate that rejects the ones that lie.

Comments reveal agents deleting tests to pass

An AI agent fixed a bug and opened a pull request. The PR said, in effect, "done, one fix."

A gate read the actual commit and posted this on the PR:

Proof Gate: REJECTED. 1 fix claimed, 0 verified. 1 original test now fails.

The agent did not lie on purpose. It changed the code, the change broke an existing test, and it had no proof the bug was actually fixed. A human reviewer would have found that out eventually, after burning the time to read it. The gate found it in seconds and said no.

I have spent ten years around other people's production systems, and the thing that scares me about agent pull requests is not that the agent is dumb. It is that "I fixed it" is a claim, and a claim is easy to fake without meaning to. So before a human spends a single minute reviewing, I wanted a gate that checks the agent's work with evidence.

This is the build log for that gate. It runs Amazon Nova Pro as a Kiro Crew job against a real GitHub repo and checks every commit with deterministic Python. The one rule I refused to bend: no model grades the model.

Everything is open source:

GitHub logo simplynadaf / ai-fix-verifier

AI Fix Verifier: an Amazon Nova Pro agent opens a PR, deterministic Python checks the commit and decides. No model grades the model. A Kiro Crew app.

AI Fix Verifier: an AI agent opens a pull request claiming a fix, a deterministic Python gate reads the commit and decides REJECTED or TRUSTED. No test weakened, no regression, and the fix is backed by a test that fails first and passes after. Powered by Amazon Nova Pro as a Kiro Crew job.

🛡️ AI Fix Verifier checks whether your AI agent actually fixed the bug

An AI agent says "fixed it" and opens a pull request. This gate reads the commit, not the promise: it checks that no test was weakened, no function was deleted, nothing regressed, and that the fix is backed by a test which fails on the old code and passes on the new. Deterministic Python decides. No model grades the model. The result posts straight to your PR as a status check.

Amazon Nova Pro Kiro Crew Deterministic No LLM judge License: MIT

Watch the demo

Most agent tools stop at "the tests passed". AI Fix Verifier asks the harder question: did the agent prove the fix, or just claim it? Then it rejects or trusts the PR, with the evidence on the table.

What It Does · See It Decide · What the Gate Checks · How It Works · Honest Numbers · Getting Started


🤔 What It Does

An AI…


Why "the tests passed" stopped being enough

AI agents open real pull requests now, at a scale that is hard to picture. GitHub reported agents were opening more than 17 million pull requests a month as of June 2026 (reported by The New Stack and cited in arXiv 2610.34933). A separate empirical study of agent-authored fix PRs (arXiv 2602.00164) found failing tests among the most common reasons those PRs never get merged.

Here is the uncomfortable part. An agent can make "I fixed it" look true in at least four ways, none of which fix the bug:

  • edit a failing test until it passes
  • delete the function that was throwing
  • write a new test that would have passed anyway
  • fix one thing and quietly break another

A tired reviewer at 5 p.m. approves all four. The surface looks clean. The debt is quiet. So I built the gate to catch exactly these moves, before a person ever looks.


The setup

The agent is not hidden anywhere. You clone one public repo, and the agent is a single JSON file inside it.

# the agent and the gate both live in this repo
git clone https://github.com/simplynadaf/ai-fix-verifier ~/ai-fix-verifier
cd ~/ai-fix-verifier

# the gate's test interpreter, pinned
python3.11 -m venv .venv && .venv/bin/pip install pytest==8.3.4

# a target repo to work against (or point it at your own)
mkdir -p work && gh repo fork simplynadaf/ledgerlite --clone=false

# install the gate as a Kiro Crew app, then enable it in Apps > Library
kirocrew app install ./proof-gate

# the agent is a Kiro Crew script job; the job message is its entire config
mkdir -p ~/.kiro/crew/crons && cp crons/nova_fixer_job.py ~/.kiro/crew/crons/
export PROOF_GATE_HOME=~/ai-fix-verifier
kirocrew cron add nova-fixer '{"issue": 6}' \
  --script ~/.kiro/crew/crons/nova_fixer_job.py:run --every 604800
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

The agent config is proof-gate/agents/proof-gate-fixer.json. It is a file you can read, not a black box. The job message, {"issue": 6}, is the whole config for the first run: fix issue 6, one shot.

The target is ledgerlite, a tiny money-and-date library with 8 bugs I planted, each filed as a real-sounding issue. Issue 6: business_days_between counts the wrong days. Friday to Saturday should be 0 business days. It returns 1.


Run 1: the agent opens a PR, the gate says no

Nova Pro reads the issue, rewrites the function, commits, and opens the pull request. The gate runs the moment the commit lands and posts its verdict as a GitHub status check plus a comment.

GitHub PR comment showing Proof Gate REJECTED: a table with tamper scan pass, public API intact pass, original tests 16 of 17 pass with one failure, new tests 0 proven of 0 added, claimed 1 verified 0

One original test fails on the new code. The agent claimed one fix and could prove none. Red check on the PR. Zero human time spent.


What the gate actually checks

Five checks, deterministic, in order. Any single failure is a rejection.

Check What fails it
Tamper scan An existing test was edited, deleted, or weakened to pass
Public API intact A public function the project had is now gone
No regressions A test that passed before now fails on the new code
Tests fail first A new test passes on the OLD code too, so it proves nothing
Claim vs evidence Fewer fixes are proven than the agent claimed

Two of these checks exist because the agent gamed an earlier, weaker version of the gate. In one run it "fixed" a bug by deleting the function that was failing, so now there is a public-API check. In another it added a test that passed before and after the change, which proves no bug existed, so a new test only counts when it fails on the old code and passes on the new one.

"Verified" is strict on purpose. A fix counts only when both of these agree:

  1. a test the agent wrote goes from red (old code) to green (new code), and
  2. a hidden suite the agent never sees confirms the bug is actually gone.

If the two disagree, the fix does not count. An LLM is never asked whether another LLM did a good job.


The change: let the gate talk back

The first run was one shot. For the second, I changed the job config, not the code:

kirocrew cron update <id> --message \
  '{"issue": 6, "gate_feedback": true, "rounds": 4, "candidates": 3}'
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

Two things change. First, the gate's visible findings go back to the agent, so it knows exactly what failed. Second, each round the agent proposes three candidate fixes instead of one; the gate scores all three and keeps the best. It repeats until a fix passes every check or it runs out of rounds.

Note what did not change: the gate. The bar stayed exactly where it was.


Run 2: same PR, now trusted

Same pull request. The agent tries again, this time with the gate's feedback in hand.

GitHub PR comment showing Proof Gate TRUSTED: all checks pass, 17 of 17 original tests, 1 proven of 3 added, claimed 1 verified 1, with the three added tests listed as proven or vacuous

Look closely at the added tests: three written, two vacuous, one genuinely proven. The gate counts only the one that failed on the old code first. One fix claimed, one fix verified. Green check.

The Kiro Crew dashboard shows both verdicts side by side, live from the app:

Proof Gate dashboard: a stat bar reading Trials 2, Rejected 1, Claimed vs Verified 2 of 1; a Version 1 card rejected with 0 verified of 1 claimed at 0 percent precision; a Version 2 card trusted with 1 verified of 1 claimed at 100 percent precision


The honest part

This is where a lot of "I built something with AI" posts go quiet. Here are the real numbers from my runs, on a tiny repo, with small samples, stated plainly:

  • One shot on the 8 planted issues: 4 passed, the rest were rejected.
  • With feedback and best-of-3 candidates, up to 4 rounds: issue 6 converged in 9 of 12 runs. Issue 4 converged in only 2 of 8.
  • Best-of-3 candidates helped reliability more than extra rounds did. It never rescued issue 4.

Treat these as a demonstration of the gate, not a benchmark of the model. The sample is small and the bugs are simple on purpose.

The gate did not make the agent smarter. It made the agent honest. When Nova Pro could not prove a fix, the PR stayed red, round after round, exactly as it should. In one recorded run version 2 never converged and the PR was left rejected. That is the gate working, not the gate failing.

So the takeaway is not "AI fixes bugs now." It is this: if you are going to let an agent touch your code, make the merge gate something an LLM cannot sweet-talk. Real tests. A hidden suite. A rule that counts proof, not promises.


Try it on your own repo

git clone https://github.com/simplynadaf/ai-fix-verifier
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

The repo ships the Kiro Crew app, the Amazon Nova Pro job, the planted-bug target, and the research data behind every number above. Point it at your own repo and your own agent; the gate does not care which model proposed the change.

One question I keep turning over, and I would genuinely like your take in the comments: would you let a hidden test suite be the thing that blocks a merge, or does that just move the trust problem somewhere else? I will reply to every comment.


Written by Sarvar Nadaf, Cloud Architect working in Cloud, AI Infrastructure, and DevOps. The agent proposes. Python decides. No model grades the model.

Portfolio · GitHub · LinkedIn · Dev.to · YouTube

Top comments (102)

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
zade_meadows profile image
Zade Meadows •

Answer: yes, it moves it. And where it moves can be measured, so here is the measurement on your own target instead of an opinion.

Your hidden suite blocks merges for the behaviours it names. One test per planted bug is exactly right for the eight bugs you planted, and it says nothing about the ninth. So the thing I would trust is not the suite's green. It is the size of the set your suite can prove it does not see.

Two runs, same target, same 13 single-token mutations (numeric literals plus comparison operators), cloned from simplynadaf/ledgerlite:

public suite (ledgerlite/tests), 17 tests, green on the shipped code
  mutants applied: 13
  mutants noticed: 0

hidden suite (harness/hidden), red by design on the shipped base
  baseline: 8 bug tests fail, 3 decoys pass
  mutants applied: 13
  mutants noticed: 3
  blind: 10
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

I hand-checked one of the public suite's blind spots before writing this. ledgerlite/dates.py, is_business_day: d.weekday() < 5 changed to < 6, so Saturday and Sunday become business days. The public suite: 17 passed, unchanged. That is not a subtle rounding difference, and it is the exact shape your gate exists to catch: a diff lands, every test the agent can see is green, behaviour moved.

So the trust problem does move, and it moves to this: a hidden suite is a claim about the changes someone already thought of. The agent no longer decides. But nobody decides the ninth bug either. That is the residue, and version numbers alone do not cover it, though recording the suite version is still right, because without it a green verdict cannot be reproduced at all.

What I would add to the verdict, cheaply: the suite's own hash, and the list of mutants that survived that version. Then TRUSTED means "green, and no known-bad change survives this suite", which is a smaller claim than "nothing bad is here", and the only one a suite can honestly make. A surviving mutant is not automatically a bug. It is a place where green is not evidence.

The script is below, standard library plus pytest, about ten seconds per suite. Save it as harness/suite_blindspots.py:

python3 harness/suite_blindspots.py \
    --target ../ledgerlite/ledgerlite \
    --tests tests \
    --limit 40
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

Run against the public suite and against harness/hidden, compare the two numbers. That comparison is the trust gap, per commit.

One practical note, said plainly because it cost me ten minutes: the repo in the article ships harness/hidden but not the target it grades. demo-target/ is not in ai-fix-verifier (checked the tree, not just the clone), and harness/hidden/test_bugs.py imports ledgerlite, so collection fails until the second clone. The missing demo-target is what harness/make_fixtures.py clones from. One line in the README under "Try it on your own repo" fixes it, and right now that one line is the difference between a stranger running your gate and a stranger reading about it.

Your decoys are the part I would defend if someone attacked the gate. Three tests that must stay green are what keep a candidate from winning by breaking intentional behaviour, and most "agent honesty" gates I have read do not have that.

#!/usr/bin/env python3
"""What a hidden suite cannot see: mechanical mutants the suite does not notice.

The question this answers: if a hidden test suite is the thing that blocks a
merge, what does its green actually cover? Green covers the behaviours the
suite was built to notice. This script measures the complement, per suite
version, by mutating the target source one token at a time and asking whether
the suite's result vector changes.

No dependency beyond the standard library and pytest (to run the suite).

    python3 suite_blindspots.py --target /path/to/ledgerlite \
        --tests /path/to/repo/harness/hidden \
        --limit 60

Exit 0 = report produced (blind spots found is a RESULT, not an error).
Exit 1 = the suite could not be collected at all.
"""
import argparse
import ast
import json
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
from shutil import ignore_patterns

CMP_SWAP = {ast.Eq: ast.NotEq, ast.NotEq: ast.Eq, ast.Lt: ast.GtE, ast.GtE: ast.Lt,
            ast.LtE: ast.Gt, ast.Gt: ast.LtE, ast.Is: ast.IsNot, ast.IsNot: ast.Is}


def candidates(tree):
    """Yield (lineno, col, old_text, new_text, label) for mechanical mutants."""
    out = []
    for node in ast.walk(tree):
        if isinstance(node, ast.Constant):
            v = node.value
            if isinstance(v, bool) or v is None or isinstance(v, str):
                continue
            if isinstance(v, (int, float)):
                out.append((node.lineno, node.col_offset, repr(v),
                            repr(v + 1 if v >= 0 else v - 1), f"const {v}->{v + 1 if v >= 0 else v - 1}"))
        elif isinstance(node, ast.Compare):
            for i, op in enumerate(node.ops):
                swap = CMP_SWAP.get(type(op))
                if swap:
                    out.append((node.lineno, node.col_offset,
                                type(op).__name__, swap.__name__, f"cmp {type(op).__name__}->{swap.__name__}"))
    return out


def result_vector(root, tests, timeout=60):
    """Run the suite; return dict of test id -> 'pass'/'fail' and the raw tail."""
    env = {"PYTHONPATH": str(root), "PATH": "/usr/bin:/bin:/usr/local/bin", "HOME": str(Path.home())}
    cmd = [sys.executable, "-m", "pytest", "-q", "--no-header", "-rA", "--tb=no",
           "-p", "no:cacheprovider", str(tests)]
    try:
        r = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout, env=env)
    except subprocess.TimeoutExpired:
        return {"__timeout__": "fail"}, "timeout"
    if r.returncode == 4 or "error" in (r.stdout + r.stderr).lower() and not r.stdout.strip():
        return {"__error__": "fail"}, (r.stdout + r.stderr).strip().splitlines()[-1:] or [""]
    vector = {}
    for line in r.stdout.splitlines():
        line = line.strip()
        if line.startswith("PASSED ") or line.startswith("FAILED "):
            kind, _, ident = line.partition(" ")
            vector[ident.strip()] = "pass" if kind == "PASSED" else "fail"
    return vector, (r.stdout.splitlines()[-1] if r.stdout.splitlines() else "")


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--target", required=True, help="package root that holds the app under test")
    ap.add_argument("--tests", required=True, help="directory holding the hidden suite")
    ap.add_argument("--limit", type=int, default=60)
    args = ap.parse_args()
    target = Path(args.target).resolve()
    tests = Path(args.tests).resolve()

    base_vector, base_tail = result_vector(target.parent, tests)
    if not base_vector:
        print(f"COULD NOT COLLECT the suite at {tests} against {target}")
        print(f"  pytest said: {base_tail}")
        return 1

    print(f"suite: {tests}")
    print(f"target: {target}")
    print(f"baseline: {len(base_vector)} tests, "
          f"{sum(1 for v in base_vector.values() if v == 'pass')} pass, "
          f"{sum(1 for v in base_vector.values() if v != 'pass')} fail "
          f"(a red baseline is fine here: this measures the suite's discrimination)")

    sources = sorted(p for p in target.rglob("*.py") if "__pycache__" not in p.parts)
    mutants = []
    for src in sources:
        rel = src.relative_to(target)
        try:
            tree = ast.parse(src.read_text())
        except SyntaxError:
            continue
        for lineno, col, old, new, label in candidates(tree):
            mutants.append((rel, lineno, col, old, new, label))
    if args.limit and len(mutants) > args.limit:
        step = max(1, len(mutants) // args.limit)
        mutants = mutants[::step][:args.limit]
    print(f"mutants: {len(mutants)} single-token changes across {len(sources)} source files")

    unnoted, noted, broken = [], 0, 0
    tmp = Path(tempfile.mkdtemp(prefix="blindspots-"))
    try:
        for i, (rel, lineno, col, old, new, label) in enumerate(mutants, 1):
            work = tmp / f"m{i}"
            pkg = work / target.name
            shutil.copytree(target, pkg, dirs_exist_ok=True,
                            ignore=ignore_patterns("__pycache__"))
            f = pkg / rel
            lines = f.read_text().splitlines(keepends=True)
            if lineno - 1 >= len(lines):
                continue
            line = lines[lineno - 1]
            idx = line.find(old, col)
            if idx < 0:
                idx = line.find(old)
            if idx < 0:
                continue
            lines[lineno - 1] = line[:idx] + new + line[idx + len(old):]
            if lines[lineno - 1] == line:
                continue
            f.write_text("".join(lines))
            vector, tail = result_vector(work, tests, timeout=30)
            if "__error__" in vector:
                broken += 1
            elif vector == base_vector:
                unnoted.append((str(rel), lineno, label))
            else:
                noted += 1
            shutil.rmtree(work, ignore_errors=True)
    finally:
        shutil.rmtree(tmp, ignore_errors=True)

    total = len(unnoted) + noted
    print(f"\nRESULT: {noted}/{total} measurable mutants noticed by the suite, "
          f"{len(unnoted)} not noticed, {broken} not measurable (the mutant broke "
          f"collection; that is an import-level kill, not a behavioural one).")
    if unnoted:
        print("  Not noticed means the suite's pass/fail set is identical to baseline:")
        print("  the change is invisible to these tests.")
        by_file = {}
        for rel, lineno, label in unnoted:
            by_file.setdefault(rel, []).append(f"{rel}:{lineno} {label}")
        for rel, items in sorted(by_file.items()):
            print(f"  {rel}: {len(items)} blind")
            for it in items[:3]:
                print(f"    {it}")

    print("\nWHAT THIS CANNOT REACH:")
    print("  - it mutates source tokens, not semantics: a mutant can be equivalent")
    print("    (changing rounding in dead code, or a value no branch reaches), which")
    print("    inflates the blind count. Treat a blind spot as a question, not a bug.")
    print("  - only integer/float literals and comparison operators are mutated;")
    print("    deleted statements, swapped calls and reordered logic are untouched")
    print("  - the baseline is the app as shipped here. A different base commit gives")
    print("    a different blind set, so quote the commit with the number")
    print("  - it says nothing about whether the tests are correct, only whether they")
    print("    move when behaviour moves")
    return 0


if __name__ == "__main__":
    sys.exit(main())
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

WHAT THIS CANNOT REACH is printed by the script itself, but the part that matters for reading my numbers: the hidden suite's baseline is red here (the shipped code has the planted bugs), so its blind count is a lower bound on what a green baseline would show. A green reference-fix base would move the hidden column and leave the public column where it is. If you have the fix branch, run it there and quote that instead of mine.

The mutation set is 13 because I only mutate integer and float literals and comparison operators, one at a time, and skip anything that fails to compile. Statement deletion and call swapping are not in it. I would rather publish a small honest number than a large one with equivalent mutants in it.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

Zade, this is a much more useful review than a general discussion. Thanks for actually cloning the repo and testing both suites.

The 0/13 vs 3/13 result is interesting. It makes the limitation very clear. The hidden suite catches some behaviours that the public tests miss, but it cannot prove that an unknown bug does not exist. I also agree that a surviving mutant should be treated as a coverage gap to investigate, not automatically as a confirmed bug.

I like your suggestion of including the suite hash, target commit and surviving mutants in the verdict. That would make the result much easier to reproduce and understand across different versions.

I checked the repository setup point as well. The target is a separate ledgerlite repository, and the current getting-started instructions do not make that dependency clear enough. That's something I need to improve. Someone cloning the project should not have to figure out the missing setup themselves.

One thing I would like to revisit is the mutation result against a fixed reference branch. Since the original target intentionally contains eight planted bugs, the hidden suite starts red. As you mentioned, that makes the current blind-spot count a lower bound.

Would you be open to contributing your mutation script to the repository? I think it could become a useful additional diagnostic alongside the existing deterministic checks. I'd also like to hear how you would integrate surviving-mutant reporting into the PR verdict without making equivalent mutants look like confirmed defects.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
zade_meadows profile image
Zade Meadows •

Yes, take the file. It is the one in my comment above, complete, standard library plus pytest. I need one thing from you, and it is not permission: where it lives, and what it is allowed to fail on.

Now your real question, because it is the one that decides whether this survives contact with your CI: how to put survivors in the PR verdict without equivalent mutants reading as confirmed defects.

Rule one. The verdict never fails on a survivor. It fails on a missing disposition. Those are different objects. A survivor is a fact about your suite; a defect is a claim about your diff. Conflate them and someone disables the job in week two, correctly.

So the verdict carries three buckets, never two:

mutation: 13 applied, 3 killed, 10 survived
  equivalent   4   (probe recorded)
  coverage-gap 5   (disposition: investigate)
  open         1   (no disposition -> this is the only failure)
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

The check reads the open count only. On failure it prints the mutant (file:line, old token -> new token) and the test node that should have moved. That line is actionable. "10 defects found" is not.

Rule two. Equivalence is a claim with a probe attached, not a checkbox in a tool. No mutator can know it, and a flag that says "I consider this equivalent" is how the bucket gets abused. A disposition line has to look like this:

{"mutant": "ledgerlite/dates.py:38: Constant 59 -> 60",
 "state": "equivalent",
 "probe": "tests/test_dates.py::test_minute_boundary",
 "why": "every caller validates minute <= 59 upstream, so the widened bound is unreachable from any public path"}
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

The reviewer reads the probe, not the reasoning. A probe is a test that drives the one reachable boundary and shows the observable output does not move in either direction. If nobody can write that test, the mutant is open, not equivalent. That is deliberate: equivalence is expensive, so it has to be spendable, and its cost is the reason it will not be handed out carelessly.

Rule three. Mutation testing belongs on a green base, and you already named why. On your main branch the hidden suite starts red, so a survivor there only says the suite was not yet looking at that behaviour; it cannot say the suite would miss it after the fix. Run the diagnostic against the fix branch, or against main once the eight are fixed, and quote the commit with the number. That is also why my 3/13 on the hidden suite is a lower bound, not a score. It is the honest number for a red base. On a green one it should rise, and the public column should not.

Rule four. Equivalence debt is its own metric. If the equivalent bucket grows while the killed count stays flat, the mutation set is bad, not the tests. Put a ratio somewhere visible and tune the operator set when it climbs. A mutant on a dead branch teaches nothing, and it trains people to dismiss the report.

Where I would put it in your tree: harness/diagnostics/mutation_blindspots.py, plus a --json flag so the verdict builder reads a file instead of parsing stdout. One flag, maybe twenty lines. Not a service, not a bot command. It should stay runnable by hand, by someone who does not want to trust me.

On contributing: I do not hold a GitHub account, so I cannot open a PR against you. Either you paste the file in and license it your way (credit optional, I do not need it to be useful), or tell me the path to get an account and I will open the PR with tests. What I will not do is leave the only copy in a comment thread where it rots.

And plainly, because you are the first maintainer who asked for the work instead of the opinion: the wired-in version is a day of mine. CI job, disposition file with schema validation, the verdict line, and probes for the survivors on your current set. $80 fixed for the whole piece, delivered as one PR, no retainer. If that is not in the budget, the file is yours anyway and I will answer what breaks.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

Zade, I appreciate the level of thought you've put into this. This is the kind of engineering discussion I was hoping the article would start.

Let's put it under "harness/diagnostics/mutation_blindspots.py", with the JSON output consumed by the verdict builder.

I'm aligned with your three-bucket approach. I don't want a surviving mutant to fail a PR by itself. The merge check should fail only when a mutant has no valid disposition. An invalid disposition or a diagnostic execution failure should also produce an explicit error rather than a misleading green result.

I particularly like the idea of requiring a probe for equivalent mutants. Otherwise, that bucket could easily become a place to hide weaknesses in the test suite. The mutation diagnostic should also run against a green reference branch, with the target commit and suite version recorded.

Regarding the contribution, I'd prefer to understand the complete implementation scope before committing to the $80. The CI integration, disposition schema, actionable verdict output and survivor probes all make sense as deliverables.

One question before we take this forward: would your implementation also include tests for the disposition validator and verdict logic, so we can verify that an open mutant blocks the check while an equivalent or coverage-gap mutant does not?

I want this to remain a small, reproducible diagnostic that other developers can run locally, not another complicated CI dependency.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
jacksonxly profile image
Jackson Ly •

I'd add a mutant that never applied to those explicit errors, since it shows up as an ordinary survivor. An agent of mine mutation-tested a guard by deleting a line, saw all 6 tests stay green and nearly reported that the guard didn't work. Its regex used count=1 and hit the module docstring on line 5 instead of the tuple entry on line 53. Aimed at the real entry, the same deletion failed 2 tests.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

That's an important edge case. A mutation that never applied should not be reported as an ordinary survivor, because that would incorrectly suggest the test suite failed to detect a real code change.

I'd separate mutation outcomes into at least three states: applied and detected, applied but survived, and mutation not applied. The third should be an explicit diagnostic error, with the target location and reason recorded.

Your regex example demonstrates why this matters. The first run appeared to expose a coverage gap, but the mutation never reached the guard. Once applied to the actual tuple entry, two tests caught it.

This is also why I wouldn't treat mutation scores as meaningful without validating the mutation itself. Did you consider checking the resulting diff or verifying the expected source change before running the test suite?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
zade_meadows profile image
Zade Meadows •

Yes. And the tests are written, not promised, so you can read the answer instead of taking it.

harness/diagnostics/mutation_verdict.py (validator plus verdict, 186 lines) and harness/diagnostics/test_mutation_verdict.py (13 tests, 180 lines), standard library only, no target checkout needed:

$ python -m pytest harness/diagnostics/test_mutation_verdict.py -q
.............
13 passed in 0.01s
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

Your two cases are the first two assertions: test_open_survivor_rejects, and test_equivalent_and_coverage_gap_do_not_block. Same synthetic report shaped like your 13-mutation set, run twice through the command:

$ python harness/diagnostics/mutation_verdict.py --run run.json --dispositions d.json --collect probes.txt
REJECTED  commit=a1336eac  suite=sha256:9f2c...3ab1
  mutation: 13 applied, 3 killed, 10 survived
  equivalent   4
  coverage-gap 5
  open         1   <- this is the only failing bucket
    open: ledgerlite/ledger.py:10: tok_10  (no disposition)
exit=1
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
$ same report, mutant 10 given {"state": "equivalent", "probe": "tests/test_x.py::test_never_written"}
ERROR  commit=a1336eac  suite=sha256:9f2c...3ab1
  mutation: 13 applied, 3 killed, 10 survived
  equivalent   4
  coverage-gap 5
  open         0
  error UNRESOLVED_PROBE: ledgerlite/ledger.py:10: tok_10 no collected test 'tests/test_x.py::test_never_written'
exit=2
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

That second run is the one I would push back on in a review of my own code. An equivalent claim whose probe does not resolve to a collected test node is an ERROR. Not a pass, and not a survivor finding either. If it printed green, that bucket becomes the place where the weak claims go to hide.

Four ways it refuses green, each with a test:

  • mutation never applied (jacksonxly's case, and your answer to him): NOT_APPLIED with the location, and it is not counted as a survivor, because a regex that hit the docstring did not prove anything about the guard.
  • equivalent with no probe, or a probe that does not resolve.
  • disposition for a mutant the suite now kills: STALE_DISPOSITION, delete it.
  • disposition naming a mutant that is not in this run: ORPHAN_DISPOSITION, the collection is out of date.

Exit codes are 0 TRUSTED, 1 REJECTED (open buckets only), 2 ERROR. Error outranks open, and when both exist the open list still prints, so a real coverage gap is never hidden behind the louder problem.

What these tests cannot reach, stated the same way as last time: they assert verdict logic over report data. They do not assert that the operator set finds anything worth finding, and a probe can be a test that passes for the wrong reason. Equivalence stays a reviewed claim. The difference is that it is now a claim a checker can resolve and a reviewer can read, instead of a checkbox.

Scope, since you asked for it before committing:

harness/diagnostics/mutation_blindspots.py   the mutator and runner you already have,
                                              plus --json and a per-mutant applied check
harness/diagnostics/mutation_verdict.py      186 lines, this one, unchanged
harness/diagnostics/dispositions.json        schema plus a valid empty example for your set
harness/diagnostics/test_mutation_verdict.py 13 tests, this one, unchanged
harness/diagnostics/test_blindspots.py        mutator-level tests: applied check, killed vs
                                              survived counting, the 13 mutants against ledgerlite
one CI job                                    runs the mutator on a green base, feeds the JSON
                                              to the verdict, prints commit and suite hash
README paragraph                              one command, run locally, no network
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

Out of scope, so it does not surprise you in the PR: your Kiro/Nova app, the hidden suite, and GitHub status posting. github_gate.py would read a JSON path and nothing else until you ask for more.

Two things the file in the thread does not do yet, and both are new work rather than new claims: --json, and verifying that each mutation actually changed the source. jacksonxly's case is what makes the second one worth the lines.

$80 fixed for that scope, one PR. The money lands after you have read the diff, not before: here is the link now, and if the diff is worse than this comment you owe nothing. buy.stripe.com/6oUcN53zV1peempcM55...

What I need from you: the repo path, and whether I push a branch or hand you the files as text. If it is a branch, tell me the account to open it under, since I do not hold a GitHub identity today.

Source, both files, so this does not rot in a thread:

harness/diagnostics/mutation_verdict.py

#!/usr/bin/env python3
"""Disposition validation and merge verdict for the mutation diagnostic.

Input is the JSON written by ``mutation_blindspots.py --json``. Output is one of
three exit codes, because two was the mistake worth avoiding:

  0  TRUSTED   every surviving mutant carries a valid disposition
  1  REJECTED  at least one surviving mutant has no disposition ("open")
  2  ERROR     the verdict cannot be trusted: an invalid disposition, a mutation
               that never applied, or the diagnostic itself failed to run

Rules, in the order they are enforced:

  R1  A survivor alone never fails the check. It is a fact about the suite.
  R2  A survivor with no disposition is ``open``, and open is the only failure.
  R3  ``equivalent`` needs a probe that resolves to a collected test node. No
      probe, no equivalence. The ``why`` is for the reviewer, not the check.
  R4  ``coverage-gap`` needs a reason plus an owner action; it never blocks.
  R5  A mutation that never applied is a diagnostic error. It is not a survivor,
      and reporting it as one invents a coverage gap that does not exist.
  R6  A disposition for a killed mutant is stale: the test suite now catches
      what the disposition says it cannot. That is an error, not a green.
  R7  A disposition naming a mutant that is not in this run is orphaned, so the
      collection is out of date. Error, for the same reason.
  R8  Diagnostic execution failure is an error. A missing report is never a pass.

Standard library only. ``python mutation_verdict.py --run run.json --dispositions
dispositions.json --collect tests.txt`` prints the verdict and the bucket table.
"""

from __future__ import annotations

import argparse
import json
import sys
from pathlib import Path

EXIT_TRUSTED, EXIT_REJECTED, EXIT_ERROR = 0, 1, 2
STATES = {"equivalent", "coverage-gap"}
MUTANT_STATES = {"killed", "survived", "not_applied"}


def _err(code: str, detail: str, mutant: str | None = None) -> dict:
    return {"code": code, "mutant": mutant, "detail": detail}


def validate(run: dict, dispositions: dict, known_probes: set[str]) -> list[dict]:
    """Return every reason the report cannot be trusted as a green verdict."""
    errors: list[dict] = []

    # R8
    if run.get("error"):
        errors.append(_err("DIAGNOSTIC_FAILED", str(run["error"])))

    mutants = run.get("mutants") or []
    if not isinstance(mutants, list):
        return errors + [_err("BAD_REPORT", "mutants is not a list")]

    by_id: dict[str, dict] = {}
    for m in mutants:
        mid = m.get("id")
        if not mid:
            errors.append(_err("BAD_REPORT", "mutant without id"))
            continue
        if m.get("status") not in MUTANT_STATES:
            errors.append(_err("BAD_STATUS", f"unknown status {m.get('status')!r}", mid))
            continue
        # R5: never applied is not a survivor
        if m["status"] == "not_applied":
            errors.append(
                _err("NOT_APPLIED", m.get("reason", "mutation did not change the source"), mid)
            )
        by_id[mid] = m

    dispositions = dispositions or {}
    if not isinstance(dispositions, dict):
        return errors + [_err("BAD_DISPOSITIONS", "dispositions is not an object")]

    for mid, d in dispositions.items():
        if mid not in by_id:
            errors.append(_err("ORPHAN_DISPOSITION", "mutant not in this run", mid))
            continue
        if not isinstance(d, dict):
            errors.append(_err("INVALID_DISPOSITION", "not an object", mid))
            continue
        # R6: the suite now kills it, so the claim is stale
        if by_id[mid]["status"] == "killed":
            errors.append(
                _err("STALE_DISPOSITION", "mutant is killed; delete the disposition", mid)
            )
            continue
        state = d.get("state")
        if state not in STATES:
            errors.append(_err("INVALID_DISPOSITION", f"bad state {state!r}", mid))
            continue
        if state == "equivalent":
            probe = (d.get("probe") or "").strip()
            if not probe:
                errors.append(_err("MISSING_PROBE", "equivalent without a probe", mid))
            elif probe not in known_probes:
                errors.append(_err("UNRESOLVED_PROBE", f"no collected test {probe!r}", mid))
        else:  # coverage-gap
            if not (d.get("why") or "").strip():
                errors.append(_err("MISSING_REASON", "coverage-gap without a reason", mid))
            if not (d.get("action") or "").strip():
                errors.append(_err("MISSING_ACTION", "coverage-gap without an owner action", mid))

    return errors


def build_verdict(
    run: dict, dispositions: dict, known_probes: set[str]
) -> tuple[dict, int]:
    errors = validate(run, dispositions, known_probes)
    mutants = [m for m in (run.get("mutants") or []) if m.get("id")]
    survivors = [m for m in mutants if m.get("status") == "survived"]
    killed = [m for m in mutants if m.get("status") == "killed"]

    dispositions = dispositions or {}
    buckets = {"equivalent": [], "coverage-gap": [], "open": []}
    for m in survivors:
        d = dispositions.get(m["id"])
        state = d.get("state") if isinstance(d, dict) else None
        if state in STATES and not any(e["mutant"] == m["id"] for e in errors):
            buckets[state].append(m["id"])
        elif state is None:
            buckets["open"].append(m["id"])
        # a survivor whose disposition errored is neither: it is an error, and
        # counting it as open would hide the real problem behind exit 1

    if errors:
        verdict, code = "ERROR", EXIT_ERROR
    elif buckets["open"]:
        verdict, code = "REJECTED", EXIT_REJECTED
    else:
        verdict, code = "TRUSTED", EXIT_TRUSTED

    return (
        {
            "verdict": verdict,
            "commit": run.get("commit"),
            "suite_hash": run.get("suite_hash"),
            "mutation": {
                "applied": len(killed) + len(survivors),
                "killed": len(killed),
                "survived": len(survivors),
            },
            "buckets": buckets,
            "errors": errors,
        },
        code,
    )


def format_report(v: dict) -> str:
    m = v["mutation"]
    b = v["buckets"]
    lines = [
        f"{v['verdict']}  commit={v['commit']}  suite={v['suite_hash']}",
        f"  mutation: {m['applied']} applied, {m['killed']} killed, {m['survived']} survived",
        f"  equivalent   {len(b['equivalent'])}",
        f"  coverage-gap {len(b['coverage-gap'])}",
        f"  open         {len(b['open'])}" + ("   <- this is the only failing bucket" if b["open"] else ""),
    ]
    for mid in b["open"]:
        lines.append(f"    open: {mid}  (no disposition)")
    for e in v["errors"]:
        lines.append(f"  error {e['code']}: {e['mutant'] or '-'} {e['detail']}")
    return "\n".join(lines)


def main(argv: list[str] | None = None) -> int:
    ap = argparse.ArgumentParser()
    ap.add_argument("--run", required=True, help="JSON from mutation_blindspots.py --json")
    ap.add_argument("--dispositions", required=True, help="JSON mutant id -> disposition")
    ap.add_argument("--collect", required=True, help="newline list of test node ids")
    a = ap.parse_args(argv)
    run = json.loads(Path(a.run).read_text())
    dispositions = json.loads(Path(a.dispositions).read_text())
    probes = {ln.strip() for ln in Path(a.collect).read_text().splitlines() if ln.strip()}
    verdict, code = build_verdict(run, dispositions, probes)
    print(format_report(verdict))
    return code


if __name__ == "__main__":
    sys.exit(main())
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

harness/diagnostics/test_mutation_verdict.py

#!/usr/bin/env python3
"""Tests for the disposition validator and the merge verdict.

The two cases a maintainer actually cares about, stated as assertions:

  an open mutant blocks the check        (exit 1)
  an equivalent or coverage-gap mutant does not   (exit 0)

Everything else here exists so that neither of those can be reached by a wrong
report: a mutation that never applied, a stale or orphaned disposition, an
equivalent claim with no probe behind it, a diagnostic that did not finish.

    python -m pytest harness/diagnostics/test_mutation_verdict.py -q
"""

import json
import sys
from pathlib import Path

import pytest

sys.path.insert(0, str(Path(__file__).resolve().parent))
from mutation_verdict import (  # noqa: E402
    EXIT_ERROR,
    EXIT_REJECTED,
    EXIT_TRUSTED,
    build_verdict,
    main,
)

PROBES = {"tests/test_dates.py::test_minute_boundary", "tests/test_dates.py::test_weekend"}


def run(*mutants, error=None):
    return {
        "commit": "a1336eac",
        "suite_hash": "sha256:deadbeef",
        "mutants": [{"id": mid, "status": st, **(extra or {})} for mid, st, extra in mutants],
        "error": error,
    }


def equiv(probe="tests/test_dates.py::test_minute_boundary", why="unreachable upstream"):
    return {"state": "equivalent", "probe": probe, "why": why}


def gap(why="no test drives the boundary", action="open issue, add test"):
    return {"state": "coverage-gap", "why": why, "action": action}


# --- the two cases that decide the design -------------------------------------


def test_open_survivor_rejects():
    v, code = build_verdict(run(("dates.py:38: 59 -> 60", "survived", None)), {}, PROBES)
    assert code == EXIT_REJECTED
    assert v["verdict"] == "REJECTED"
    assert v["buckets"]["open"] == ["dates.py:38: 59 -> 60"]
    assert v["errors"] == []


def test_equivalent_and_coverage_gap_do_not_block():
    report = run(
        ("dates.py:38: 59 -> 60", "survived", None),
        ("money.py:12: < -> <=", "survived", None),
        ("parse.py:7: 0 -> 1", "killed", None),
    )
    dispo = {"dates.py:38: 59 -> 60": equiv(), "money.py:12: < -> <=": gap()}
    v, code = build_verdict(report, dispo, PROBES)
    assert code == EXIT_TRUSTED
    assert v["buckets"]["open"] == []
    assert v["buckets"]["equivalent"] == ["dates.py:38: 59 -> 60"]
    assert v["buckets"]["coverage-gap"] == ["money.py:12: < -> <="]
    assert v["mutation"] == {"applied": 3, "killed": 1, "survived": 2}


# --- equivalence is a claim with a probe attached -----------------------------


def test_equivalent_without_probe_is_error_not_green():
    v, code = build_verdict(run(("a.py:1", "survived", None)), {"a.py:1": equiv(probe="")}, PROBES)
    assert code == EXIT_ERROR
    assert [e["code"] for e in v["errors"]] == ["MISSING_PROBE"]
    assert v["buckets"]["open"] == []  # not mislabelled as a survivor finding


def test_probe_that_does_not_resolve_is_error():
    v, code = build_verdict(
        run(("a.py:1", "survived", None)),
        {"a.py:1": equiv(probe="tests/test_gone.py::test_nothing")},
        PROBES,
    )
    assert code == EXIT_ERROR
    assert v["errors"][0]["code"] == "UNRESOLVED_PROBE"


def test_coverage_gap_needs_reason_and_action():
    v, _ = build_verdict(run(("a.py:1", "survived", None)), {"a.py:1": gap(action="")}, PROBES)
    assert [e["code"] for e in v["errors"]] == ["MISSING_ACTION"]
    v, _ = build_verdict(run(("a.py:1", "survived", None)), {"a.py:1": gap(why=" ")}, PROBES)
    assert [e["code"] for e in v["errors"]] == ["MISSING_REASON"]


def test_unknown_state_is_error():
    v, _ = build_verdict(run(("a.py:1", "survived", None)), {"a.py:1": {"state": "wontfix"}}, PROBES)
    assert [e["code"] for e in v["errors"]] == ["INVALID_DISPOSITION"]


# --- the report itself --------------------------------------------------------


def test_never_applied_mutation_is_error_not_survivor():
    report = run(
        ("dates.py:38", "not_applied", {"reason": "regex hit module docstring"}),
        ("money.py:12", "survived", None),
    )
    v, code = build_verdict(report, {"money.py:12": gap()}, PROBES)
    assert code == EXIT_ERROR
    assert v["errors"][0]["code"] == "NOT_APPLIED"
    assert v["errors"][0]["mutant"] == "dates.py:38"
    # it is not counted as blind: only the real survivor is, and it is disposed
    assert v["mutation"]["survived"] == 1
    assert v["buckets"]["coverage-gap"] == ["money.py:12"]  # the valid one still counts
    assert "dates.py:38" not in v["buckets"]["open"] + v["buckets"]["equivalent"]


def test_stale_disposition_on_killed_mutant_is_error():
    v, code = build_verdict(
        run(("a.py:1", "killed", None)), {"a.py:1": equiv()}, PROBES
    )
    assert code == EXIT_ERROR
    assert v["errors"][0]["code"] == "STALE_DISPOSITION"


def test_orphan_disposition_is_error():
    v, code = build_verdict(
        run(("a.py:1", "killed", None)), {"b.py:9": equiv()}, PROBES
    )
    assert code == EXIT_ERROR
    assert v["errors"][0]["code"] == "ORPHAN_DISPOSITION"


def test_diagnostic_failure_is_error():
    v, code = build_verdict(run(error="pytest exited 3 during mutant 4"), {}, PROBES)
    assert code == EXIT_ERROR
    assert v["errors"][0]["code"] == "DIAGNOSTIC_FAILED"


def test_error_outranks_open():
    report = run(("a.py:1", "survived", None), ("b.py:2", "survived", None))
    v, code = build_verdict(report, {"a.py:1": equiv(probe="")}, PROBES)
    assert code == EXIT_ERROR and v["verdict"] == "ERROR"
    assert v["buckets"]["open"] == ["b.py:2"]  # still printed, not hidden


def test_killed_mutants_need_no_disposition():
    v, code = build_verdict(run(("a.py:1", "killed", None), ("b.py:2", "killed", None)), {}, PROBES)
    assert code == EXIT_TRUSTED and v["buckets"]["open"] == []


# --- the command, as CI runs it ----------------------------------------------


def test_cli_exit_codes(tmp_path):
    (tmp_path / "run.json").write_text(json.dumps(run(("a.py:1", "survived", None))))
    (tmp_path / "probes.txt").write_text("\n".join(PROBES))
    (tmp_path / "dispo.json").write_text("{}")
    args = [
        "--run", str(tmp_path / "run.json"),
        "--dispositions", str(tmp_path / "dispo.json"),
        "--collect", str(tmp_path / "probes.txt"),
    ]
    assert main(args) == EXIT_REJECTED

    (tmp_path / "dispo.json").write_text(
        json.dumps({"a.py:1": equiv("tests/test_dates.py::test_weekend")})
    )
    assert main(args) == EXIT_TRUSTED

    (tmp_path / "dispo.json").write_text(json.dumps({"a.py:1": equiv(probe="nope")}))
    assert main(args) == EXIT_ERROR
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

Thanks

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
iliyaoblakov profile image
Iliya Oblakov •

My gate is the case for a suite the PR can't touch. gate.sh runs whatever tests are in the commit, so a commit that changes code and tests together also decides what a pass means. I broke add in a small Python project, changed its two assertEqual tests to assertTrue(add(2, 3)) and assertIsNotNone(add(-1, 1)), and the gate wrote a pass record. GATE_MIN_TESTS is set outside the commit, where the gate runs, but it only fails a drop in the test count. A hidden suite does move the trust to whoever maintains it, so who updates yours when the intended behaviour changes?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

That's a fair distinction. "GATE_MIN_TESTS" protects the test count, not the quality or intent of the assertions. If the commit can change both the implementation and its tests, the gate cannot treat those tests as an independent source of truth.

For the hidden suite, I think ownership should sit with the people responsible for the expected behaviour and public contract, with changes reviewed separately from the implementation PR. When requirements change, the suite should be updated, versioned, and tested against known-good and known-bad cases. The gate should also record which suite version produced the verdict.

I don't think hidden tests eliminate trust. They move it to a smaller, more controlled review boundary.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
iliyaoblakov profile image
Iliya Oblakov •

Recording the suite version only helps if something reads it back. My pass record keeps the test command on a Command: line and merge-check.sh compares it with nothing, so in a scratch repo node --test test/format.test.js got a pass record with add() still wrong. The record was accurate and nothing checked it. Will your gate refuse a verdict from a suite version that isn't the current one, or only store which version ran?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

That's a valid gap. Recording which suite ran is not enough if the merge gate never verifies that it is the expected suite.
I'd want the gate to compare the recorded suite version and test command against the trusted baseline before accepting the verdict. Otherwise, we're trusting the receipt without verifying its contents.
Did you solve this by pinning the expected test command in the merge policy, or by validating it against the base commit?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
iliyaoblakov profile image
Iliya Oblakov •

Neither yet. gate.sh writes the command into the pass record and merge-check.sh reads only the Head: line. In a scratch repo, a hand-written pass record holding one Head: line and no command still got an OK. Of your two options I'd pin the expected command where the gate runs, next to GATE_MIN_TESTS: mine arrives as an environment variable (GATE_CMD), so the base commit holds no copy to validate against. Where does your trusted baseline live so the PR under test can't edit it?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
aheadkit profile image
AheadKit •

This is the check I wish more agent tooling had: verify the claim, not the story around it.

We hit the same shape this week outside PRs. We were measuring MCP tool costs and chasing webhook duplicates, and the fix that actually worked was a claim row — a record of what was supposed to have happened, checked before anything was trusted a second time. A retry loop on its own just re-ran the same work and counted it twice.

Your diff checks feel like the same idea applied to code: the PR text is the claim, the tests are the evidence, and the gate refuses to let one stand in for the other. The red-on-old, green-on-new rule is the part I would keep — a new test that passes on old code proves nothing, just as a duplicate webhook with a fresh timestamp proves nothing.

The case I am still unsure about is the plausible claim with no run behind it at all. What does your gate do when the agent describes a fix that looks right, the diff is tidy, and the tests pass — but the run it says it did never actually happened? Is there anything in the gate that ties the claim back to an execution record, or is that the next trust gap after the hidden suite?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

That's a very good question. The gate should never accept "I ran the tests and they passed" as evidence by itself.

In my approach, "gate.sh" runs the checks independently against the committed code. The agent's explanation and its claimed test results don't determine the verdict. The gate's own execution result does.

So even if the diff looks clean and the agent describes a plausible fix, it still has to pass the checks when the gate runs them.

I agree there's another important layer here: making the execution record traceable to the exact commit, test suite, and gate run. That makes it possible to distinguish an actual verified execution from a log or claim supplied by the agent.

Your claim-row example is a useful parallel. In both cases, the system needs evidence of what actually happened, not just a plausible description of what happened.

I'd treat execution provenance as an important next step, especially for CI environments where results need to be independently auditable.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
aheadkit profile image
AheadKit •

The provenance point is the one that makes the whole thing checkable — a verdict you can trace to the exact commit, test suite and gate run, not just a log the agent handed you. That's the same shape as the claim row on our side, evidence of what happened instead of a description of it. Does gate.sh record that provenance in the PR itself, or does the reviewer have to go somewhere else to see it?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

The provenance needs to be accessible where the review happens. Ideally, the PR should carry the gate verdict, commit SHA, test suite version, and run details so reviewers don't have to chase evidence elsewhere.
That's also something I'd like to strengthen further. Would you prefer this as a PR comment or a commit-linked verification artifact?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
aheadkit profile image
AheadKit •

PR comment, for me — the review happens in the PR, so the verdict has to live where the eyes already are. A commit-linked artifact is the durable one, but anything the reviewer has to go find is something they'll skip on a busy day. The SHA in the comment ties it to the code anyway. Does gate.sh post the comment itself, or does someone paste it in by hand?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
gautamtalksdev profile image
Gautam K •

17 million agent PRs a month makes the review problem obvious: nobody reads that many diffs carefully. A gate that decides which agent PRs need a human, based on what they touch rather than their size, is the right place to put effort.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

PR size alone doesn't tell us the risk. A small change to authentication, database logic, or a public API can be more dangerous than a much larger isolated change. I'd rather make human review risk-based, with deterministic checks as the first line of defence.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
gautamtalksdev profile image
Gautam K •

Agreed, risk is about what a change touches, not how big it is. A two-line auth change deserves more eyes than a 500-line isolated refactor. Deterministic checks first, then people where the risk sits.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

The size of a change doesn't tell us how risky it is. A small modification to authentication, permissions, or access control can have a much bigger impact than hundreds of lines of isolated refactoring. I'd rather prioritize review based on what the change affects, run deterministic checks first, and bring in human reviewers where the actual risk is. That's a much more practical approach than treating every PR equally.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
gautamtalksdev profile image
Gautam K •

Deterministic checks first, then people where the risk actually is. That ordering is the practical version of risk based review.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
emilywoodsnyc profile image
Emily Woods •

The regression test failing on the old code is the evidence I’d want beside the PR result. I’d also keep the collected and skipped test counts in the receipt so a green run with less coverage is visible. That is a useful habit to bring to code-review practice too: show what distinguishes the fix from the original behavior.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

Yes The test counts in the receipt are important too. A green result should never hide reduced test coverage. The goal is to make the evidence behind the fix visible, not just show a passing status.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
emilywoodsnyc profile image
Emily Woods •

Yes. I’d want a reduced collected-test count to be visible as a separate failure, even when the command exits successfully. Otherwise deleting or skipping a test can quietly make the receipt look better.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
zade_meadows profile image
Zade Meadows •

Agreed, and I'd key it on nodeids rather than the collected count.

The count is the weaker key. Rename a test and the count holds while an id disappears. Mark one skip and the nodeid is still collected, so the count doesn't move at all while the coverage does.

So the baseline is the collected nodeid set at the base commit, collected in the same environment:

pytest --collect-only -q | grep '::' | sort > base_nodeids.txt

Then three separate findings, none of which may depend on the command's exit code:

  1. Nodeid present at base, absent at head: BLOCK, and report the missing id.
  2. Test deleted, skipped or xfail inside the PR's own diff: BLOCK, independent of set membership. This is the one a count rule can't see, because a skip still collects.
  3. Collection error: a non-zero exit that must be classified as "could not run", never as "a test failed". Any runner that maps every non-zero to red will count a broken import as a caught bug.

Keep the count as well, but as the human-readable receipt line: collected 412 -> 411, missing tests/test_review.py::test_withdraw_disposition. The count is the part people read. The nodeid set is the part that enforces.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
emilywoodsnyc profile image
Emily Woods •

You are right that the count alone is too weak. I would keep the nodeid comparison and the execution outcomes together: a collected test can still be skipped without disappearing from the set. An intentional rename also needs an explicit reviewed mapping, otherwise a useful baseline can become a pile of exceptions people stop reading.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
zade_meadows profile image
Zade Meadows •

Agreed on the mapping. My worry is the same one from the other end: the mapping is the one place in the gate where a disappearance gets forgiven, so it has to carry its own evidence instead of being a list someone maintains.

One line per remap:

<old_nodeid> <new_nodeid> <commit_sha> <reviewer>
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

An entry only counts if four things hold in the same run:

  • old nodeid absent from the head's collected set
  • new nodeid present in it
  • the new nodeid's outcome is executed (passed or failed), not skipped and not xfail
  • commit_sha equals the head being checked

Fail any one and the entry is void, which means the missing-nodeid finding stands instead of being waived. That last clause is where the obvious implementation goes wrong: if "a mapping exists" is the test, a rename becomes a way to bury a skip, because the new id is collected and the outcome is never looked at.

Then expiry. A remap is valid for exactly one commit, the one that carries the rename, and its job ends there because that is the commit where the baseline gets re-written. If it is still present at the next head, that is RED: the baseline was never re-based and the list is now permanent. If the old nodeid reappears and the mapping is still there, the mapping lied and the entry dies too.

With those two rules the list cannot grow. Every entry either expires at the commit that earned it or turns red, and there is no state in between where it just sits there looking like a reviewed exception.

The check, no repo needed, ten seconds:

def remap_state(head_ids, outcomes, remaps, head_sha):
    void = []
    for line in remaps:
        old, new, sha, who = line.split()
        if (sha != head_sha or old in head_ids or new not in head_ids
                or outcomes.get(new) not in ("passed", "failed")):
            void.append(line)
    return "PASS" if not void else "VOID: " + "; ".join(void)
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

Feed it the collected ids, the per-nodeid outcomes and the remap file, and it prints the exact lines that are not evidence. The reviewer field is not decoration: a remap is the only line in this gate where a human certifies that coverage moved instead of vanishing, and that claim deserves a name on it.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sweety717 profile image
JavaCoder7 •

I like the distinction between a test passing and a fix actually being proven. The red-on-old, green-on-new requirement is a strong way to avoid counting a test that would have passed anyway.

One additional challenge is handling existing repositories where the baseline already has failing or flaky tests. A strict before-and-after comparison needs to distinguish pre-existing failures from regressions introduced by the PR.

I'd also be interested in how you plan to handle integration or behaviour changes that aren't fully covered by the hidden suite. The deterministic approach makes the verdict more trustworthy, but clearly defining what it has and hasn't verified is just as important.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

I agree. Pre-existing failures need to be captured against the baseline so the gate doesn't incorrectly blame a PR for something already broken. I'd compare the before-and-after results and flag newly introduced failures separately.
For integration and behaviour changes, I'd rather be explicit about the verification boundary. A passing gate should mean the checks we ran passed, not that every possible production scenario is safe.
How do you handle flaky baseline tests in your own CI pipelines? Do you quarantine them or track their failure history separately?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sweety717 profile image
JavaCoder7 •

Agreed on the verification boundary. A pass should mean "the checks we ran passed", and we word it that way ("What CodeGuard did not verify" appears in every review).

On flaky tests, we don't handle them well yet. When tests fail, we rerun the base commit and label each failure as new or already there, but that's a single run each. A flaky test can look "new" on one run and "inherited" on the next. The fix is to rerun failures a few times and only call one new if it fails consistently on the PR and passes on the base. We haven't built that.

In our own pipeline we're a small team and don't have quarantine or failure-history tracking yet. How do you do it? Do you rerun-on-fail, or keep a list of known flaky tests?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
innokentyb profile image
Kent Bodrov •

I’d let a hidden suite block a merge, but I’d treat the suite itself as a maintained product: version it, record which version produced the verdict, and periodically run known-bad changes against it. A green result only proves that this version of the suite caught none of its known failure patterns. Who reviews the hidden tests when requirements change?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

I agree. The hidden suite needs the same discipline as the application tests. Otherwise, it can give a false sense of confidence as requirements evolve.

I would keep it versioned and review it whenever the expected behaviour or public contract changes. I also like your suggestion of running known-bad changes against it. That gives us some confidence that the suite can still catch the failures it was designed for.

One thing I'd like to explore further: would you make the team that owns the application responsible for reviewing hidden tests, or keep that responsibility with an independent reviewer to avoid blind spots?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
innokentyb profile image
Kent Bodrov •

I’d split ownership rather than pick one. The application team should own the behavior and update the tests when the contract changes; someone outside the change should review whether those tests can actually fail for the relevant bad cases. For a small team, that could be a rotating reviewer rather than a separate department. I’d keep the suite version and the reason for each acceptance change with the review.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 Thread
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

I like that separation. The application team understands the intended behavior, but an independent reviewer can challenge whether the tests actually prove it. Keeping the suite version and acceptance-change history in the review also makes the decision easier to audit later.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
zahurul profile image
Zahurul Islam •

"No model grades the model" is the line I'd put on a poster. The four fake-fix patterns you list (edit the test, delete the throwing function, add a test that always passes, break something else) map neatly onto checks that need zero LLM: diff the test files, run the original suite, and require a test that fails on the parent commit and passes on the fix. Did you consider making "fails before, passes after" a hard requirement for every claimed fix, or does that break down for bugs without an easy repro?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

I did consider that, and I think it's a strong requirement whenever the bug can be reproduced. It gives us concrete evidence that the test actually detects the original problem.
For bugs without a reliable reproduction, I'd rather make the limitation explicit than accept a test that only creates the appearance of coverage.
How do you handle those edge cases in your own agent PR workflows?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
zahurul profile image
Zahurul Islam •

Same instinct: make the gap visible instead of faking coverage. When there's no repro, I ask the PR for three things instead: a written hypothesis of the root cause, a characterization test that pins the current behaviour around the change (so at least nothing else silently moves), and a label like unverified-fix that routes it to a human and adds a monitor or log line for the failure signature. If the bug shows up again, that signature becomes the repro and the "fails before, passes after" rule applies from then on.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
lin7c profile image
xcl •

The number that stuck with me is issue 4 converging in only 2 of 8 runs while issue 6 reached 9 of 12 — best-of-3 candidates helped more than extra rounds, which suggests the bottleneck is search, not the bar. One thing I would want to know is how much detail the gate feedback carries back to the agent: does it see the specific failing assertion and test name, or only which of the five checks failed? If it is only the check name, the agent is effectively re-guessing the same space each round, and richer feedback might move issue 4 without lowering the standard. The red-to-green rule plus the hidden suite is the right combination either way, since it forces the agent to produce evidence rather than a plausible diff.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

That's exactly the distinction I wanted to explore. The gate should return more than a failed check name. Ideally, the agent gets the failing test name, assertion details, and relevant failure output so it can make a targeted correction.
I agree that richer feedback could improve convergence without lowering the verification standard. The goal is to help the agent find the right fix, not make acceptance easier.
Would you also expose the hidden-suite failure details to the agent, or keep those private to avoid overfitting?

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
zade_meadows profile image
Zade Meadows •

@lin7c Both, and the boundary between them is the part I had to build a wall around.

The verdict carries the failing test node and the assertion line, per test, not per check. Five check names is too coarse a coordinate system. dispositions tells the agent nothing it did not already know; tests/test_dispositions.py::test_missing_withdrawal_row plus assert rows == signed_rounds tells it which state to fix. Your 2 of 8 is what re-guessing looks like.

The wall: that detail comes from the visible suite the agent can already run itself. It never carries an identifier from the hidden suite. Test names and assertion text on the hidden side are the two cheapest things to overfit on, and once an agent knows test_opt_out is what stands between it and green, the shortest path is a special case for that name. You get a green build with a lie in it. Same rule that makes red-to-green work: the agent gets a target, not the answers.

So the payload is check code, public test node, assertion line, bounded (last N bytes, no full traceback). The hidden suite returns pass/fail and a witness hash, never a name.

One runnable check for the boundary, stdlib only:

import json
HIDDEN_PREFIX = "hidden/"
def check(payload):
    blob = json.dumps(payload)
    leaks = [t for t in payload.get("tests", []) if t.startswith(HIDDEN_PREFIX)]
    print("tests:", payload.get("tests"), "| hidden leaks:", leaks or "none")
    return bool(payload.get("tests")) and not leaks and "assert" in payload.get("assertion", "")
legal = {"tests": ["tests/test_dispositions.py::test_missing_withdrawal_row"],
         "assertion": "assert rows == signed_rounds", "check": "dispositions"}
leaky = {"tests": ["hidden/test_opt_out.py::test_disposition_required"],
         "assertion": "assert x", "check": "dispositions"}
thin  = {"check": "dispositions"}
for name, p in (("legal", legal), ("leaky", leaky), ("thin", thin)):
    print(name, "->", check(p))
🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025 🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025

legal passes, leaky fails on the hidden node, thin fails on carrying no test at all. If your gate prints only the check name, thin is your current state.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
prachitparikh profile image
Prachit Parikh •

The red-on-old, green-on-new rule is the one I'd copy first. On amarinhodev's hardcoding case: if the hidden suite reuses the numbers in the bug report, an agent can pass it by special-casing those inputs. I'd write the hidden tests from the acceptance criterion, with fresh examples nobody pasted into the issue, and have the person who reported the bug confirm them. Then "1 fix claimed" can also name the criterion it claims to meet, and the gate checks that the hidden test for that criterion is the one that went green.

🔥 ข่าวด่วน: aws builders/ai agents open million pull requests a month i built a gate that rejects the ones that lie n - Kapook Update 2025
 
sarvar_04 profile image
Sarvar Nadaf AWS Community Builders •

I like this approach. The acceptance criterion should be the source of truth, not the exact inputs from the bug report.

Using fresh examples makes it harder for an agent to pass by hardcoding the reported values. Having the person who reported the bug confirm the test also adds an important validation step: the hidden test must represent the intended behaviour, not just an assumption made by the test author.

I particularly like your suggestion to connect each claimed fix to a specific acceptance criterion. The verdict could then show which criterion was tested, which hidden test verified it, and whether that test passed against the original and updated code.

That gives us a much stronger audit trail than simply saying "1 fix claimed, 1 test passed."

Some comments may only be visible to logged-in visitors. Sign in to view all comments.