Verification engineering is the work of writing machine checks that prove a system is correct. When AI agents write most of the code, these checks replace line-by-line human review. For systems with many states, the strongest check is a formal model such as a TLA+ specification. A model checker tests the model against every reachable state.

Shopify CEO Tobi Lütke made this case on David Senra's podcast on November 22, 2026. This post explains his method in steps. It adds what AWS, MongoDB, and Datadog have published about TLA+ in production. It also shows where AI still falls short.

What Lütke said

Lütke said that most engineering work at Shopify has become "what we call, for lack of a better term, verification engineering".

He defined it as "creating acceptance tests: here's how you know for sure that the thing that exists, the thing that was created, is good."

He went further on formal methods. In his words, "the field of formal verification is now by far the most important field in engineering".

His reason: "you can prove that a system is correct. This is extremely important for complex systems."

He described a sequence that any team can run on its own code with a coding agent:

  1. Ask the agent to "find all the implicit state machines in this codebase" and make them explicit.
  2. Ask it to "make a TLA+ model for it to make sure that all the cases are specified."
  3. Run a security scanner. He named Vercel's deepsec, which we covered in AI vulnerability hunting.
  4. Rebuild the code against the formal model, unit tests, and production traffic, in a safer language such as Rust.

He said this finds "a thousand bugs in any codebase we've ever pointed it at".

He also predicted that "we probably have to replace all human code running in production on planet Earth within the next 6 to 12 months." His reasons were security and a coming shortage of compute.

Why code review stops working

For 20 years, the software industry optimized for developer productivity. Frameworks such as Ruby on Rails hide hard work behind abstractions, so one engineer can do the work of many. Abstractions also keep code short, so a person can read a change in review.

Lütke's point is that agents change both sides of this trade:

  • Agents write far more code than people can review. Shopify now merges pull requests at "10 to 100 times" its old rate, by his account.
  • Agents do not need abstractions to be productive. They can write long, direct code that is correct for one job.
  • Agents work well with strict rules. Linter rules that engineers find oppressive give an agent exact feedback. In his words, "They love rules, but not abstractions."

He called code review a human-run, weaker version of formal verification. When the volume of code grows by 10x or more, the review has to move to something a machine can run on every change. Our post on legacy modernization shows the same pattern in Airbnb, Google, and Salesforce migrations. Writing the code got fast. Proving the behavior became the cost.

What an implicit state machine is

A state machine is a list of states and the allowed moves between them. Most business software has state machines that nobody wrote down. The state lives in separate flags, columns, and if-statements in different files.

Here is a simple example with an order:

  1. The orders table has three yes/no columns: paid, shipped, and refunded.
  2. Three columns allow 2 × 2 × 2 = 8 combinations.
  3. Only 5 are valid: created, paid, shipped, refunded before shipping, and refunded after a return.
  4. Three are invalid: shipped but not paid, refunded but not paid, and shipped and refunded but never paid.
  5. The payment service sets paid. The warehouse service sets shipped. The support tool sets refunded. No single place checks the combination.
  6. A webhook retry, a race between two workers, or a support action on the wrong order can reach an invalid state.

The explicit version is one status field with 5 values and a table of allowed moves. A refund is allowed from "paid" or "shipped". A shipment is allowed only from "paid". Every other move is rejected.

Check What it proves Where it fails
Unit tests The code works for the inputs you wrote Inputs and orderings you did not think of
Type checks and linter rules The code has the right shape and follows house rules Wrong business logic in well-typed code
Code review A person read the change Volume, and bugs that need many steps to appear
TLA+ model checking Every reachable state of the design obeys the rules Code that does not match the design
Tests generated from the model The code does what the model allows States beyond the model's limits
Runtime monitors Production behavior matches the model Problems that the monitored rules do not describe

How TLA+ checks every state

TLA+ is a specification language created by Leslie Lamport. A TLA+ spec has three parts:

  1. States. The variables of the system, such as each order's status and each worker's queue.
  2. Steps. The actions that change state, such as "pay", "ship", "refund", "retry webhook", and "worker crashes".
  3. Rules that must always hold. For example, "an order is never shipped unless it was paid" and "the refunded amount never exceeds the paid amount".

