Metakit / Verify a state machine

Reading a counterexample witness

When a transition is refuted, entry.witness holds Option.some(report) with structured before (the state it started from), input, after (the state it produced, which the Schema refuses), the violated rules as text, and a reproducer string, a Transition.run call you can paste into a test where your transition is in scope. report.format() prints all five. If Withdraw above lost its Num.lte(input.amount, …) guard, it would print:

REFUTED Withdraw [PIN BROKEN]
  before:   {"balance":0,"reserved":0,"status":"open"}
  input:    {"amount":1}
  after:    {"balance":-1,"reserved":0,"status":"open"}
  violated: (((balance >= 0) && (reserved >= 0)) && (reserved <= balance))
  repro:    Transition.run(Withdraw, {"balance":0,"reserved":0,"status":"open"}, {"amount":1})

In a Vitest test, assert expect(report.ok, report.format()).toBe(true) so a failing proof prints the formatted witness directly in the test output. That assertion is how CI fails: the test goes red when any transition is refuted, undecided without a reason, or pinned and not proved.

Next