Failure handling
Ten failure rows, each held by a test with this title in pnpm test (packages/facilitator/test/failures-1.test.ts, packages/facilitator/test/failures-2.test.ts). Status read as "facilitator / vendor": the facilitator answers a verdict with 200 and the spec's own shape plus {error, code, retryable}; the vendor answers the buyer with 402 and never the resource.
| Row | Failure | Code | Behaviour | Test |
|---|---|---|---|---|
| 1 | Voucher exceeds the deposit | invalid_batch_settlement_svm_cumulative_exceeds_deposit | Corrective 402 with extra.channelState, the buyer's own extra.voucherState, and extra.minDeposit set so one top-up makes the voucher fit; nothing moves | "voucher exceeds deposit: corrective 402 carries minDeposit" |
| 2 | Voucher total not above the last accepted | invalid_batch_settlement_svm_cumulative_amount_mismatch | Rejected with the snapshot so the buyer resynchronises; the highest watermark is kept | "voucher not above last accepted is rejected" |
| 3 | Bad signature or wrong channel | invalid_batch_settlement_svm_voucher_signature, invalid_batch_settlement_svm_channel_id_mismatch | Rejected before the record is read; no snapshot travels; nothing stored | "bad signature or wrong channel is rejected and nothing stored" |
| 4 | Facilitator unreachable or times out | shielded_facilitator_unavailable, retryable: true | The vendor fails closed: 402 with empty accepts[], no resource, nothing to deposit into | "facilitator unreachable: vendor fails closed" |
| 5 | Redemption transaction fails or is unconfirmed | settlement_pending (carries the signature) | The amount stays owed; the worker asks the rail about the signature before any resend, then the escrow's balance; the vendor reads it under pending[] of its receipts | "redemption failure keeps the amount owed and returns settlement_pending with signature" |
| 6 | Buyer starts a close before redemption | invalid_batch_settlement_svm_channel_closing | During the grace (withdrawDelay) the vendor's latest voucher is accepted; after it the vendor is paid its watermark and deposit − settled returns to the buyer's private balance | "close before redemption: vendor voucher accepted during grace" |
| 7 | Buyer disappears | n/a (lifecycle) | At maxIdleSecs without activity the channel is idle-closed: settled to the vendor at the accepted watermark, the rest refunded | "buyer disappears: idle close settles at the accepted watermark" |
| 8 | Duplicate request retry | duplicate_settlement | The same /settle envelope answers the stored result with extra.replayed: true and moves nothing; a buyer resending a header is served once | "duplicate retry returns the stored result" |
| 9 | Private transfer rejected at PER ingress or UNSUPPORTED_TRANSFER_ROUTE | shielded_binding_rejected | Terminal: alerted with the rail's code, never retried, never public; the amount stays owed; the vendor reads it under rejected[] | "PER rejection is terminal, alerted, never public" |
| 10 | TEE attestation fails | shielded_attestation_failed | The binding does not exist; /supported answers kinds: [], every other route 503; nothing is verified, settled or simulated | "attestation failure gives an empty /supported" |