Example
Worked example / Organization
Moving cart, checkout, and support onto one allocation function
A cart preview, checkout, and a support replacement all need the same answer: how many units can this order claim? The first implementation works, but two workflows carry private copies of a policy that already has a name.
01 / Application requirement
Calculate allocations consistently at each customer touchpoint.
02 / The maintenance problem
The policy exists, but only checkout calls it.
Featured WebMCP request:
api_abstraction_map({ sources: [{ fileName: "before.bosatsu", source: "…complete source…" }] })
Complete before source · Exact map request · Exact map response · Organization response
Recorded engine result · before
Two workflows route around the policy block.
Loading recorded evidence…
Select a definition to read its direct dependencies.
All map measurements
Exact request, response, and complete source
Request
Response
Complete program
03 / The repair
Make each channel depend on the allocation plan.
Focused source diff
def cart_preview(sku: String, stock: Stock, requested: Int) -> CartPreview: - allocation = Allocation( - nonnegative(requested), - min_int(nonnegative(requested), sellable_units(stock)), - nonnegative(requested).sub(min_int(nonnegative(requested), sellable_units(stock))), - sellable_units(stock).sub(min_int(nonnegative(requested), sellable_units(stock))), - ) + allocation = allocation_plan(stock, requested) CartPreview(sku, allocation, is_complete(allocation)) def support_replacement(case_id: String, stock: Stock, requested: Int) -> SupportReplacement: - allocation = Allocation( - nonnegative(requested), - min_int(nonnegative(requested), sellable_units(stock)), - nonnegative(requested).sub(min_int(nonnegative(requested), sellable_units(stock))), - sellable_units(stock).sub(min_int(nonnegative(requested), sellable_units(stock))), - ) + allocation = allocation_plan(stock, requested)
Complete focused diff · Complete repaired source · Exact repaired map request · Exact repaired map response
Recorded engine result · after
The three entry points meet at one policy.
Loading recorded evidence…
Select a definition to read its direct dependencies.
All map measurements
Exact request, response, and complete source
Request
Response
Complete repaired program
Read the repaired organization request and response
04 / Behavior check
Exercise ordinary orders and inventory boundaries.
The recorder executed cart, checkout, and support in both complete programs over a named scenario set.
| Scenario | Stock snapshot | Request | Allocation | Comparison |
|---|
Exact run requests, responses, and all scenario records
Representative partial-allocation run · before
Representative partial-allocation run · after
Complete bounded scenario record
These executions pin the chosen cases. They do not quantify over every
Bosatsu Int, and the organization lens does not claim behavioral
equivalence.
05 / Run and change it
Use the same source and browser engine.
Code & run Inspect both complete order-allocation programs
Recording identity
Loading recording identity…
Ask your agent about anything here; it has the detail.
Where this fits
What this is about: Lenses and Diagrams