Why we write agent-built backends in Rust.
Agents write most of the code at Factory Zero, so the useful question about a language is what it refuses to build. Rust refuses a lot. Type errors, missing cases, unsafe memory access and, in our setup, a backend whose parts do not fit together all fail before anything is deployed. The compiler does not get tired on the twelfth repository, and an agent cannot argue with it.
By Nick van der Meij · Published
Listen to this post
In short
- Our shared backend base, the Cratefield harness, is Rust compiled to WebAssembly for Cloudflare Workers.
- Unsafe code is forbidden across the whole workspace, and CI rejects any compiler or linter warning.
- A venture whose modules do not fit together is refused when it is assembled, and the tests run that check before any deploy.
- Rust does not catch wrong logic. Tests, a conformance kit and smoke tests on the live worker cover that.
§1 · DECISION
We threw away a TypeScript version in a day.
The first harness was TypeScript. It was designed and built on 5 September 2026, reached a passing foundation pull request, and was discarded before the day ended. The decision record is short and not flattering: our own projects were Rust, and TypeScript had come along as somebody else's default.
So the choice began as consistency. What we have learned since is why it suits a company where agents write the code, and that is the subject here.
§2 · COMPILER
The compiler does the review a person would skip.
An agent working in a dynamic language can produce code that runs, passes the test it also wrote, and fails on the first unusual input. In Rust a large share of those failures never get that far. A value that might be absent has to be handled. A new variant of an enum breaks every match that forgot it. A function that can fail says so in its type.
We tightened this further in the workspace settings, which apply to every crate in the harness:
[workspace.lints.rust]
unsafe_code = "forbid"
unreachable_pub = "warn"
unnameable_types = "warn"
[workspace.lints.clippy]
all = "warn"
pedantic = "warn"
Unsafe code is forbidden outright. Everything else is a warning, and CI treats warnings as errors, so nothing merges with one. An agent that reaches for a shortcut gets a build failure with the line number and, most of the time, the fix.
This is the loop that makes agents productive in Rust: write, run the check, read the error, repair. Nobody has to be in it.
§3 · COMPOSITION
A backend that does not fit together is refused.
A venture's backend is one file that names its modules and the services behind them:
Harness::builder()
.venture(Venture::new("factory0", "factory0.ventures"))
.module(EmailSignup::new().double_opt_in(true))
.module(Waitlist::new())
.runtime(Cloudflare::new()
.db("DB")
.mailer(Resend::from_env())
.captcha(Turnstile::from_env()))
.build()?
The last line is the check. If a module needs something the runtime does not provide, build() returns an error. If two modules claim the same table or the same route, it returns an error. Every venture runs that call in its test suite, so a backend that does not fit together fails before it is deployed. The worker that comes out contains the listed modules and nothing else: there is no plugin loading at run time.
Modules also never touch a vendor directly. A module asks for a database, a mailer or a captcha check. An adapter answers. An agent writing a module cannot reach an environment variable or a Cloudflare binding from inside it, because the code to do so is not in scope.
§4 · UPGRADES
On upgrade day, the compiler writes the to-do list.
The strongest case for Rust showed up in maintenance. When the shared base changes an interface, every venture that depends on it stops compiling at exactly the places that need attention. The agent doing the upgrade does not have to guess what broke. It reads the errors.
We used that on 16 November 2026 to move 13 production workers to a new release in one afternoon. The account of that day is in AI made building software cheap. Maintaining it is the hard part.
§5 · LIMITS
What Rust does not catch.
Code that compiles can still be wrong. A sign-up handler that stores the wrong address is perfectly typed. An access check that is missing is not a type error. Veracode's October 2026 tests found that 38% of AI code tasks produced a vulnerability, and most of those were injection and input-handling flaws, which a compiler does not judge.
- 01CompilerTypes, missing cases, values that might be absent, any unsafe code
- 02LinterShortcuts and sloppy patterns. A warning fails the build in CI
- 03Assembly checkModules that do not fit the runtime, or that claim the same table or route
- 04TestsWrong behaviour: the conformance kit, on SQLite and on Postgres
- 05Smoke testA deploy that built and passed, and still does not answer on the live worker
So the compiler is the first gate and not the only one. Each module runs against a shared conformance kit. Module tests run on both SQLite and Postgres. Every production deploy is followed by a smoke test against the live worker.
There is a cost as well. Rust builds are slower than most, and the language is harder to read for someone who has not used it. For a base that twenty companies depend on, we take that trade. For a weekend prototype we would not insist on it.
QUESTIONS
Questions people ask about this.
- Is Rust a good language for AI coding agents?
- For code that has to be maintained, yes. The compiler gives an agent a precise error and usually a suggested fix, so the write, check and repair loop converges without a person in it. The price is slower builds and a harder language for people who do not know it.
- Does Rust make AI-generated code secure?
- It removes whole classes of fault, such as memory errors and data races in safe Rust. It does not check that the code does the right thing. Veracode's October 2026 tests found 38% of AI code tasks produced a vulnerability across the languages it covers, and those are mostly logic and input-handling flaws that a type system does not see.
- Can Rust run on Cloudflare Workers?
- Yes. The harness targets Workers through workers-rs, which compiles Rust to WebAssembly. The same crates also build as a native binary for a server.
- Did you try anything else first?
- The first version of the harness was TypeScript. It reached a passing foundation pull request on 5 September 2026 and was discarded the same day. The decision record says why: our other projects were Rust, and TypeScript had been carried over as a default from elsewhere.
SOURCES
Where the numbers come from.
- ADR 0000: The harness is written in Rust, Cratefield, 5 September 2026.
- ADR 0003: Compile-time composition, Cratefield.
- Workspace lints in the harness Cargo.toml, Cratefield.
- Veracode Finds First Meaningful Gain in AI Code Security Since 2025 as Average Pass Rate Hits 62%, Veracode, 29 October 2026. Veracode sells security tools, and these figures come from its own tests.
- SWE-CI: Evaluating Agent Capabilities in Maintaining Codebases via Continuous Integration, Chen et al., March 2026.
KEEP READING
- 01AI made building software cheap. Maintaining it is the hard part.An agent can write a working backend in an afternoon. Keeping it patched and secure is the real cost. How one shared base keeps our ventures maintained.
- 03One shared base, private code on top: who maintains what.A venture built on Factory Zero has two kinds of code. The shared base is maintained once for everyone. The private part stays yours. Where the line runs.