Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
324 changes: 324 additions & 0 deletions verification/squabble-creusot/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions verification/squabble-creusot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ creusot-std = { version = "0.14", optional = true }
# Only for the stable-Rust mirror tests, which check that the model in
# `src/model.rs` agrees with the real implementation in `squabble-core`.
squabble-core = { path = "../../crates/squabble-core" }
serde_json = "1"
60 changes: 60 additions & 0 deletions verification/squabble-creusot/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,63 @@ pub fn after_admission(passed: u32, skipped: u32, total: u32, admitted: bool) ->
let _ = admitted;
passed as u64 + skipped as u64 == total as u64
}

// ---- PR verdict (S4; design 3.6 properties 3 and 5) ---------------------------
//
// These state to the prover the per-check facts the derivation in
// `squabble_core::verdict` conditions on. They are a *model* of that function
// (see `crate::model`), not a proof of it: the mirror tests in `model.rs` are
// what tie the model to the real code, and docs/CREUSOT.adoc records what has
// and has not been discharged.

/// Property 3 (no blame for the base), per check: a failure the base already
/// carries -- inherited at the base tip, or cured on it -- is never *introduced*
/// by the PR.
#[requires(!(tip_pass && tip_fail))]
#[requires(head_fail && (cured || (tip_fail && inherits)))]
#[ensures(!result)]
pub fn no_blame_for_the_base(
head_fail: bool,
cured: bool,
tip_pass: bool,
tip_fail: bool,
inherits: bool,
) -> bool {
head_fail && !cured && (tip_pass || (tip_fail && !inherits))
}

/// The same statement from the other side: a check is introduced exactly when
/// it fails on the head, is not cured, and the base tip either passes or fails
/// with a signature the head does not inherit.
#[ensures(result == (head_fail && !cured && (tip_pass || (tip_fail && !inherits))))]
pub fn introduced(
head_fail: bool,
cured: bool,
tip_pass: bool,
tip_fail: bool,
inherits: bool,
) -> bool {
head_fail && !cured && (tip_pass || (tip_fail && !inherits))
}

/// Property 5 (infra is never PR-BROKEN, except the ruled start failure): the
/// result can only be true for a start failure the PR's own workflow edit caused.
#[requires(kind <= 4u8)]
#[ensures(result ==> kind == 0u8)]
#[ensures(result ==> edits_workflow && starts_on_base)]
#[ensures(result == (kind == 0u8 && edits_workflow && starts_on_base))]
pub fn pr_broken_by_infra(kind: u8, edits_workflow: bool, starts_on_base: bool) -> bool {
kind == 0u8 && edits_workflow && starts_on_base
}

/// Billing, runner, rate-limit and timeout failures are never the author's,
/// whatever the diff touches.
#[requires(1u8 <= kind && kind <= 4u8)]
#[ensures(!result)]
pub fn other_infra_is_never_pr_broken(
kind: u8,
edits_workflow: bool,
starts_on_base: bool,
) -> bool {
kind == 0u8 && edits_workflow && starts_on_base
}
Loading
Loading