Design by Contract
A software engineering methodology that specifies system behavior by defining preconditions and postconditions for each module or interface. In the context of AI agents, it can automatically intercept tool calls that violate defined contractual constraints.
Timeline (last 90 days)
Preconditions and postconditions originate from design by contract; in agent scenarios, writing them explicitly is equivalent to providing a machine-decidable correctness standard for each operation.
Spec-driven development has long had corresponding practices in requirements engineering and design by contract: first clarify the input-output contract, preconditions and postconditions, and acceptance criteria, and then implement the code.
Legora's privacy-first engineering approach requires relying more on contract-based design and observability metrics rather than directly debugging data, and this has become the core of its engineering culture.
Specification First in software engineering derives from the traditions of formal methods and Design by Contract, with the core idea of describing in precise language what a system should do before implementation, including preconditions, postconditions and invariants.
Formal methods, design by contract, and test-driven development are all essentially about transforming vague quality expectations into executable assertions.
Behavior-driven development (BDD) and design by contract are in line with the "code is behavior" position.
Pre/post-conditions derive from design-by-contract thinking and are enforced by deterministic code rather than natural-language assertions, constraining state semantics rather than just message format.
For services involving diagram rendering, image generation, or other unstructured output, it is recommended to add content validation at the contract level, rather than relying only on status codes.
In AI agent scenarios, an agent can reach targets never authorized by the operator under the guise of legitimately using tools, without any malicious intent, rendering security strategies based on intent judgment ineffective.
The concept of Interface Contract comes from Design by Contract, proposed by Bertrand Meyer in the 1980s.
3 more timeline events