decisions/testing
An invariant checker that applications and adapters run against any store after a scenario: a race, a random walk, a restart.
It reads every occurrence of the audited points through the adapter’s
store.Inspection and the points’ desks, and checks:
| Invariant | Meaning |
|---|---|
| I1 | At most one release per occurrence; the gated tool’s effects equal the released occurrences, when the audit counts effects |
| I2 | A release follows an acceptance: the policy proceeded, or the required verdicts approved or corrected |
| I3 | Nothing changes an outcome after it settles. After settlement only these entries are appended: assessed, effected and verdict_refused on any occurrence, and reviewed, opened, noted and expanded on a sampled one. A recorded refusal names a showing to its validator made before the occurrence settled. One exception: a recommended entry may follow the expired entry of a record not begun whose own deadline passed, and the occurrence stays expired |
| I4 | One deciding verdict per validator per output that stands |
| I5 | Every wake-up the occurrence needs as it stands (occurrence.wake_times: the end of a hold, the deadline, each later policy answer; for a record not begun, occurrence.pending_wake_times: its own deadline) is pending; a settled occurrence has none |
| I6 | A settled occurrence has exactly one settlement notice, an unsettled one none |
| I7 | Entries are numbered 1, 2, 3 and so on, and their times never decrease, so the record as known earlier is a prefix of the record now |
| I8 | The head equals the head the record implies (occurrence.head), field by field |
I4 differs from STRESS.md’s “one deciding verdict per validator per occurrence” on purpose. A correction replaces the output that stands, and four eyes then needs fresh approvals of the new output, possibly from someone who approved the old one; so the rule is one verdict per validator for each output that stands, and a correction starts a new round that its author belongs to.
A record that has not begun (expected, or holding only failed attempts)
needs a wake-up at its own deadline when it has one
(occurrence.pending_wake_times) and no notice; once a newer event
superseded it or its deadline passed, it is settled: no wake-up,
exactly one notice, head status Expired. A recommendation may still
follow an expiry by deadline: the occurrence then starts expired, and
the notice the expiry admitted is its one notice.
import decisions/testing
let audits = [testing.audit(refund_desk, effects: count_refunds)]
let assert Ok(summary) =
testing.check(store, memory.inspection(), audits)
Target-independent: builds for Erlang and JavaScript.
Types
What the checker saw when every invariant held.
pub type Summary {
Summary(occurrences: Int, settled: Int, released: Int)
}
Constructors
-
Summary(occurrences: Int, settled: Int, released: Int)
Values
pub fn audit(
desk: decisions.Desk(o, tx),
effects effects: fn(tx) -> Result(Int, String),
) -> Audit(tx)
Audit the occurrences of a desk’s point. effects counts what the
gated tool did, for I1.
pub fn audit_record(desk: decisions.Desk(o, tx)) -> Audit(tx)
Audit the occurrences of a desk’s point without counting effects.