The Test That Could Never Fail

A passing test tells you very little until you have seen it fail. On October 21, 2026, a guard test on Moi, another product I build, was meant to keep development language off a public page. Its word boundaries had been written through a Python string, and each \b turned into one backspace character. Most editors show a backspace as nothing at all, so a regex like that can read as correct while it no longer looks for what it was written to find.

AI agents write a lot of tests now, and a green check is easy to accept without a second look. The lab below lets you plant a forbidden word, watch the guard miss it, find the hidden character, and prove your repair works in both directions.

Verification lab

Break a guard test, then prove it works

Five steps on one small guard. This is a reconstruction: the guard and the sample text are built to show the bug, and every result comes from a real regex running in your browser.

    Why the test stayed green

    A guard like this passes when its pattern finds nothing. Break the pattern so it can never match, and the guard passes forever. Most bugs make a test go red. This one removes the test’s ability to go red, so nothing tells you to look.

    Three things look alike here, and only one of them is a word boundary:

    • A backspace character, U+0008. One invisible control character. In a regex it matches only a real backspace, which ordinary page text does not contain.
    • A word boundary, \b in a regex. A position between a word character and anything else. It matches no characters at all. /\bagents?\b/i finds “agent” and leaves “reagent” alone.
    • The string "\\b". When you build a regex from a JavaScript string, the string gets read first. "\b" becomes a backspace before RegExp ever sees it, and "\\b" becomes the backslash and b that RegExp needs. Python strings behave the same way.

    What the record shows, and what it does not

    Moi’s repository is private, so the record is quoted here. This is how far each part can be checked.

    • In git history: commit c0f06af (October 21, 2026) says it “repairs the test that keeps development language off the public page: its word boundaries had been written as backspace bytes, so it could never match.” The project’s notes record the same lesson under escapes written through Python heredocs.
    • The repaired line, as committed: it is below, and it is still in Moi’s test suite.
    • Not in git history: the broken line itself. It was repaired before it was ever committed. I checked four versions of the test file and found no backspace bytes in any of them. So I cannot show you the original pattern, and I cannot recheck the words “could never match”: in the repaired line, only some alternatives use boundaries, and I do not know what the broken one looked like.
    • Not confirmed: how the bug was noticed. A private note of mine credits a test that deliberately broke the code, and I could not find that in the session logs I searched. I am not claiming it.
    • Reconstruction: the lab. Its one-word guard and sample sentences are mine. Its regexes are real.
    assert.doesNotMatch(visible, /\bagents?\b|ledger|research|tokens?\b|budget|USD|implementation|prototype|bake-off/i);

    A separate reproduction, ten days later

    This is a different event from the one above, and it happened while I was checking the record for this post. On October 31, 2026, my AI agent wrote a small Python script to count word boundaries in that test file. It typed a doubled backslash into a shell heredoc, and one backslash arrived in the file. I did not isolate which layer dropped it.

    b.count(b'\b')       # what arrived in the file: counts backspaces
    # reported 0

    The script ran without complaint and printed a false zero. The agent then rewrote it to build the bytes from numbers, and got the true count:

    b.count(bytes([92, 98]))   # a backslash and a b, built from numbers
    # reported 7

    It was not a one-off in my projects either: session logs from October 7, 2026 show an agent finding the same backspace in a regex in a different repository, using cat -A.

    Check your own guards

    1. Scan for control characters. Source files rarely have a reason to contain them. Tabs and line endings are allowed here, and a clean tree prints nothing. This one needs a shell that expands the wildcard, and it uses no backslashes, so it cannot fall into the trap it looks for:
      node -e "for (const f of process.argv.slice(1)) require('fs').readFileSync(f).forEach((b, i) => { if (b < 9 || b === 11 || b === 12 || (b > 13 && b < 32)) console.log(f, 'byte', i, 'value', b) })" test/*.js
    2. Look at a suspect line with cat -A. A backspace shows up as ^H, and your editor may show nothing at all.
    3. Test the guard in both directions. One input it must catch, and one it must leave alone. With a backspace in the pattern, the first test below fails, which is exactly what you want from it:
      import { test } from 'node:test';
      import assert from 'node:assert/strict';
      
      const FORBIDDEN = /\bagents?\b/i;
      
      test('the guard catches a forbidden word', () => {
        assert.match('Built by our agents in a weekend.', FORBIDDEN);
      });
      
      test('the guard leaves clean text alone', () => {
        assert.doesNotMatch('Pick a character and make it yours.', FORBIDDEN);
        assert.doesNotMatch('A chemist mixes a reagent.', FORBIDDEN);
      });
    4. Break the code once on purpose. Plant the thing the guard forbids, watch it go red, then take it back out.
    5. When a script writes code, keep backslashes out of nested strings. Use a raw string, or the editor directly. Regex literals avoid one layer of escaping.
    6. Distrust a surprising zero. If a count, a match or a test result is suspiciously clean, count it a second way.

    The first lab

    This lab is about checking what an AI agent says worked. The other is about recovering when one damages something: an agent blanks your files, and you get them back. Both come down to the same line from that postmortem: a check only proves what it compares.