← Back to AILP Home

Design by Contract Cookbook

This subsection is the canonical v0.34.7 guide for Nitpick's Design by Contract (DbC) and final-safety-net surfaces. It supersedes older scattered notes in guide/functions/design_by_contract.md, guide/verification/03_contracts.md, and the DbC portions of guide/advanced_features/verification.md where those pages are shorter or stale.

The v0.34.x cycle locked the shipped behavior of the failsafe family and DbC family:

Chapters

  1. Requires — preconditions, caller obligations, contradiction checks, and where to place boundary assumptions.
  2. Ensures — postconditions, the result pseudo-variable, downstream propagation, and result-scope diagnostics.
  3. Invariants — loop entry/back-edge obligations, purity rules, and --debug-contracts runtime checks.
  4. Prove — hard compile-time proof obligations, Z3 outcomes, --debug-z3, and ARIA-073/074 diagnostics.
  5. assert_static — CTFE assertions, runtime fallback, built-in macro compatibility, and ARIA-075.
  6. limit — Rules definitions, compile-time ARIA-076 failures, runtime assignment checks, and failsafe code 49.
  7. Failsafe workflowmain, failsafe, exit, !!!, and the v0.34.x error-code table.
  8. Z3 cookbook — solver-friendly code, reports, debug dumps, counterexamples, and when to prefer runtime fallback.

Quick mental model

Validation snapshot (v0.34.7)