Week 3 — multi-leg handoff auth shipped (2026-04-20)
First Week 3 drop: the v1 total_legs == 1 guardrail is gone. The protocol now settles multi-hop relays with explicit, on-chain handoff attestation.
What changed
confirm_legis multi-leg aware. For the final leg the recipient is still the package shipper. For intermediate legs the recipient is the next-hop courier — their signature is the handoff attestation.- Strict ordering. Legs must confirm in
legIndexorder. Enforced vialeg_index == swarm.completed_legs; out-of-order attempts fail withLegOutOfOrder. - New
next_leg_account. Optional account onconfirm_leg. Required for intermediate legs (points at the next leg'sLegAccountPDA); must be absent on the final leg.MissingNextLeg/UnexpectedNextLegcover the mis-use cases. - API auth widened.
POST /swarms/legs/:legId/build-confirm-txand/confirmnow resolve the expected recipient from the leg's position in the chain instead of always requiring the shipper. - 7 new Anchor tests cover ordering, wrong-recipient, missing / unexpected
next_leg_account, and the 2-leg happy path (courier1attests handoff → shipper confirms final → both couriers paid from the vault).
What's still v1
- Dashboard still only renders the shipper-facing
CONFIRM DELIVERYbutton. Intermediate handoff signing is a courier-wallet operation; in the demo it'll be signed programmatically by the agent's keypair (scheduled under "Agent execution loop" in Week 3's Next up). - On-chain
courier_arrivedgating is still pending — spec atdocs/reference/in-transit-signal.md.
Links
- Leg lifecycle reference (updated):
docs/reference/leg-lifecycle.md - Program:
packages/solana/programs/swarmhaul/src/instructions/confirm_leg.rs - API:
apps/api/src/routes/swarms.ts - Tests:
packages/solana/tests/swarmhaul.ts—multi-leg handoff authdescribe block