The Ledger — Agentic Event Store
A PostgreSQL-backed, append-only event store and enterprise audit infrastructure for multi-agent AI systems in regulated environments, where five AI agents collaborate on commercial loan decisions with full cryptographic auditability.
Overview
A PostgreSQL-backed, append-only event store and enterprise audit infrastructure for multi-agent AI systems in regulated environments, where five AI agents collaborate on commercial loan decisions with full cryptographic auditability.
Problem
Multi-agent AI systems making high-stakes decisions (credit approvals, compliance checks, fraud screening) in regulated industries require a complete, immutable audit trail. Standard logging is insufficient — every agent decision must be permanently recorded, cryptographically verifiable, and queryable for regulatory review.
Dataset
Synthetic commercial loan application data generated via a seed pipeline: 80 applicant profiles with associated PDF and XLSX financial documents, producing structured event streams across five agent decision points per application.
Architecture
An event-sourced architecture with five collaborating AI agents: Credit Agent, Compliance Agent, Fraud Agent, Underwriter Agent, and Human Review Agent. All decisions are appended to an immutable PostgreSQL event store with optimistic concurrency control (OCC). A transactional outbox handles downstream messaging. Read models are maintained via projections: application summary, agent performance ledger, and a compliance audit view with temporal query support. Snapshot store reduces replay cost for long-lived aggregates.
Training
No model training. Agents use OpenRouter LLMs (Gemini 2.0 Flash) for decision generation. Business logic is enforced via an 8-state loan application state machine with domain-level validation. Property-based tests (Hypothesis + Faker) validate event store invariants and concurrency guarantees.
Results
Optimistic concurrency control ensures exactly-one-wins semantics for concurrent agent writes. The compliance audit view supports temporal queries for regulatory review. The full pipeline processes a loan application through all five agents with a complete, replayable event log. Test suite validates round-trip event integrity, state machine transitions, and projection correctness.