railyard/apps/vend/crates/vend-store/migrations/0008_settlement_receipts.sql
caelum0x 894359e5ff feat(railyard): per-app completion pass — money-correct settlement + crate cores
- rago: exactly-once prepaid settlement (deterministic idempotency, unique partial index + in-tx ON CONFLICT guard) — closes the double-charge risk
- mint: double-entry + reserve conservation verified (14 tests)
- ledgerline: atomic settlement outbox + partial recovery index (37 tests)
- abacus: hard per-agent budget enforcement + kill-switch (54 tests)
- vend: crash reaper / in-flight session reconciliation
- turnstile/agent-runtime/ranguard/rit/game-economy/context-passport/rithub: core advanced + tests
2026-09-07 17:17:54 +03:00

14 lines
690 B
SQL

-- Preserve Mint's signed, hash-linked terminal proof beside Vend's product
-- projection. Mint remains the authoritative money ledger; these columns make
-- each Vend charge auditable by the same request/receipt chain.
ALTER TABLE metered_usage
ADD COLUMN IF NOT EXISTS settlement_seq BIGINT,
ADD COLUMN IF NOT EXISTS settlement_operation TEXT,
ADD COLUMN IF NOT EXISTS settlement_op_hash TEXT,
ADD COLUMN IF NOT EXISTS settlement_receipt_hash TEXT,
ADD COLUMN IF NOT EXISTS settlement_signature TEXT;
CREATE UNIQUE INDEX IF NOT EXISTS metered_usage_settlement_receipt_hash
ON metered_usage (settlement_receipt_hash)
WHERE settlement_receipt_hash IS NOT NULL;