Example
Mini-Ledger: batch admission without locks
A demo of yichus admit: given a batch of transfers, declared balance rules, and the real handler, the checker computes which subset can commit together in one write, and explains every operation it turns away.
A demo of Yichus, a research checker for programs written in Bosatsu. Committing a batch of updates to busy balances in one write is an old database idea: IMS Fast Path checked each update against a bound instead of locking the field (Gawlick and Kinkade, 1985), and the escrow transactional method (O'Neil, 1986) made it general. This applies the escrow method to invariants you declare.
Four accounts start at A 200, B 60, C 40, D 150. Every balance must stay ≥ 0, and D is capped at 200. Every result below is rerun from these sources on each deploy.
ledger.bosatsu: the domain (limits shared by guard and spec)
loading…
ledger.spec.bosatsu: the escrow declaration
loading…
ledger_handlers.bosatsu: the guarded handler
loading…
1. Escrow admission of the sample batch
The solver admits the eight transfers below in arrival order, keeping only those that no ordering of the admitted set can push past a bound, and says why it defers the rest.
batch-sample.json: the eight transfers (each entry is {"operation", "input"})
loading…
yichus admit ledger.bosatsu ledger.spec.bosatsu ledger_handlers.bosatsu \
--batch batch-sample.json --result admission.json
# exit 0 — replay verifiedGreen means admitted, red means deferred, and amber means inconclusive. Every chip also prints that verdict, so colour only reinforces the text.
Loading admission artifact…
Dig deeper: why the interval covers every ordering
Any prefix of any ordering of the admitted set debits key k by at most the sum
of all admitted debits on k, and credits it by at most the sum of all admitted
credits, so every intermediate balance lies inside
[initial − Σdebits, initial + Σcredits]. Checking the declared bounds at the
two interval endpoints therefore covers every intermediate state of every ordering at
once. Admission is greedy in arrival order; finding the largest admissible
subset is NP-hard and not attempted. Greedy order is the intended semantics.
2. Write-round counts: escrow batch vs serial locking
These are round counts, not timings. Serial locking pays one write round per operation; escrow admission pays one for the whole admitted set.
3. A non-monotone invariant forces bounded witness search
Add a rule that D's balance stays even. It is not an interval bound, so D's operations leave
the fast path for a witness search, which reports inconclusive: search bound exhausted
past 8 operations.
yichus admit ledger.bosatsu ledger_parity.spec.bosatsu ledger_handlers.bosatsu \
--batch batch-sample.json --result admission.jsonledger_parity.spec.bosatsu: the same spec plus the parity policy
loading…
Loading admission artifact…
Dig deeper: how the witness search works and what the bound counts
Conflict components are built from evaluated keys: two search-path operations are linked
when their key functions evaluate to the same account id, and a component is a connected
group under that relation; arrival order is preserved inside each component. Each
component is searched independently with exact-value simulation, starting from the state
the escrow-admitted operations produce: orderings of the component's operations are
enumerated until one satisfies every declared bound and property at every step. The
bound counts operations per component: in a component larger than 8, the
operations beyond the bound are marked inconclusive: search bound exhausted
and only the first 8 are searched (--max-search can lower the bound; 8 is
the hard cap, the same bound discipline as the interleaving checker). Non-monotone
properties are not the only route here: a delta with mixed sign or a negative amount is
also not escrow-analyzable and takes the search path. The final witness
ordering is the escrow-admitted operations in arrival order, followed by each component's
searched sequence. That is why, in the artifact above, a late-arriving escrow
operation can hold an earlier witness position than a searched one.
4. Browser solver controls and replay verification
The same solver runs in your browser. Things to try:
- Raise the hot-account share and watch deferrals pile up on D.
- Turn on the parity rule, and at batch size 24 with 100% on D the search bound runs out.
- Break the handler's credit and replay reports model drift at the first diverging operation.
ledger_handlers.bosatsu (editable)
Escrow declarations, witness search, and replay soundness
The deltas and bounds are declarations about the handler, so every batch is replayed through the compiled handler, and any divergence makes it inconclusive: model drift.
Dig deeper: stated limits of this pass
Admission is greedy in arrival order; finding the largest admissible subset is NP-hard
and not attempted. Escrow values are Int in this pass; generalizing to other
ordered structures (sets, max/min registers) is listed as future work in the design note.
One EscrowSpec cell per run; operations spanning multiple cells are not yet
supported. Keyed footprints are declared in the spec, not extracted from the
compiled code. Replay verification is the stopgap that guards the declaration, and it
checks the batch's key universe only: a handler that mutated a key no batch operation
declared would be outside this pass's replay scope.
Raw artifacts: escrow, with the parity policy, the batch.
Ask your agent about anything here; it has the detail.
Where this fits
What this is about: Batch admission