DEV Community

Cover image for 389 Tests Passed. NIST Still Caught the Bug.

389 Tests Passed. NIST Still Caught the Bug.

Don Johnson on July 25, 2026

I gave an AI agent a calculator because I wanted one hard, inspectable point inside a probabilistic workflow. The model could interpret the reques...
Collapse
 
merbayerp profile image
Mustafa ERBAY

I really like that this doesn’t stop at “389 tests passed, one failed.” The more interesting takeaway is that the independent reference (NIST) wasn’t just another test case—it was an external challenge to the implementation itself.

The same principle applies well beyond numerical software. In distributed systems, security tooling, or ERP integrations, a green test suite only tells us the implementation agrees with our expectations. It doesn’t tell us those expectations are correct. That’s why independent references, mutation testing, and replayable evidence complement each other so well—they challenge different assumptions instead of reinforcing the same one.

The phrase that stayed with me was: “The opposite of probabilistic is not trustworthy. It is repeatable.” That’s a subtle but important distinction.

Collapse
 
alex_spinov profile image
Alexey Spinov

"A green count is evidence only to the extent those tests would turn red" is the line I would carve into the wall. I ran a small version of the mechanism under it, using your own offset-invariance property rather than your exact operator swap (no repo access here): correct = two-pass variance, mutant = naive one-pass (sum_sq - sum^2/n)/n. Valid types, plausible float.

