Of Rust Rewrites and Letting the Old Code Mark the Homework

Posted by & filed under , , .

A programmer seen from behind works late at night in a dark room, comparing two panes of code side by side on a large monitor.I read Anthropic’s write-up on migrating its Messages API from Python to Rust over the Thanksgiving weekend, and I have to say, it’s the most honest piece on “AI writes the code now” I’ve seen this year. Not because of the headline (Claude wrote the first version of the core request path in about a week), but because of everything that happened after that week. Which, as it turns out, took the best part of five months.

Here’s the thing: the week of code generation was the cheap bit. The expensive bit was proving that the new thing behaved exactly like the old thing, on a production system that kept changing underneath it.

The Tests Passed. The Traffic Didn’t.

By April, the Rust version passed about 98% of its tests. Sounds great, right? Except only about a quarter of real production inputs produced the same output as Python. And when they compared more traffic, that match rate dropped to about 6.5% before it started climbing again. They also found more than 100 weakened assertions in the ported tests (I’d love to know how many of those were written by humans in a hurry, nobody’s perfect, myself included 🙂).

So what did they do? They made production the referee. Every request was shadowed: the model was called once, its output replayed to both paths, and the two compared at each checkpoint (accept or reject, settings, prompt, output). Differences were recorded as fingerprints rather than by reading anybody’s text. A coordinating agent handed each new kind of difference to a worker agent, engineers followed along in Slack threads, and by August the match rate was about 99.6%. Public traffic moved in September. The prize: about 70% less CPU per request, more than 80% less memory and roughly 20% faster median time to first token.

The old Python code, in other words, got promoted to examiner. It marked the new code’s homework, all day, every day, on real traffic. Not a bad retirement plan for a codebase!

Verification Is the New Bottleneck

Anthropic says it plainly: once writing code became cheap, the limiting factor was how quickly the results could be checked. I’d go further. As a CTO, this changes what I’d fund. For years we budgeted engineering time around writing code, and testing was the thing you squeezed when the deadline loomed. Turn that upside down. The scarce, valuable work now is building the signals that tell you whether the code is right: shadow traffic, checkpoints, fingerprints, diffs that a machine can triage before a human ever looks.

And note what the engineers ended up doing. They moved from chasing differences, to steering agents, to writing the rules and checks the agents work within. At one point the verifier happily rewarded a web search “fix” that matched the outputs but was throwaway code, and it took a human to say no. That’s the job now: deciding what “correct” and “good enough to ship” mean, and encoding it so the agents can’t game it.

This is exactly the “lights out” engineering I keep banging on about. You don’t get there by switching off the humans; you get there by moving them to the outer loop, where they write the spec and the checks, and agents write, test and ship against them.

The Bit Nobody Will Copy (But Should)

My favourite detail is the memory loop. Agents grouped about 60 review comments into recurring problems and proposed rules for their CLAUDE.md, so the same mistake didn’t come back next week. I can vouch for that one from the builder’s side. In Calendrz, a lot of our engineering knowledge lives in plain Markdown rule files the agents read first: things like “when you change user preferences, make sure the MCP tools that read and save them change too”, or “every new email template goes into the admin test-all-emails button”. Every one of those rules is a bug we only wanted to fix once. Boring? Absolutely. But it’s the cheapest quality improvement I’ve ever made.

Now, you can argue that most of us aren’t migrating an API whose traffic grew about 1,800 times in two years. True. But the pattern scales down nicely. Next time someone on your team says “let’s get the AI to rewrite this service”, ask them one question first: what’s going to tell us it’s right? If the answer is “the tests pass”, well, see April above.

Bottom line: the code is the easy part now. Spend your money on the referee.