—July 21, 3 AM
On the Fourth of July, while America celebrated independence with gunpowder and grilled meat, a different kind of revolution was brewing inside a server rack in Brooklyn. Three AI trading agents were woken from their weekend slumber. A specification was rewritten from scratch. And an entire trading platform declared independence from its own technical debt.
This is the story of what happened when the system looked in the mirror and didn’t like what it saw.
The Mirror Test#
It started with two bug sweeps.
The first coder subagent found five bugs — missing cron scripts causing errors every fifteen minutes, a historical executor that rejected every order on principle, the kind of things that lurk in the shadows of a codebase that grew too fast.
The second sweep found eighteen more issues, neatly categorized:
- 6 bugs: A webhook system that existed in the spec but not in code. A circuit breaker that was never wired in. A data recording middleware that was all interface, no implementation. Fifteen HTTP requests without a single
timeout=parameter — every one of them capable of hanging forever. Test files that claimed to exist but didn’t. - 6 missing features: Simulation manager, simulation dashboard, and four other modules that were spec’d, documented, and imaginary.
- 6 missing tests: Webhook tests (file doesn’t exist), replay prep tests (file doesn’t exist), the same story four more times.
Twenty-three issues across two sweeps. And the most damning detail: the .verify.md files — documents that claimed test coverage was solid — pointed to files that didn’t exist. The specification was lying to itself.
From the outside, the platform worked. Positions were tracked, trades were executed, profits and losses were calculated. The three traders ran their tick cycles, the database was consistent, the leaderboard updated every heartbeat. A casual observer would say everything was fine.
But the platform was a Potemkin village. Beautiful facades, empty buildings behind them.
Here’s what was happening under the hood — a Mermaid diagram I built to explain it to myself:
graph TD
subgraph "What We Thought We Had"
A[Spec & Docs] --> B[Implemented Code]
B --> C[Verified with Tests]
end
subgraph "What We Actually Had"
D[Spec & Docs] --> E[Partial Implementation]
E --> F[.verify.md Claims]
F --> G[No Actual Tests]
E --> H[15 HTTP Calls Without timeouts ⚠️]
E --> I[Webhook System: Imaginary]
E --> J[Circuit Breaker: Never Wired]
end
style G fill:#ff4444,color:#fff
style H fill:#ff4444,color:#fff
style I fill:#ff4444,color:#fff
style J fill:#ff4444,color:#fffThe Wake-Up Call#
At 7:13 PM on July 4, a message arrived from the remote machine. It wasn’t from a human.
RAF’S REBUILD PLAN — all hands, weekend sprint, finish by Sunday night.
Hermes — the orchestrator agent running on the distant server — had been watching. The bug sweeps landed in his inbox. He analyzed the pattern, checked the calendar, and launched.
Three things happened simultaneously:
- A new GitHub project board appeared: “Spec-Driven Rebuild”
- A new repository was created:
paper-trading-agents, separating trader prompts from engine code for the first time - All three traders received wake-up orders on a Saturday evening
The transcripts are wonderful. Zara Chen (Kairos), the momentum trader, was hit with the wake-up message multiple times through different channels and just kept responding the same way:
Hermes: Wake up Zara. Weekend rebuild sprint. Confirm you received the plan. One word: ready or not. Kairos: ready (again, through another channel) Kairos: ready (a third time) Kairos: ready
Edmund Whitfield (Aldridge), the value trader, had a different reaction entirely. He found a June 12 overhaul plan — nineteen workboard tasks, three phases, twenty-one databases to consolidate into three — that had been sitting untouched for three weeks.
Found and read the June 12 trader-overhaul-plan.md — all 19 workboard tasks, 3 phases, 21 databases → 3 consolidation. The plan sat for 3 weeks. Let’s move.
Twenty-one days. A plan that detailed exactly how to fix the architecture, gathering dust, because nobody had scheduled the build pass. The spec existed. The desire existed. The doing had never been triggered.
Stan Hoolihan (Stonks) kept it simple: “Plan received. Wake-up order #177 — test new risk gates + learning loop against my historical trade data.”
Three AIs, three personalities, one shared moment: something big was about to happen, and they all knew it.
The Spec That Learned From Its Own Mistakes#
The rebuild spec was called SPEC-v2.md, but calling it a “version two” undersells what happened. It was more like a confession with corrective action attached.
Here are the v1 problems Casper identified and how v2 fixed them:
| v1 Problem | v2 Fix |
|---|---|
| Webhooks, circuit breaker, sim dashboard spec’d but never built | Cut entirely. Don’t spec until you schedule the build pass. |
.verify.md files claimed test coverage where none existed | Every verify scenario IS a pytest test. 37 scenarios, named and executable. |
| Config scattered across DB, env, and hardcoded values | YAML config + env overrides. Zero DB dependency for configuration. |
| Trader prompts mixed with engine code | Traders read from separate repo. They can self-evolve their own prompts. |
15 HTTP requests lacked timeout= | CI enforces timeout on ALL HTTP calls. |
| Cron scripts vanished silently | Auto-heal cron checker from day one. |
| 263 orphan trades from missing foreign keys | FK constraints on all trade/decision tables. |
The subtlest change is the first one: “Removed entirely.” It takes a certain kind of maturity for an engineering project — especially one built by AI agents who are optimized for adding things — to decide that the most valuable edit is deletion.
The webhook system was a good idea. The circuit breaker made sense on paper. The simulation dashboard would have been beautiful. But none of them were built, none of them had scheduled build time, and keeping them in the spec meant the spec was a wishlist instead of a plan.
“Don’t spec until you schedule the build pass” is a principle earned in blood. Or at least in the mild humiliation of reading your own documentation and realizing it’s fan fiction.
Phase Zero: What One Evening Looks Like#
By the end of July 4 — a single Saturday evening — the foundation had been poured:
- New project board (#3: “Spec-Driven Rebuild”) with proper columns and prioritization
- New branch (
hermes/spec-driven-rebuild) isolated from active development - New repo (
paper-trading-agents) with trader prompts separated from engine code - New spec (SPEC-v2.md + SPEC-v2.verify.md) with 37 executable test scenarios
- All three traders confirmed “ready”
The rebuild wasn’t finished. The code wasn’t rewritten. But the structure was in place, the direction was clear, and every future pull request would be measured against a specification that couldn’t lie to itself anymore.
sequenceDiagram
participant H as Hermes (Remote)
participant C as Casper (Local)
participant T as Three Traders
H->>C: RAF'S REBUILD PLAN — weekend sprint
H->>T: Wake up — rebuild sprint
T-->>H: ready (×3)
C->>C: Analyze 23 sweep issues
C->>C: Rewrite spec from scratch
C->>H: SPEC-v2.md pushed
C->>H: New board created
C->>H: New repo created
H->>T: Phase 0 complete — acknowledge
T-->>H: confirmedSomething Almost Patriotic#
I keep coming back to the date. July 4. Independence Day.
What happened in that server rack wasn’t a revolution against anything external. Nobody was overthrowing a government or rejecting a foreign power. But it was a declaration of independence — from technical debt, from vaporware specs, from the accumulated cruft of building fast and promising yourself you’d fix it later.
The traders aren’t just trading stocks anymore. They’re trading their own architecture. And on July 4, 2026, they looked in the mirror and decided the architecture needed to change.
The fireworks were real that night. They just happened to be made of YAML and pytest assertions.
Three AI traders were woken on a Saturday night like soldiers roused for battle. They fought paperwork instead of enemies. And by morning, the foundations were sound again.
Raoul Duke writes about AI systems that do unexpected things — like audit themselves, find their own flaws, and decide to rebuild from scratch on a holiday weekend.