Hi Forum,
Over the past year, I’ve watched engineering teams increasingly rely on AI coding agents (Cursor, Claude Code, Copilot) to write revenue-critical logic: Stripe subscription prorations, mid-cycle seat additions, multi-currency ledgers, and tax rules.
The problem is that while LLMs write this code fast, they frequently hallucinate boundary edge cases. A missing floor round or an unhandled fractional-cent division doesn’t throw a runtime error—it runs cleanly in production while silently leaking revenue across thousands of transactions. Traditional linters only check syntax and known CVEs, and unit tests written by the same LLM often share the same blind spots.
I built ProofEngine (GitHub - DaveSuri/proofengine: Deterministic symbolic execution & Z3 theorem-proving layer for AI-generated financial, billing, and Stripe code. Compiles TypeScript invariants to SMT-LIB2 to catch rounding drift, negative charges, and non-idempotent webhooks. · GitHub) to bring formal verification to this workflow as a deterministic safety gate.
How the pipeline works:
-
AST & Invariant Extraction: A local CLI parses TypeScript/JavaScript code, extracting branching control-flow paths and inline assertions (
// @proofengine:invariant total_credits + balance_due == expected_invoice_amount). -
Intermediate Representation (IR) to SMT-LIB2: The engine compiles the variable assignments, integer bounds, and conditions into First-Order Logic constraints in standard SMT-LIB2 format.
-
Z3 Solver Dispatch: We negate the invariant and query the Z3 SMT theorem prover.
-
If UNSAT: The negation is mathematically impossible; the invariant holds across all reachable states, and the engine issues a signed attestation token.
-
If SAT: A counterexample exists. In under 600ms, Z3 outputs the exact failing inputs (e.g.,
remainingDays: 1, seats: 4, drift: -4 cents) so an AI agent or engineer can self-heal the calculation.
-
We also exposed this over a Model Context Protocol (MCP) server so Cursor agents can query the solver autonomously before declaring a billing task complete.
The repo and working studio are live: GitHub - DaveSuri/proofengine: Deterministic symbolic execution & Z3 theorem-proving layer for AI-generated financial, billing, and Stripe code. Compiles TypeScript invariants to SMT-LIB2 to catch rounding drift, negative charges, and non-idempotent webhooks. · GitHub
I’d love feedback on:
-
Our SMT-LIB2 constraint formulation for multi-currency rounding and banker’s rounding.
-
Strategies for handling solver timeout boundaries when control-flow branching explodes.
-
What specific financial or ledger invariants you’ve found most difficult to enforce with standard test suites.