ceo-api/drizzle/0003_ai_gateway_requests.sql
valentinbvro 3bc0d65c46 feat: AI Gateway -- Context Manifest, model routing, cost audit, guardrails
- AiGatewayService: punct unic de acces la modele (LiteLLM -> OpenRouter).
  Clasele de actiuni din blueprint 14.3 sunt aplicate hard: high_risk blocat
  permanent, material blocat pana exista coada de aprobare + idempotency;
  doar read_only si draft ruleaza.
- Spotlighting (design doc Strat 1): continutul untrusted (date Apollo) e
  impachetat in <untrusted-data> cu instructiune de sistem ca e DATE, nu
  comenzi -- plus redactie PII deterministica (email/telefon/CNP) inainte
  sa plece catre provider extern.
- ai_requests: adaugat action_class + context_manifest complet (nu doar
  hash) pentru audit; cost_usd_minor_units (integer) inlocuit cu
  cost_usd numeric(12,6) -- costurile reale sunt fractiuni de cent.
- research-briefs: POST /draft genereaza un rezumat AI din datele Apollo
  fara sa salveze nimic (clasa draft -- userul revizuieste, apoi salveaza).
- briefing: aiExplanation devine narativ real peste prioritizarea
  determinista; esecul AI intoarce null, nu strica briefingul.
- teste: clase de actiuni blocate, spotlighting, redactie PII.
2026-07-28 22:34:36 +02:00

7 lines
664 B
SQL

-- AI Gateway: audit complet pe fiecare cerere catre model (blueprint 9, 14.2).
-- cost_usd_minor_units (integer) se inlocuieste cu cost_usd numeric(12,6): costurile
-- reale sunt fractiuni de cent, rotunjirea la cent stergea semnalul.
ALTER TABLE "ai_requests" ADD COLUMN IF NOT EXISTS "action_class" text NOT NULL DEFAULT 'read_only';--> statement-breakpoint
ALTER TABLE "ai_requests" ADD COLUMN IF NOT EXISTS "context_manifest" jsonb NOT NULL DEFAULT '{}'::jsonb;--> statement-breakpoint
ALTER TABLE "ai_requests" ADD COLUMN IF NOT EXISTS "cost_usd" numeric(12,6);--> statement-breakpoint
ALTER TABLE "ai_requests" DROP COLUMN IF EXISTS "cost_usd_minor_units";