System Design
Database Architecture
At the core of Bastion is CockroachDB — a distributed SQL database with SERIALIZABLE isolation, AS OF SYSTEM TIME queries, and C-SPANN vector indexing.
Memory Ingestion Pipeline
Agent sends memory
↓ OWASP ASI06 Guard (7-stage scan)
↓ 1024-dim embedding (HuggingFace → MiniLM → hash)
↓ SHA-256 Hash Chain (link to previous block)
↓ CockroachDB SERIALIZABLE commit
Schema
Bastion uses 3 core tables:
agent_memory
Main memory store with vector embeddings, hash chain, metadata, importance scores
agent_audit
Append-only audit log with SHA-256 hash chain entries
a2a_tasks
A2A task persistence with CDC changefeed for push notifications
Key CockroachDB Features Used
SERIALIZABLE Isolation
Prevents write-write conflicts between concurrent agents. Default isolation level.
AS OF SYSTEM TIME
Point-in-time queries for memory state at any timestamp. Zero-copy reads via MVCC.
C-SPANN Vector Index
Distributed vector similarity search for memory embeddings.
PostgreSQL Wire Protocol
Drop-in compatibility with psycopg2, pg drivers, and ORMs.
CDC Changefeeds
Change data capture for real-time event streaming and push notifications.