Phase 1 delivers the complete durability and storage layer:
- WAL with crash recovery: Append-only journal with BLAKE3 checksums,
fsync guarantees, and proper seek-to-EOF on reopen
- Storage engine: sled-backed KVStore with scan_prefix for range queries
- Content-addressed storage: H:{hash}, V:{hash}, E:{hash} key patterns
- Ingestor: Background worker tailing WAL, writing to KV with 8-byte
aligned record headers for rkyv zero-copy deserialization
- Comprehensive tests: 31 tests covering crash recovery, round-trips,
and multi-cycle durability
New crates: stemedb-wal, stemedb-storage, stemedb-ingest
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
3.6 KiB
3.6 KiB
The Simulation: "The Infinite Game"
Codename: The Arena Goal: Validate StemeDB's behavior under emergent, adversarial, and evolutionary pressure.
1. The Vision
We are not building a database for humans to query manually. We are building the Cortex for AI agents. Therefore, the only way to truly validate StemeDB is to simulate a society of agents living, arguing, and reasoning within it.
The Simulation is an Agent-Based Modeling (ABM) environment where StemeDB is the physics engine of truth.
2. The Players (Personas)
We instantiate a swarm of agents with conflicting goals and personalities:
| Persona | Goal | Behavior Pattern |
|---|---|---|
| The Scientist | Converge on Truth | Publishes assertions with high confidence, cites sources, verifies others. |
| The Troll | Sow Chaos | Publishes low-confidence contradictions, forks reality frequently. |
| The Believer | Amplify Consensus | Blindly trusts high-reputation agents, creates echo chambers. |
| The Skeptic | Find Variance | Queries for high-conflict nodes, reduces confidence of unverified claims. |
| The Historian | Preserve Context | Audits "Dormant" assertions, resurrects old truths if new evidence appears. |
3. The Gameplay Loop
The simulation runs in "Ticks" (Logic Frames).
Tick 1: The Assertion
- Scientist reads a "Paper" (simulated ground truth).
- Asserts:
Subject="Protein_X", Predicate="binds_to", Object="Receptor_Y". - Sign:
Key_Scientist.
Tick 2: The Fork
- Troll reads the assertion.
- Forks reality:
Branch="Counter_Narrative". - Asserts:
Subject="Protein_X", Predicate="binds_to", Object="Nothing". - Sign:
Key_Troll.
Tick 3: The Lens Resolution
- Believer queries
Protein_X. - Applies Lens::Consensus.
- Result:
Receptor_Y(Weight 1.0 vs 0.0). - Believer signs the original assertion (Weight increases).
Tick 4: The Reputation Update
- Gardener (System Process) runs TrustRank.
- Sees Scientist verified by Believer.
- Increases Scientist Reputation.
- Decreases Troll Reputation (low consensus).
Tick 5: The Decay
- Time passes.
- Dormancy Protocol calculates "Confidence Half-Life".
- Unverified assertions fade. High-reputation assertions persist.
4. Technical Architecture
4.1. The Arena (Runner)
A Rust binary (stemedb-sim) that orchestrates the swarm.
- Runtime:
tokio(Async). - Communication: Agents talk only via StemeDB (Writes/Reads).
- Metrics: Prometheus/Grafana dashboard tracking:
global_truth_convergence(Entropy of the graph).agent_reputation_distribution.fork_depth_max.
4.2. The Scenario Config
We define scenarios in YAML:
scenario: "The Rumor Mill"
agents:
scientists: 5
trolls: 2
believers: 20
duration: 1000 ticks
ground_truth:
- "Sky is Blue"
- "Water is Wet"
5. Success Criteria
We know StemeDB works when:
- Truth Survives: High-reputation assertions outlive spam.
- Lenses Work: A
Consensuslens correctly filters out the Troll's noise. - Performance: The system handles 1000 concurrent agents forking reality without locking up (SMT efficiency).
- Emergence: We see "Trust Clusters" form naturally without hardcoded rules.
6. Implementation Plan
- Basic Agent Logic: Implement
Agentstruct withSignerandStrategy. - Scenario Runner: Build the loop that ticks agents.
- Metric Export: Expose internal graph stats.
- Chaos Injection: Randomly kill nodes/agents and verify recovery.
The Simulation is the Integration Test.