The Credit Reservation Lifecycle

Interactive Supabase / Postgres Atomic State Flow

INVOKE DISPATCH WEBHOOK / POLL completed EXCEPTION / ERR timeout / throws release_generation_reservation 1. REQUEST [Client / Edge] 2. RESERVE reserve_usage RPC 3. SUBMIT submitApimartGen 4. SETTLE settlePlatformGen RELEASE & REFUND release_reservation ROW STATE: STAGE 1 generation_reservations row: (does not exist) user_balance: 100 cr ROW STATE: STAGE 2 id: "res_9942a" status: "pending" provider_task_id: null user_balance: 95 (-5) ROW STATE: STAGE 3 id: "res_9942a" status: "pending" provider_task_id: "tsk_88f1a2" ROW STATE: STAGE 4 id: "res_9942a" status: "settled" provider_task_id: ... settled_at: 14:02:01 ROW STATE: RELEASED status: "released" user_balance: 100 (credits refunded +5) .eq('status','pending') REJECTED 0 rows updated (Idempotent Guard)
STAGE 1: REQUEST Client Initiated
User submits a generation request. The client calculates required credit balance before invoking backend handlers.