Tutorial
Verified Mutation Flows
Several mutations can share a rule: read, try an update, retry on conflict, or fail. Declare that flow once, then check whether each mutation follows it. The checker reports where a mutation’s structure diverges from the declared family.
Code & run Run the stock mutation
Write the flow once
The flow is an ordinary function whose function-typed parameters are the holes where each mutation's own steps go. Each mutation stays plain code; the checker matches it against the flow and names its parts.
def retry_flow(
observe: i -> IO[Int],
propose: (i, Int) -> Int,
reconcile: (i, Int) -> Int,
explain: (i, Int) -> Int
) -> i -> IO[Outcome]:
def run(input: i) -> IO[Outcome]:
(
current <- observe(input).flat_map()
match apply_change(
current, propose(input, current)):
case Accepted(next): commit(next)
case Rejected(_):
match apply_change(
current, reconcile(input, current)):
case Accepted(next2): commit(next2)
case Rejected(deficit):
pure(wrap_error(
explain(input, deficit)))
)
run
See where a mutation breaks the rule
Wire one argument from the wrong value and the checker says where:
Demo/Stock/withdraw at stock:192:3:
argument 2 of withdraw_explain at hole
'explain' receives 'current' where the
flow passes 'deficit'. The value the flow computes
as 'deficit' never reaches
withdraw_explain.
Matching allows renaming and naming intermediate values, not arbitrary refactoring. A seeded comparison with the composed flow is bounded observation, not proof.
Benchmark: a blind conformance census
On a 2,811-line API it had never seen, a reviewer using only the checker's facts and one reading only the source each found all 5 nonconforming mutations, 5 / 5, located, with no false accusations. Reading was 1.9× cheaper, so the round failed its cost gate. What the facts bought was standing: every answer was a claim a verifier re-checked. The full record is round 010 on the measurement scoreboard.
Try it
Ask your agent to run the flow checks on the stock.bosatsu example with the npm command line, or on mutations in your own program. It has the exact commands and what each result means.
Fact-based review: fact tooling · Measured results: tooling evals
Ask your agent about anything here; it has the detail.
Where this fits
What this is about: Checks and Proofs