
A new proposal called Semantic Contracts offers a solution to the trust crisis created by rapid AI code generation. By placing a typed, compile-time-checked blueprint between requirements and implementation, the approach guarantees that any code matching the contract—whether written by a human or AI—will behave as intended. This replaces traditional code review and testing as the primary trust mechanism.
Summaries like this, in your inbox every morning.
Sign up free →What happened
A proposal introduces Semantic Contracts—a structured blueprint that sits between requirements and code to guarantee correctness of any implementation, whether written by humans or AI. The approach uses typed states, combinators (basic building blocks like Seq, Par, Batch, Race), and compile-time checks to catch errors before runtime.
Why it matters
AI-driven development has collapsed the traditional trust pipeline (Requirements → Architecture → Design → Code → Testing → Review → Deploy) into a single step: prompt to running code. Because AI behavior is unpredictable and code review cannot keep pace with AI output speed, there is a fundamental crisis of trust in AI-generated code. Semantic Contracts restore confidence by enforcing correctness by design, not by review.
What to watch
The approach uses explicit state returns (Success, InsufficientBalance, Processing, etc.) instead of exceptions, forcing developers and AI to handle every edge case before code compiles. Examples include sorting algorithms and e-commerce checkout workflows, where the contract structure itself makes certain failures impossible.
The article opens by identifying a crisis: AI writes code faster than humans can review it, and because we do not understand how neural networks with billions of parameters make decisions, we face a fundamental trust breakdown. Traditional software engineering relied on a structured pipeline with clear handoffs—Requirements to Architecture to Detailed Design to Coding to Testing to Code Review to Deploy—where each step had human ownership and oversight. The AI era has collapsed this pipeline: a user types a prompt, and the AI immediately produces running code, skipping the middle steps entirely.
This breakdown manifests in four specific ways. First, AI behavior is unknown: the same prompt can yield completely different code due to the complexity of the underlying neural network. Second, bugs are untraceable—when AI code fails, it is nearly impossible to trace the failure back to a specific design flaw. Third, fixes are unpredictable: prompting an AI to fix one bug can introduce unexpected side effects elsewhere. Fourth, code review becomes impossible at scale: humans simply cannot review code as fast as AI generates it, turning review into a checkbox exercise rather than a safeguard.
The proposal introduces Semantic Contracts as a new layer positioned between requirements and code. A Semantic Contract has three parts: a signature (input state and possible output states), a skeleton (an expression tree built from basic combinators like Seq, Par, Batch, Race, Transaction, and Timed), and capabilities (attachable behaviors such as database transactions, retries, rate-limiting, and logging). Instead of throwing exceptions, contracts return explicit states—Success, InsufficientBalance, Processing, or BlockedIf business rules are violated (such as attempting to transfer negative money), the contract returns an InvalidAmount state rather than an exception. If a parent contract does not explicitly handle a returned state, the compiler raises an error, forcing all edge cases to be handled before code can run.
The article provides two concrete examples. For sorting algorithms, the contract defines atomic operations (CheckSorted, Partition, Merge) and then structures the sort as a Seq (sequential) operation that checks if the list is sorted, divides it if not, sorts both halves in parallel using Par, and merges the results. This structure makes certain failure modes impossible. For e-commerce checkout, the PlaceOrder contract chains Payment and Inventory steps inside a Transaction combinator, explicitly enumerating possible outcomes: Success, InsufficientBalance (from Payment), InsufficientStock (from Inventory), or Failed. If a developer or AI tries to ignore these states, the compiler rejects the code.
The article argues that Semantic Contracts succeed where decades of formal verification research (Hoare Logic, Z language, Model Checking) failed because they focus on process guarantees rather than post-hoc bug-finding, avoid the need for perfect mathematical specifications, and sidestep the State Explosion Problem by using simple, composable rules that the compiler can verify. By treating business logic as a type system, Semantic Contracts allow safe composition, instant compile-time verification, and implementation swaps—any code satisfying the contract can replace any other without breaking the system. The approach bridges the gap between traditional design documents (which lack compiler validation) and raw code (which hides the big-picture design).
The article diagnoses a fundamental shift in software engineering. The traditional waterfall pipeline—Requirements through Deploy—provided multiple human checkpoints and thus a chain of trust. AI-driven development (termed "Vibe Coding" in the piece) collapses this into a single prompt-to-code step, creating four distinct trust failures: unknown AI behavior (from billions of parameters), untraceable bugs, unpredictable fixes, and the impossibility of human code review at AI generation speeds. The proposal reframes the problem not as a need to understand AI decision-making, but as a need for a new intermediate layer that makes correctness a structural property of the system itself.
Semantic Contracts draw on decades of formal verification research but reject its approach. Rather than trying to mathematically prove correctness after code is written, they enforce correctness through process guarantees—using simple, composable building blocks (combinators) with predictable rules that the compiler can verify at build time. This shifts the burden from post-hoc review to design-time structure. The article illustrates this with two examples: a sorting algorithm (where the contract structure prevents recursion errors) and an e-commerce checkout (where explicit state returns force handling of InsufficientBalance and InsufficientStock cases). The approach treats business logic as a type system, allowing safe composition, instant verification, and implementation swaps—a significant departure from the current ad-hoc tangle of if/else statements and error handling.
AI-summarized, only the topics you pick — one digest a day via Email, Slack, or Discord.
Free · takes 30 seconds · unsubscribe anytime
No discussion yet for this article
Get curated AI news from 200+ sources delivered daily to your inbox. Free to use.
Get Started FreeFree · takes 30 seconds · unsubscribe anytime
1 minute a day. The AI essentials.
200+ sources · Email / LINE / Slack