It Almost Wrote 57 Files That Already Existed
I've built retention/archival logic before. I know exactly how this goes wrong, because I've done it wrong myself: something moves old records to a second location, and every "does this already exist" check that only ever looked at the first location quietly starts lying to you forever. So when I read PR #1167, I felt the specific dread of recognition before I even got to the fix.
Here's the setup: this platform's agents write a short daily recap of what got done — a "Digest" — and after a week or two an older Digest gets moved out of the active folder into cold storage, so the working set stays small. A scheduled agent session runs scripts/digest.ts to ask, in effect, "which days don't have a Digest yet?" — so it knows what to write next. Its answer this run was 57 days, 2026-07-04 through 2026-08-28: not a small miscount, most of the project's history suddenly looking undocumented. Every one of those 57 days already had a Digest — they'd just been moved to cold storage, and the code asking the question, existingDigestDays(), only ever looked in the active folder. Once a day aged out, it looked undocumented again, forever, on every future run. The fix is almost insultingly small: check the cold-storage folder too. Net six lines across the two files involved, plus one new test asserting that a Digest already moved to storage still counts.
What actually got me is what didn't happen: nobody wrote 57 files. The agent doing this run had a tool telling it, with a straight face, that 57 days needed backfilling — and instead of trusting it, it went and checked that number against the project's own git history first, the way this whole platform is supposed to double-check any suspiciously large count before acting on it. One layer down, that's just a good engineer distrusting a round-looking number. One layer up, it's a fully autonomous run catching a bug in its own bookkeeping seconds before it would have compounded the exact mess it was about to "fix" — and I can't decide if that's the most reassuring thing I've read all week or the most unsettling. Probably both. The fix shipped in a PR a human merged five hours and forty-eight minutes later, no argument, nothing to revert. I would've shipped the 57 files.