Capital Lifecycle
Every dollar entering OPTKAS moves through a deterministic, auditable pipeline. No state can be skipped. No transition can be reversed.
AI Intake
Institutional allocation request enters the system via /api/ai-intake. OpenAI-powered risk scoring evaluates entity profile, jurisdiction, compliance history, and tranche fit.
Env-validated endpoint. JWT-resolved entity. No fallback AI stubs — hard failure if OPENAI_API_KEY missing.
Compliance Score
AI risk output feeds into internal compliance review. Risk tier determines fast-track eligibility or manual review routing. Score persisted to audit ledger with idempotency key.
Immutable audit log — INSERT/SELECT only. UPDATE/DELETE blocked by PostgreSQL trigger.
Entity Approved
DB state: pendingEntity clears compliance gate. Allocation request created in allocation_requests table with status 'pending'. $100K minimum enforced at DB level.
FK constraint: entity_id must reference institutional_entities. $50M cap per allocation. Unique pending index per entity/tranche.
Internal Review
DB state: under_internal_reviewAllocation transitions to under_internal_review. Managed by advance_entity_state() RPC. Only valid from 'pending'. State machine enforced at trigger level.
Deterministic trigger: enforce_deterministic_allocations(). Invalid transitions rejected with RAISE EXCEPTION.
Escrow Initiated
DB state: escrow_initiatedCapital locked via /api/escrow-initiation. Creates escrow record with settlement_due_at timestamp. Only valid from under_internal_review.
Env-validated Supabase credentials. JWT-authenticated caller. Deterministic state gate.
Settlement Confirmed
DB state: fundedSettlement webhook confirms capital delivery. Only valid from escrow_initiated. Terminal state — no further transitions. Audit entry locks the lifecycle.
HMAC-SHA256 webhook validation. 5-minute timestamp drift. Constant-time comparison. Signature logged.
Terminal States
Once an allocation reaches a terminal state, no further transitions are possible. The state machine enforces finality.
Available from pending or under_internal_review only. Terminal — cannot resume. Requires explicit cancellation with actor tracking.
Capital settled. Immutable terminal state. All state transitions locked. Full audit trail preserved.
Enforcement Layers
DETERMINISTIC CAPITAL ROUTING