An AI agent proposes an action on a shipped order. guardAction(world, action)
checks it against the model and returns ok or the violated rule — before it executes.
Scenario
Money always carries its currency. The library refuses to add across currencies, splits a total without losing a cent, and rejects nonsense conversion rates — each is Invariant 1 in action.
Operation
The Commitment lifecycle is a real state machine — 11 states, 26 legal transitions.
Click a state to select it, then click another to ask the library
isValidCommitmentTransition(from, to). Green edges exist; a red flash means the model forbids it.
Reversals aren’t backward edges: a refund is a new forward-moving commitment, not
Fulfilled → Accepted. That’s why the backward moves are rejected here — and why the agent guardrail can trust the lifecycle.
Compose an order with the order() builder, then audit it. A history-complete, single-currency
order audits clean; mixing currencies or omitting a party is returned as a result you handle — never a broken object.