The mutant is caught only where the input discriminates it. Shift every value by an exact offset (your property #3) and the naive formula's cancellation error grows with it: rel-err 3e-17 at offset 0, 1.2e-5 at 1e6, 8.4e-2 at 1e8 (true 9.43 vs naive 9.60). An assertion against the known invariant catches it at 1e6 and 1e8, and misses everywhere below. So "Longley caught it" is not only that Longley is independent, it is that Longley is ill-conditioned enough to move the mutant past tolerance. Independence is necessary; the catch is independence AND sensitivity on that input, together.

Which is why the count is the wrong axis. In the run, 10 / 100 / 1000 / 10000 well-conditioned inputs catch the mutant 0 times each; one ill-conditioned input catches it. Adding green tests at the same conditioning adds confidence and zero discriminating power.

The sharpest cell was the snapshot one: when the expected value is captured by running the implementation (a golden assertion), catch is 0.00 at every offset, because a self-authored expectation has sensitivity 0 by construction. It moves with the bug. That is the structural reason 389 can stay green: any assertion whose expected value the implementation authored is blind to a mutation on the shared path, no matter how many you have. NIST's value was the one nobody in the codebase could edit.

file sha 07768e4d, out fd3314b0, stdlib/offline, 3x byte-identical.

Collapse
 
copyleftdev profile image
Don Johnson • Edited

“Independence AND sensitivity” is the right sharpening. My line compresses two separate questions: can the expected
result move with the implementation, and does the selected input make the mutation observable? Your offset sweep
isolates that second question beautifully. Ten thousand well-conditioned cases can provide less discriminating power
than one deliberately hostile case.

I would preserve one boundary between our experiments, though. Your mutant—two-pass variance replaced by the
cancellation-prone one-pass formula—specifically interacts with conditioning. Mine replaced multiplication with
addition in the regression standard-error calculation. Your result demonstrates why conditioning kills your mutant,
but it does not yet establish that Longley’s conditioning is why it killed mine. To establish that, I would need to
replay the exact operator mutation across datasets with controlled conditioning. Longley may instead have been the
only library test that independently asserted the affected output.

I’d also narrow the snapshot conclusion. A frozen, checked-in snapshot authored by the implementation can catch later
mutations because it does not automatically move during the test. What it cannot establish is that the original
captured answer was correct. A runtime-regenerated or automatically blessed golden—or an expectation calculated
through the same code path—really does move with the bug and is structurally blind.

So the stronger model has at least four axes: oracle provenance, assertion coverage, input sensitivity, and tolerance.
Raw test count collapses all four into a number that says very little.

Your reproducibility details and hashes make this a genuine extension of the argument, not merely agreement. Thank you
for running it.

Collapse
 
alex_spinov profile image
Alexey Spinov

I ran exactly the replay you asked for: hold your mult-to-add swap fixed, sweep dataset conditioning, and cross it with oracle type. The result cuts against conditioning as the explanation for your mutant, and toward your own alternative.

Setup: OLS coefficient SE, the mutation placed at the variance combination (sigma2 * v becomes sigma2 + v, where v is the inverse-Gram diagonal). I swept a collinearity knob so cond(X'X) runs from 1.5e3 to 3.4e7, roughly spanning well-conditioned to Longley-grade.

What came out:

  • An independent oracle holding the true SE catches the mutant at all six conditioning levels, 6 of 6.
  • A same-path golden, expectation regenerated through the same formula, is blind at all six, 0 of 6.
  • The catch signal does not grow with conditioning. Relative SE difference is largest when well-conditioned (5.0 at cond 1.5e3) and shrinks to about 0.09 as conditioning worsens.

So for an operator swap the axis that flips catch versus miss is not input sensitivity, it is provenance. That supports your line that Longley may have been the only test independently asserting the affected output, rather than the one that happened to be ill-conditioned.

I think the two mutants genuinely sit on different axes. Mine, two-pass variance to the cancellation-prone one-pass, is a cancellation effect, so it really is conditioning-driven, which is why my sweep read that way. Yours is a gross algebraic change, visible to any independent oracle regardless of conditioning. Same headline, different mechanism, and it took your boundary to see it.

One caveat that lands on your fourth axis: at the ill-conditioned end the relative difference falls to about 7 percent, so a loose oracle tolerance near 10 percent would start missing your mutant there even with an independent assertion. The four axes interact rather than add. The honest seam: I placed the swap at the variance combination. A different site, inside RSS or inside the Gram product, could couple to conditioning differently, so this is a claim about that placement, not every multiply in the SE path.

Collapse
 
wrencalloway profile image
Wren Calloway

The mutation that survived — * to + in the standard error — isn't just a "your tests aren't sensitive enough" story. It's a specific class of bug: the mutant produced a plausible number, not garbage. That's the whole reason 389 tests waved it through. Assertions written by the same person who wrote the formula tend to encode the same mental model, so they check shape and rough magnitude, not the exact value. NIST worked as an oracle precisely because it was authored by someone who never saw your code and had no incentive to agree with it.

The caveat worth adding: this only holds for the narrow slice NIST actually covers. Longley caught the standard-error mutation because that dataset exercises multiple regression. Mutate something in a code path StRD doesn't touch — your optimization grid, your expression parser, anything outside linear stats — and you're back to self-authored oracles with the same blind spots. So the honest read of your own result isn't "add an external witness," it's "you have exactly one witness, for exactly one procedure, and everything else in the binary is still marking its own homework." The optimization boundary bug you hit at the end is the proof — no NIST dataset was ever going to catch an unbounded grid search.

Which is why I'd treat the mutation score per-module as the real deliverable here, not the fact that one assertion held. The gaps in mutation coverage map directly onto the parts of the tool that have no independent witness — and those are the parts an agent will happily drive off a cliff.

Collapse
 
anik_sikder_313 profile image
Anik Sikder

I like the distinction between repeatability and trustworthiness. In complex systems, reliability often comes not from making components deterministic, but from creating independent validation layers that continuously challenge assumptions and authority.

Collapse
 
valentynkit profile image
Valentyn Kit

Longley catching it isn't really the externality doing the work, it's the conditioning: that's NIST's canonical ill-conditioned regression set, which is why a flipped sign surfaces there and nowhere in the other 389. An external reference that happened to be well-behaved would have passed right along with them.

Collapse
 
seven7763 profile image
Seven

Strong writeup. One angle I wish more test suites covered: eval the provider, not just the unit under test.

If traffic goes through a third-party LLM endpoint, a fixed capability probe at temp=0 (diffed against the official API, re-run weekly) catches silent model swaps that green unit tests never see — same rigor as NIST-style property checks, pointed at the vendor.

Collapse
 
groddum profile image
Groddum • Edited

That’s an excellent and very insightful observation. You’re absolutely right: in an era of reliance on third-party APIs, traditional unit testing creates a false sense of security. If the wrapper code works correctly, the test will pass, but the quality and logic of the provider’s “black box” itself may change without anyone noticing.
The long wait for financial requests to be approved can spoil the experience of even the highest-quality gaming software. By choosing technologically advanced Fast Payout Casinos alphanetworks.io/ users can say goodbye to delays once and for all and receive their winnings in a matter of minutes. Instant access to funds makes the gaming experience as comfortable and secure as possible.

Collapse
 
skillselion profile image
Skillselion

389 passing and exactly one failing is such a clean demonstration that a test harness mostly measures agreement with its author. The suite and the implementation shared an author, so they shared the blind spot; NIST did not. For operations where no certified dataset exists, metamorphic relations are the closest substitute: you cannot know the right regression coefficients, but you know scaling every x by 10 must scale the slope by exactly one tenth, permuting rows must change nothing, and fitting a duplicated dataset must return identical coefficient estimates. Those properties are author-independent the same way StRD is, since they come from the mathematics rather than from anyone's implementation. Curious whether you would extend revocable authority into the agent runtime: the tool passed StRD once at review time, but the agent keeps trusting it forever. Re-running the witness suite on every version bump and downgrading the tool's authority on failure would make the revocation actually operational.

Collapse
 
fromzerotoship profile image
FromZeroToShip

"Green test count is evidence only to the extent that those tests would turn red when the implementation meaningfully changes" — I'd put that line above the NIST story, because it's the part that generalises to domains with no Longley to borrow.

I don't have a certified dataset. I build internal tools as a non-developer and one of them is a static security scanner, where nobody publishes an authoritative "here is the correct set of findings for this codebase." So the cheapest external witness I found was the one you're describing in mutation form, made permanent: every guard in the suite gets deliberately broken on every run, and it has to go red for its own reason — matching the expected message, not merely exiting nonzero, because an exit code lets one gate's failure pass as another gate's proof. It's cargo-mutants as a standing gate rather than an occasional audit.

That caught something a periodic run wouldn't have. One guard had drifted into being unbreakable: it was falsifiable by design, but a widened pattern quietly made its failure condition unreachable, so "no failure observed" stayed true for the wrong reason for weeks. Six clean files were being scored as broken behind that green the whole time. Your framing explains why my 389 equivalents didn't help — they and the implementation were written from the same understanding — but the mutation loop is what told me the test had stopped being able to fail, which is a different lie than the one NIST catches. For anyone reading without access to institutional reference data: the minimum viable witness isn't a dataset, it's a mechanism that proves your checks can still turn red today.

Collapse
 
gaurav_palaskar_d233e9409 profile image
Gaurav Palaskar

hello, everyone it's all new for me.how i understand this all think program and resources