CodeGuard AI is a self-hosted PR reviewer for Java that runs your tests and lets the result overrule the AI. Right after 1.1.1, readers found two holes. Here is each one and how it was closed.
Hole 1: the PR that makes a test flaky. 1.1.1 reran a failing PR test once. If it passed and base never failed, it was called flaky and did not block. But a PR that introduces a race fails once, passes on the rerun, and base is clean, which is exactly the same picture. The fix compares counts. When the PR fails a test base did not, both sides run the same number of extra times (default 2) and each test is judged by its failure counts:
PR runs failing Base runs failing Result
all none PR broke it: BLOCK
some some already flaky: no block
some none PR most likely made it flaky: WARN (configurable)
The review shows the evidence, for example "failed in 1 of 3 runs on the PR and 0 of 3 on the base branch". A rerun that errors out is never counted as a pass.
Hole 2: runs that execute nothing. Exit 0 with zero tests counted is not a pass: it becomes NO_TESTS_EXECUTED and the verdict is floored at UNVERIFIED, whatever the AI said. New in this round: a test that pushes a 2-second, zero-result run through the whole review, and a guard that marks a pass UNVERIFIED if it ran under half the tests of the last trusted run for that repo.
properties
codeguard.sandbox.flaky-reruns=2
codeguard.policy.tests.on-flaky-introduced=WARN
codeguard.policy.tests.min-test-ratio=0.5
Limits: the count floor lives in memory and starts empty after a restart. A PR that deliberately deletes half its tests will trip it; handling that case from the diff is next. Both new features are covered by unit tests and not yet seen on a live run.
CodeGuard AI: full source, one-time purchase, 14-day refund, 25% off with LADDOOGOPAL25 until 6 Dec: https://javacoder716.gumroad.com/l/codeguard-ai
Top comments (4)
Love the
exit 0 + zero tests ≠ passrule. “Nothing failed” is surprisingly easy for an agent to interpret as “everything worked” 😄I’ve been exploring the same problem with Stet proving expected behaviour stayed intact rather than trusting the agent’s definition of done. Really like your evidence-first approach.
Thanks, Shamaz. "Nothing failed" and "everything worked" really are different claims, and the gap shows up most when an agent decides what "done" means. I'd like to hear how Stet proves expected behavior stayed intact. Does it compare against a recorded baseline, or against tests you write by hand? I'll take a look.
Both, in a way, and main is the baseline rather than a recorded file.
"Expected behaviour" in Stet is a set of locks: commands that must keep passing. Most are the checks you already have (your test suite, the type check, lint). Stet detects those on its own and doesn't ask you to write new tests. You can also lock a specific behaviour by recording a command's output as a snapshot, for when there's no test for it yet.
The comparison then happens against main, not against a stored baseline:
The honest limit is the one your post is about: a lock only proves what it actually checks. If the agent weakens the check itself, everything still passes on both sides. So Stet also reads the diff for that: assertions removed, tests skipped or set to .only, @ts-ignore added, test files deleted.
Your "exit 0 + zero tests" case is a gap I want to close the same way. I'd be curious which test runners bit you hardest there.
Thanks for the detail. Locks checked against main is the same shape as our base comparison. On "which runners bit you hardest": for us it was Maven Surefire. An empty test class exits 0 with no readable report, and before the fix our own sandbox ran 2 seconds with no results because the test container couldn't enter its work folder. Both now end in UNVERIFIED. Reading the diff for weakened tests is the right second half. We have the same idea for removed assertions and deleted test files.