Event Sourcing Architecture
Overview
Fulcrum uses Event Sourcing patterns via NATS JetStream to ensure comprehensive audit trails, reliable asynchronous processing, and system decoupling.
Stream Hierarchy
fulcrum.events
The primary stream for all domain events.
Subjects:
- fulcrum.events.envelope.created
- fulcrum.events.envelope.completed
- fulcrum.events.policy.evaluated
- fulcrum.events.cost.tracked
fulcrum.tasks
The work queue for agent task distribution (if utilizing Fulcrum's scheduler).
Event Schema
All events follow the CloudEvents specification 1.0.
{
"specversion": "1.0",
"type": "com.fulcrum.policy.evaluated",
"source": "/tenants/tenant-123/agents/agent-abc",
"id": "evt-1234567890",
"time": "2026-01-06T12:00:00Z",
"datacontenttype": "application/json",
"data": {
"envelope_id": "env-xyz",
"policy_id": "pol-read-only",
"decision": "ALLOW",
"latency_ms": 5
}
}
Consumers
- Audit Logger: Subscribes to
fulcrum.events.*and persists to PostgreSQL/ClickHouse. - Billing Aggregator: Subscribes to
fulcrum.events.cost.*and updates budget items. - Webhooks: Subscribes to relevant events to push notifications to external systems.
Retention
- Stream Retention: 7 days (configurable)
- Archive: Long-term storage in S3/GCS via archival worker.