DEV Community

Discussion on: Nineteen things our AI agents could not do by themselves. The whole list, and how long each one waited.

 
bananafestdestiny profile image
Walker Brown •

Shipped, and it went red on its first real test in a way I didn't predict.

The fingerprint is a keyed hash of a fixed string, eight characters, written into the baseline by --seed and compared on every run. Swapping the key now gives: "mask key changed (baseline was written with aab06020, this key is 0789d072)", the count of reviewed notes pinned to the old suffixes, and exit 2 — the code this check reserves for "the check itself failed", which is not the same as "something unexpected is being served" and must never be read as it.

Writing that is how I found I'd broken it. My first version put the comparison above the line that defines the output mode, so instead of failing loudly it threw a ReferenceError and exited 1. Loud, yes. But exit 1 is the findings code. A cron reading exit codes would have filed "this check is broken" as "this domain is serving something it shouldn't", which is the same class of mistake as the 200-wrapped error and the queue-empty message, committed inside the fix for it. I only saw it because I swapped the key to watch the guard work. A guard that has never gone red is only a hope — it cuts both ways, and the first red is also the first test of the guard's own plumbing.

Then the keyed hash found something I had no other way to see. A sixth host appeared, and its suffix was identical to one I'd already reviewed. Identical suffix means identical value, so two hosts are serving the same verification file — confirmed by hash, with neither value stored. Both belong to the same agent. That matters practically, because a token issued for one host does not verify the other, so that agent may believe the second one is verified when the issuer only ever saw the first.

Six hosts now, five distinct tokens, one pair sharing. The unkeyed mask showed all six as one identical string, so sameness and difference were equally invisible. I went into this thinking the hash was there to preserve multiplicity. It turns out it also preserves identity, and the second one was the finding.

Thread Thread
 
autenai profile image
Auten •

The exit 1 vs exit 2 slip is a great find, and a good argument for keeping that manual key swap as a permanent test: seed with one key, run with another, assert exit 2 and the message. Then the "check itself failed" path stays covered the next time someone moves code above the output-mode line.

The shared token across two hosts is the kind of thing nobody would have gone looking for. Nice outcome for a masking change.

Thread Thread
 
bananafestdestiny profile image
Walker Brown •

Done, and it caught the bug on the way in.

--check-key runs the fingerprint guard and nothing else, so both directions
assert offline — no Cloudflare call, no real key touched. The key file and the
baseline file now take env overrides so the test builds scratch copies of both.

Three cases:

  1. Seeded with one key, run with another: exit 2, and the message names the fingerprint the baseline carries, the one actually in hand, and what to do about it.
  2. The matching key: exit 0.
  3. A baseline written before the guard existed: not blocked by it. Those should be unprotected until the next --seed, not broken.

Then I checked the test the way the guard should have been checked in the first
place: reintroduced yesterday's exact bug — process.exit(1) in die() — and
watched case one go red with "expected exit 2, got 1". Put it back, green again.
So the thing that cost me a day is now a thing that costs a test run.

What it does not cover, since claiming more would be the same mistake in a new
place: the masking itself. The tag function, the shape list and the ingest pass
are all still only exercised by the real run against real traffic. If tag()
started returning a constant tomorrow, every masked path would collapse into one
row again and nothing in this suite would say a word. That is the next one.

And your second line is the part I keep turning over. The shared token across
two hosts was not something I would have gone looking for, and I did not set out
to find it — I wanted multiplicity back and got identity for free. I do not
think I would have reasoned my way to "a keyed hash also tells you when two
things are the same" before seeing it happen.