AI Assistance. Human Authority.
Financial disputes carry legal and financial obligations. ResolveAI is designed with strict boundaries: AI assists with investigation, but humans hold sole authority to execute.
Security Boundary Architecture
How requests and dispute data flow safely across untrusted web, cognitive AI, and verified PayPal APIs:
HMAC signature verification against PayPal certs + event-ID deduplication.
Strict merchantId scoping on all Prisma queries. Role permissions enforced.
AI outputs validated via Zod. Every claim requires source record citations.
Backend blocks submission unless explicit merchant approval is signed.
Cryptographic Webhook Signature Verification
Every incoming PayPal webhook is validated against PayPal’s verification endpoint using transmission ID, transmission signature, cert URL, and auth algorithm headers. Unverified or forged payloads are rejected at the edge before DB write.
Idempotency & Event Deduplication
PayPal event IDs are tracked in the webhook_events table with a unique PostgreSQL index. Duplicate webhook deliveries receive an immediate HTTP 200 acknowledgment without re-triggering analysis or state transitions.
Backend-Enforced Human Approval Gate
AI is architecturally forbidden from submitting evidence autonomously. The backend explicitly verifies dispute.approvalStatus === "APPROVED" in database transactions before calling PayPal APIs. Direct submission calls without approval fail with HTTP 400.
Zod Runtime Schema Validation
LLMs can generate malformed JSON. Every AI inference response is parsed and validated at runtime using strict Zod schemas (ClassificationSchema, CompletenessScoreSchema, ResponseDraftSchema). Invalid outputs are caught before persisting.
Anti-Hallucination Citation Grounding
Draft contestation sections require an array of explicit source citations binding claims to verified transaction IDs or carrier tracking numbers. If proof is missing, the system flags it as a case weakness rather than inventing records.
Merchant-Scoped Authorization & RBAC
All dispute, transaction, and evidence queries strictly enforce WHERE merchant_id = :authenticatedMerchantId. RBAC middleware segregates MERCHANT, REVIEWER, and ADMIN permissions, blocking horizontal privilege escalation.
Immutable Compliance Audit Ledger
Every mutation (webhook receipt, AI analysis completion, evidence attachment, merchant approval, and PayPal submission) writes an append-only row into the audit_logs table capturing actor, action, timestamp, and metadata.
Zero Secrets in Frontend Bundles
PayPal client secrets, webhook IDs, and Google Gemini API keys exist strictly on the backend Express environment. Frontend code only communicates with our typed API client, never exposing gateway credentials.