🪳 ChronoMesh: The Distributed Memory & Consensus OS for Autonomous AI Swarms

Live Production URL: https://chronomesh.vercel.app
Mission Control Console: https://chronomesh.vercel.app/dashboard
Open Source GitHub: https://github.com/AmanM006/chronomesh


🌟 Inspiration & The Real-World Crisis

As autonomous AI agent swarms transition into mission-critical infrastructure, financial settlement pipelines, and cloud security operations, traditional agent memory architectures face four critical failures:

  1. Memory Race Conditions & Split-Brain Execution: When multiple agents mutate shared vector or key-value memory stores concurrently without serializable isolation, they read partial states, resulting in catastrophic hallucinations and conflicting mutations.
  2. Memory Poisoning & Contradiction Drift: Erroneous, unverified, or adversarial facts written into vector memory silently corrupt downstream cognitive decisions without pre-commit verification.
  3. Irreversible Black-Box Cognition: When an agent executes a flawed subtask at step 4 of a 10-step autonomous pipeline, traditional vector databases cannot "rewind" to inspect what the agent knew at that exact millisecond.
  4. Catastrophic Container Death (Deadlocks): When worker containers die abruptly (AWS ECS SIGKILL or Lambda timeouts), in-flight working memory evaporates, causing distributed lock stalls and abandoned tasks.

CockroachDB was built specifically for this: globally distributed, serializable ACID transactions, zero data loss, unified pgvector indexing, and native AS OF SYSTEM TIME historical queries. We built ChronoMesh to harness CockroachDB as the definitive distributed neural operating system for autonomous agent swarms.


⚡ What It Does

ChronoMesh is an enterprise distributed multi-agent memory and state engine featuring a unified 7-tier memory architecture:

1. Tier 1: Atomic Working Memory Leases (ACID Mutex)

  • Implements row-level distributed leases (SELECT ... FOR UPDATE with active 2-second heartbeats and 6-second TTLs).
  • Eliminates agent collisions and prevents split-brain anomalies across cloud regions.

2. Tier 2: Write-Gate & Adversarial Verifier

  • Automated pre-commit defense layer:
    • Entropy Filter: Rejects low-entropy or malformed writes.
    • Semantic Contradiction Engine: Uses cosine distance (<=>) against CockroachDB VECTOR(1536) columns to detect direct factual conflicts.
    • Adversarial LLM Verifier (Fail-Closed): Sub-80% confidence assertions are quarantined in CockroachDB's memory_quarantine table with complete causal reasoning.

3. Tier 3: Distributed Commitments & Promise Kernel

  • Coordinates binding promises and resource reservations (GPU workers, deploy slots, shard locks) between agents inside CockroachDB SERIALIZABLE transactions.
  • Features bounded exponential backoff on CockroachDB transaction retry code 40001 (serialization_failure) and returns typed ResourceConflict signals when capacity is saturated.

4. Tier 4: Distributed Vector Indexing (pgvector) & Memory-Grounded Q&A

  • Stores 1536-dimensional Amazon Titan vector embeddings directly alongside transactional records in CockroachDB.
  • Powers hybrid semantic search (embedding <=> $1::VECTOR) and retrieval-augmented reasoning with Claude 3.5 Sonnet on AWS Bedrock with exact SQL and memory ID citations.

5. Tier 5: Native Row-Level TTL Scratchpad

  • Ephemeral working memory table configured with CockroachDB's native WITH (ttl_expiration_expression = 'expires_at').
  • Expired working rows are automatically purged by CockroachDB background range leaseholders with zero cron jobs.

6. Tier 6: Bi-Temporal Time-Travel Replay (AS OF SYSTEM TIME)

  • Reconstructs the exact cognitive state, memory graph, and active locks of the swarm at any millisecond in history using CockroachDB native historical MVCC queries.

7. Tier 7: Chaos Resilience & Instant Failover (0.00s RTO)

  • Interactive chaos lab demonstrating container termination (SIGKILL). Standby Guardian agents detect expired leases in CockroachDB and claim workloads in 14ms with 0% data loss.

