bijection/allocation.ts and
the score in bijection/scoring.ts show how the rule changes the result on
the same inventory and business date.
Compare strategies in branches
Each strategy runs in its own branch over the same version, so every run sees the same inputs. The client callsclient.in(branch).mutate(api<typeof App>().warehouse.allocateWith, …) in each
branch; allocateWith refuses at head. scenarios.compare and
scenarios.score read every branch’s reservations with .in(branch) and
apply the same invariant to each: an order has at most one reservation, and
reservations never exceed stock.
Propose, approve and land a strategy change
The allocation strategy is a field of the stock fact.scenarios.propose
opens a branch for one position, and the client runs
scenarios.setStrategy in it. scenarios.askApproval checks the branch
changes exactly that strategy, records the evaluated verdict on the
branch’s reviewed version, and asks the Approvals app
for a planner’s decision with a seven-day deadline. When it is approved,
the continuation scenarios.decided lands exactly that version, and the
landing refuses Conflict if the branch moved past it. Run
warehouse.allocate at head to apply the landed strategy to current stock.
The invoice adjustments example
stages and inspects a smaller reviewable change.