SHEET-003 // dbc
Design by Contract Start — Preconditions & Postconditions
Foundational Design-by-Contract cheat sheet pairing YAML/TOML invariants with pure-Rust falsifiable assertions and boundary checks.
Verified Companion Code
pub fn bounded_ratio(num: f64, den: f64) -> Result<f64, &'static str> {
if den <= 0.0 { return Err("precondition: den > 0"); }
let out = num / den;
if !out.is_finite() { return Err("postcondition: finite"); }
Ok(out)
}
sheet.contract.toml
[sheet] id = "SHEET-003" topic = "dbc-start" invariants = ["precondition-checked", "postcondition-checked", "zero-panics"]
Verified Output & SHA-256 Receipt
$ pv validate sheets/dbc-start/contract.yaml --test pv: SHEET-003 CONFORMS (precondition + postcondition invariants verified)