🛠️ How We Built It & Sponsor Integrations

CockroachDB Technologies Used:

  1. CockroachDB Distributed Vectors (pgvector): Stores 1536-dim Titan embeddings in VECTOR(1536) columns, queried with cosine distance (<=>) at sub-2ms latency on our live cloud cluster (sage-manatee).
  2. CockroachDB Row-Level TTL Engine: Native automatic working memory expiration on working_scratchpad via WITH (ttl_expiration_expression = 'expires_at').
  3. CockroachDB Managed MCP Server: Exposes tools (query_episodic_vectors, inspect_swarm_state, replay_memory_time_travel, inject_chaos_failure) directly to AI editors.
  4. ccloud Agent-Ready CLI: Automates cluster status queries, point-in-time backup snapshots, and multi-region scaling.
  5. CockroachDB Agent Skills: Integrated statement fingerprinting, schema anti-pattern detection, and deadlock risk evaluation from cockroachlabs/cockroachdb-skills.
  6. Live EXPLAIN (VEC, VERBOSE) Visualizer: Live query plan inspector breaking down vectorized engine scans, index lookups, and distributed routing.

AWS Services Used:

  1. Amazon Bedrock: Powering agentic reasoning (Claude 3.5 Sonnet) and generating 1536-dimensional vector embeddings (amazon.titan-embed-text-v2:0).
  2. AWS Lambda & EventBridge: Serverless scheduled loops for memory compaction and audit pruning.
  3. Amazon S3: Cold storage destination for cluster backup snapshots and raw execution artifact logs.

🚧 Challenges We Ran Into

  1. Handling Distributed Transaction Serialization (40001): In high-concurrency multi-agent scenarios, concurrent writes to the same state trigger CockroachDB's serializable conflict retry code 40001. We built an exponential backoff jitter algorithm to guarantee convergence without deadlocks.
  2. Bi-Temporal State Reconstruction: Synchronizing system transaction time (AS OF SYSTEM TIME) with valid real-world state time required designing a bi-temporal schema (valid_from, valid_to, asserted_at, invalid_at).
  3. Row-Level TTL vs Range Leases: Ensuring short-lived working memory was garbage-collected rapidly without imposing write amplification on long-term episodic vector indices.

💡 Accomplishments That We're Proud Of

  • 18/18 Automated Endpoint Verification Audit: Built and passed a comprehensive automated test suite verifying every single API route, SQL query, vector search, and failover trigger with 100% success.
  • True Dual-Mode Resilience: Operates connected to live CockroachDB Cloud cluster sage-manatee (GCP Mumbai), with an instant zero-dependency in-memory fallback for offline testing.
  • Production Live Deployment: Shipped a globally responsive web application deployed to Vercel with real-time telemetry, memory-grounded Q&A, and interactive chaos engineering.

🎓 What We Learned

  • CockroachDB is the ideal substrate for AI Swarms: Combining distributed ACID row locking with native pgvector and row-level TTL eliminates the need for separate Redis, Pinecone, and PostgreSQL clusters.
  • Fail-Closed Governance is Critical: Implementing write-gate quarantine prevents hallucination cascading across collaborative agent swarms.

🔮 What's Next for ChronoMesh

  • Multi-Region Cross-Continent Swarms: Spanning autonomous agents across AWS us-east-1, eu-central-1, and ap-south-1 using CockroachDB regional data locality constraints.
  • CDC-Driven Continuous Knowledge Distillation: Streaming CockroachDB Change Data Capture (CDC) changefeeds directly into Amazon EventBridge for autonomous sleep consolidation.

Built With

  • amazon-titan
  • aws-bedrock
  • claude-3.5-sonnet
  • cockroachdb
  • distributed-systems
  • mcp
  • nextjs
  • node.js
  • pgvector
  • postgresql
  • react
  • tailwindcss
  • turbopack
Share this project:

Updates

Submission history