The TLC model checker then explores every reachable combination of states within the limits you set, such as 3 orders and 2 workers. If any sequence of steps breaks a rule, TLC returns the shortest such sequence. This is called a counterexample trace. The team then fixes the design or the rule and runs TLC again.

Tests check the orderings that someone wrote. TLC checks all of them. This matters most when several actors change shared state at the same time, as with retries, crashes, and concurrent workers.

AWS published its results in How Amazon Web Services Uses Formal Methods (Communications of the ACM, 2015). From Lamport's excerpt of the paper:

  • Amazon engineers had used TLA+ on 10 large production systems. By the time the paper was printed, the number was 14.
  • In DynamoDB, the model checker found a bug where "the shortest error trace exhibiting the bug contained 35 high-level steps." The bug "had passed unnoticed through extensive design reviews, code reviews, and testing."
  • "Engineers from entry level to principal have been able to learn TLA+ from scratch and get useful results in two to three weeks."
  • The models gave engineers the confidence "to make aggressive performance optimizations without sacrificing correctness."

A 35-step bug is the kind that no person finds in a code review. It is also the kind that happens in production at scale.

Keep the code matched to the model

A TLA+ spec checks the design. The code can still differ from the design. Two companies have published ways to close that gap.

MongoDB generates tests from the spec. MongoDB wrote a TLA+ spec for the array merge rules in its mobile sync engine. That code is about 1,000 lines of C++. The model checker found 30,184 states and 4,913 distinct behaviors. MongoDB turned each behavior into a C++ test. In MongoDB's write-up, "These 4913 tests immediately achieved 100% branch coverage".

The tests also found an infinite-recursion bug, and the team removed the operation that caused it.

Branch coverage of MongoDB's array merge codeHandwritten testsHandwritten tests: 21%21%AFL fuzzingAFL fuzzing: 92%92%Tests generated from specTests generated from spec: 100%100%4,913 tests generated from the TLA+ spec's behaviors (30,184states).
CHARTBranch coverage of MongoDB's array merge code. Source: MongoDB Engineering, "Conformance Checking at MongoDB" (2025).

MongoDB also tried the opposite direction, which is to log the server's real steps and check them against the spec. That attempt failed after 10 weeks. The spec was too abstract, and multithreaded state was hard to capture. The lesson is to write the spec at the level of detail that you want to check.

Datadog checks production against the spec. In November 2026, Datadog described continuous formal spec validation for Husky, its event database. Its tool turns TLA+ rules into runtime monitors. A monitor on the placement storage found conflicting placements that a deduplication change had introduced about a year earlier. Those conflicts could have crashed the backfill system during a recovery.

These two methods are what make an agent rewrite safe. The agent writes new code. The generated tests and monitors decide if the new code matches the model.

Can AI write the TLA+ spec?

Not reliably on its own yet. Three 2026 studies from the same research group measured it:

  • TLA+-Bench (July 2026) uses 403 specs that the model checker can run. The strongest model was correct 16% of the time, and 26% when the prompt included the spec's interface names. Open models scored at most 1%.
  • Can LLMs Write Correct TLA+ Specifications? (June 2026) tested 30 models. They reached up to 26.6% syntactic correctness but only 8.6% semantic correctness.
  • ALIAS (October 2026) renamed identifiers to test memorization. Claude Opus 4.8 dropped from 28% to 18%, but most of that drop came from grading that requires exact names. With behavior-based grading, the drop was about 3 points.
LLM-written TLA+ specs that pass the model checkerStrongest modelStrongest model: 16%16%Strongest model + namesStrongest model + names: 26%26%Best open modelBest open model: 1%1%"+ names" means the prompt included the spec's interface names.
CHARTLLM-written TLA+ specs that pass the model checker. Source: Bisharat et al., "TLA+-Bench", arXiv 2607.23425 (July 2026).

These benchmarks ask a model to write a spec from a description in one try. Lütke's method is different. The agent reads the real code, drafts the model, runs TLC, and fixes errors in a loop. The model checker rejects a wrong spec every time, so the agent cannot talk its way past it.

