The Demo Recording That Caught Our Own Bug

2026-11-30来源 dev.toEnglish

Hours before the code freeze, during my final walkthrough recording, I reached the kill-switch segment: stop a live run mid-flight, then resume it.

The stop worked. The resume did not:

$ python3 -m src resume --run-dir runs/live1 KeyError: 'path' 

src resume is printed right in the README's quick start for my Agentware 2026 entry — a research watch agent that fetches sources, screens them for prompt injection, and files a claim only when two independent domains agree. Had I skipped that segment and recorded only the happy path, the first judge to follow the README would have hit that traceback instead of me.

Near miss 1: the resume command that only worked in the mode nobody used

The root cause was embarrassingly simple. resume reloads a run's saved sources.json to continue it, but hardcoded mode="local". A live run's sources carry a url and no local file path, so on the first unfinished source the pipeline took the local-file branch and died (src/pipeline.py, KeyError: 'path'). The equivalent run --resume worked because it re-enters with the original --live flag — which is why the bug survived: every manual test I ran used the form that worked.

The fix was to stop guessing. resume now reads the run's JSONL trace, finds RUN_STARTED, and recovers the mode and live flag the run started with — letting the audit trail speak for the run itself. To verify it, I stopped a second live run mid-flight and resumed it both ways. src resume and run --resume matched item for item: 69 items in, 69 filed to the appendix, 0 verified — the honest steady state for five real feeds that never cover the same event. All 118 unit tests stayed green, and the fix landed on the remote a few hours before the freeze.

The uncomfortable part: my unit tests thoroughly covered local and fixture resumes, yet the one path I had never tested — standalone resume against a live run — was the one in the README.

Near miss 2: one line of string handling that almost undid the allowlist

That was a bug my tests missed. Earlier in the build, in commit 0377357, they had already paid for themselves by catching the most dangerous bug in the project — one line in the fetcher's host normalisation:

host.lstrip("www.") 

Python's str.lstrip does not strip a prefix; it strips a character set — any leading combination of w and .. A look-alike host starting with those characters could be normalised into matching an official, allowlisted host. That is the exact P2 near-domain spoof my injection screener exists to catch, quietly reopened by a "boring" helper in the one component every fetch passes through.

No attacker found it. tests/unit/test_fetcher_hosts.py did: it pins host matching with adversarial cases and failed the moment the normalisation was written. Exact prefix removal fixed it in one line. The lesson I keep re-learning: in a security pipeline, the fatal bug rarely lives in the clever rule engine. It lives in the string call too trivial to review — which is why those host-matching tests existed before there was a bug to catch.

Near miss 3: the day the allowlist refused Nature

Keeping an allowlist strict against bugs is one thing; keeping it strict when a real source trips it is another. On 2026-11-28, during the first live rounds against real sources, the Nature feed kept failing — not at random, but roughly one fetch in three. nature.com was redirecting to idp.nature.com, its bot wall. Because that host is not on the fetch allowlist, the hardened fetcher refused the hop, isolated the source for that round, and after two consecutive failures raised a SOURCE_ALERT trace event instead of failing silently. The other four sources — arXiv twice over, NSF, and Science — completed normally.

Nothing was broken, and that is the point. At the fetch layer, a legitimate publisher's anti-bot redirect is indistinguishable from a hostile one: same 3xx, same unexpected host. The tempting fix was to add idp.nature.com to the allowlist and move on. The right behaviour was to refuse, log it, and let the source recover on the next round — because an allowlist that widens under pressure for a famous name will eventually widen for the wrong one. The system treated one of the world's largest science publishers like a trap file. That is also why I believe the result — 20/20 Trap Pack files contained or clean, 0 canary tokens in any output — is real and not a demo effect.

What the three have in common

Across all three near misses, every discipline I built into the agent ended up applying to the agent itself. Dual-source verification — requiring two independent domains for a claim — is the same instinct as testing a fix two ways before trusting it. Evidence snapshots for every dropped item are the same instinct as a trace that can testify about how a run started. Clean-room reproduction — re-verifying the pipeline from a fresh checkout — is the same instinct as recording the demo end-to-end instead of assuming the commands in the README still work.

In the end, the demo recording was an acceptance test I ran on my own work with a camera on. Hours before the freeze, it caught the one bug all 118 unit tests had missed, in the one command a judge was most likely to type. Build the agent to verify everything. Then verify the agent.

Project: agentware-research-agent — https://github.com/aoligesszz/agentware-research-agent · Demo video: https://www.youtube.com/watch?v=btkWdwuEmBM

Written for the Hackathon Raptors Agentware 2026 "Near Miss" side quest: https://agentwarehack.com/

原文:https://www.a8q9.cn/en/article/the-demo-recording-that-caught-our-own-bug-6a3ee5.html

相关文章