A change that breaks another part of the app fails the check
Your agent reads the files it's working on, and rarely the whole app. TypeScript checks every file too, but its types don't record which errors a function can throw or who may see a record, and an ID is a plain string unless you build a branded type for it. A change that gets one of those wrong somewhere else still compiles. You find out from a test, in review, or from a user.
In Jadpo, all of those are part of the types. When a change breaks something in another file, the check fails and names the place, and your agent fixes it before it hands the change to you.
You ask your agent to stop an order when a cake is out of stock. In Jadpo, an action is a function that can change stored data, and it lists the failures it can end with. So the agent adds one.
domains/shop/actions/reserve_stock.jadpothe whole file
use shop/types { Quantity, Reservation }use shop/failures { OutOfStock }/// Holds stock for an order.action reserve_stock(quantity: Quantity) fails OutOfStock -> Reservation {changed by your agent if (quantity > 10) { reject OutOfStock } return Reservation { quantity: quantity }}another file, which the agent didn't open
domains/shop/actions/checkout.jadpothe whole file
use shop/types { Quantity, Reservation, OrderReceipt }use shop/actions { reserve_stock }/// Places an order for some cakes.action checkout(quantity: Quantity) -> OrderReceipt { var held: Reservation = reserve_stock(quantity) return OrderReceipt { quantity: held.quantity }}jadpo checkcheck failed: 1 error, 14 files
✗ error reserve_stock can fail, and nothing handles it
- at
- domains/shop/actions/checkout.jadpo:6:29
- reason
- A call that can fail says so where it is made:
attempt passes its failures on to the caller's fails list, and match handles each one. - next
- Start the statement with
attempt, or match on reserve_stock(...) and handle OutOfStock (agent) - rule
- failure.attempt_required
Real code, and real output from jadpo check, from a project started with jadpo new. attempt would pass the failure on to whatever calls checkout, and match would handle it there. The request to your agent is made up.