AI Formal Verification Went Mainstream for Me A developer shipped NotiBuddy, an Apple-only iPhone, iPad, and Apple Watch app with a Cloudflare Workers relay and a local CLI and MCP client, writing roughly 440,000 lines of product and test code across well over a thousand commits exclusively with AI coding agents, and used Dafny formal verification to check the app's relay admission, replay, billing, and screen admission policy models. The developer reported that verified Dafny models generated the TypeScript the Workers run, with CI checking both that proofs pass and that generated output stays in sync, but that formal models did not apply to most of the codebase, including SwiftUI views, SQLite persistence, and push delivery. The account tests a December 2025 prediction by Martin Kleppmann that AI would bring formal verification into the mainstream. ← All blog posts https://notibuddy.app/blog AI Formal Verification Went Mainstream for Me Formal verification isn't enough on its own, yet Dafny still paid off in an AI-written codebase. Here is what held up. Over the past several weeks I shipped NotiBuddy https://notibuddy.app/ , a native iPhone, iPad, and Apple Watch app paired with a Cloudflare Workers relay and a local CLI and MCP client. It is Apple-only for now. The multi-platform codebase spans roughly 440,000 lines of product and test code across well over a thousand commits, and I built all of it exclusively with AI coding agents. Working that way changes where the bottleneck is. Writing code gets cheap almost immediately; trusting what was written is the hard part. An agent can generate a clean, well-typed state machine and a suite of passing unit tests in a couple of minutes while leaving a subtle transition bug buried inside. Maybe a late reply reopens an expired request, or a retry collides with a cancellation. Everything looks reasonable in the diff until it breaks in production. In December 2025, Martin Kleppmann predicted https://martin.kleppmann.com/2025/12/08/ai-formal-verification.html that AI would bring formal verification into the mainstream. While building NotiBuddy, I decided to test that idea on real policy logic using Dafny. Where formal models fit, they gave me a level of confidence in AI-generated code that unit tests alone never could. Across most of the codebase, though, they either did not apply or got in the way. Why Dafny fits an AI-only workflow I had never used formal verification on a shipping product before. Proof engineering by hand is slow, finicky work, and spending an afternoon hunting for the one intermediate assertion that convinces an SMT solver to accept a sequence slice rarely makes sense on a small team. Pairing Dafny with a coding agent changed the economics of that work. Searching for intermediate lemmas and adjusting proof hints is mostly repetitive trial and error, which an agent can grind through quickly. It could revise a proof and rerun dafny verify until every obligation discharged, leaving me to check that the specification itself stayed intact. When verification fails, Dafny returns exit code 4 and points to the obligation it could not establish, whether that is a postcondition, precondition, assertion, invariant, termination check, or well-formedness check. That line is not always where the underlying bug lives, and because counterexample extraction in Dafny is opt-in and only a diagnostic hint that can be invalid, you do not automatically get a runnable failing trace. Even so, knowing which obligation failed is usually enough to keep an agent moving toward a fix. The bigger payoff was shrinking what I had to review by hand. When you are not typing the implementation yourself, reading every branch of a large generated TypeScript handler turns into rubber-stamping faster than you would like to admit. I used Dafny to verify small, pure policy models for relay admission, replay, and billing rules, as well as screen admission for Custom Native Screens https://notibuddy.app/screens , where the content-blind relay validates stripped structural templates without reading plaintext. To keep production code from drifting from the spec, the Workers call generated TypeScript derived directly from those verified Dafny models instead of a separate handwritten copy, and CI checks both that the proofs pass and that the generated output stays in sync. With codegen wired up, I could spend my review budget on the datatype definitions and the requires and ensures clauses. As long as those contracts capture the rules I want and the proof contains no unjustified assumptions, the solver checks every transition in the model for the stated properties. Liveness properties, I/O wrappers, and everything outside the model still have to be tested on their own, so I never reached for Dafny on SwiftUI views, SQLite persistence, or push delivery plumbing. A small example you can try yourself A fair complaint about formal methods tutorials is that they often verify a single function where a type checker or two unit tests would have done the job. It starts paying its rent when you care about safety properties across every finite sequence of events: retries, clock ticks, cancellations, and duplicate replies arriving in orders you never thought to test. The standalone model below is drawn from NotiBuddy’s public fail-closed approval behavior. You can toggle the preset mutations above the editor, edit any line directly and click Verify to run real Dafny 4.11.0 in a rate-limited browser sandbox, or copy gate trace.dfy to run dafny verify gate trace.dfy locally: datatype GatePolicy = GatePolicy requiresAuth: bool, deadlineMs: nat datatype SignedReply = SignedReply receivedAtMs: nat, signatureValid: bool, userAccepted: bool, biometricVerified: bool datatype Event = | Tick nowMs: nat | Reply reply: SignedReply | Cancel datatype State = | Pending policy: GatePolicy | Approved policy: GatePolicy, evidence: SignedReply | Rejected | Expired predicate Authorized p: GatePolicy, r: SignedReply { r.receivedAtMs <= p.deadlineMs && r.signatureValid && r.userAccepted && p.requiresAuth || r.biometricVerified } function Step s: State, e: Event : State { match s { case Pending p = match e { case Tick now = if now p.deadlineMs then Expired else Pending p case Cancel = Rejected case Reply r = if r.receivedAtMs p.deadlineMs then Expired else if Authorized p, r then Approved p, r else Rejected } case Approved , = s case Rejected = Rejected case Expired = Expired } } function Run s: State, trace: seq