Martin Kleppmann made the same argument in AI will make formal verification go mainstream (December 2025). He wrote that "the proof checker will reject any invalid proof and force the AI agent to retry".

He also named the limit: "the challenge will move to correctly defining the specification."

The cost of proofs used to block this work. Kleppmann notes that the seL4 kernel had 8,700 lines of C and needed 20 person-years and 200,000 lines of proof. Agents cut the cost of writing models and proofs. They do not decide what the business rules are. A person who owns the process must review the rules, and those rules are far shorter than the code. For proofs of individual functions, see our post on formal verification for AI agents.

The rebuild loop

The verification engineering loopExisting codebaseflags and if-statements spread across filesagent searchExplicit state machinesstates, allowed moves, and rulesperson reviews the rulesTLA+ model checked by TLCeach counterexample fixes a bug, the model, or a ruleTests generated fromthe modelRuntime monitorsagents write code until all checks passNew implementationoften in a safer language such as RustSecurity scanShip behind monitors
DIAGRAMThe verification engineering loop
  1. Find the state machines. Ask a coding agent to list every status, flag, and lifecycle in one service, with the file and line where each one changes.
  2. Write the rules. For each state machine, write the valid states, the allowed moves, and the rules that must always hold. A person who owns the business process reviews this list.
  3. Model and check. The agent writes a TLA+ model that includes retries, crashes, and concurrent workers. TLC checks it. Every counterexample trace is either a real bug or a wrong rule.
  4. Generate the checks. Turn the model's behaviors into tests, as MongoDB did. Add runtime monitors for the most costly rules, as Datadog did.
  5. Add strict rules. Add linter rules and type checks for your house rules. Agents follow them without complaint.
  6. Rewrite. Let agents change or rewrite the code until every check passes. Lütke's choice for a rewrite is a memory-safe language such as Rust.
  7. Scan and ship. Run a security scan, ship behind the runtime monitors, and compare old and new behavior on real traffic before cutover.

Lütke said a working agent setup turns a Friday decision into production code on Monday. He rebuilt Shopify's internal source repository host over a weekend to keep up with the higher merge rate. That speed depends on the checks in steps 2 to 5. Without them, a fast rewrite is a fast way to ship new bugs.

Where TLA+ pays and where it does not

Use TLA+ for Use other checks for
Checkout, payments, and refunds Page layout and copy
Order, inventory, and fulfillment status Model answer quality (use evals)
Entitlements, subscriptions, and billing cycles Single pure functions (use unit tests or proofs)
Approval workflows and AI agent tool flows Reports and dashboards
Queues with retries, idempotency, and locks One-off scripts

The common factor is shared state that several actors change, where a wrong state costs money or trust. Our post on two agents and one record shows the kind of race that a TLA+ model catches before it ships.

How to start

  1. Pick one service where a wrong state has cost money in the past year, such as refunds or order status.
  2. Ask a coding agent to list its implicit state machines. Count the flag combinations that are possible but not valid.
  3. Write the rules with the business owner. Keep them to one page.
  4. Have the agent write a TLA+ model and run TLC with small limits, such as 3 orders and 2 workers.
  5. Triage every counterexample. Fix real bugs in the current code first.
  6. Generate tests from the model and add them to CI. Measure branch coverage before and after.
  7. Only then let agents refactor or rewrite the service.

How OpenNash helps

OpenNash puts forward-deployed engineers on your team to build verified AI engineering workflows that run in production. We work with Fortune 2000 companies. A typical engagement follows these steps:

  1. Review your systems and incident history. Find the services where a wrong state costs the most, which give the highest business value and the fastest ROI.
  2. Get the data ready: the business rules, process owners, logs, and past incidents that the models and checks need.
  3. Map the implicit state machines and write the rules with your process owners.
  4. Build the TLA+ models, generated tests, and runtime monitors, and add them to CI.
  5. Run agent refactors and rewrites against those checks, with human approval for every merge.
  6. Train your engineers to own the models, rules, and agent workflows.

Book a call with an OpenNash forward-deployed engineer, or email [email protected]. In the first session, we review your top AI use cases and data and show which ones give the highest business value and the fastest ROI.