medbeads-agent-native-immutable-data
MedBeads: Agent-Native, Immutable Data Substrate for Medical AI
This skill teaches Claude to implement the MedBeads architecture -- an immutable, causally-linked data substrate that replaces probabilistic RAG retrieval with deterministic graph traversal for clinical AI agents. The core idea: instead of storing medical data in flat, mutable FHIR resources that force LLMs to guess context via vector search, encode every clinical event as a cryptographically-sealed "Bead" in a Merkle DAG where causal relationships (why something happened) are explicit edges, not inferred metadata. This eliminates hallucination from context reconstruction and makes every AI decision fully auditable.
When to Use
- When building a medical records system that AI agents will consume directly (not just human clinicians)
- When converting existing FHIR R4 resources into a causally-linked, append-only graph
- When implementing tamper-evident audit trails for clinical data where integrity must be mathematically verifiable
- When replacing RAG-based clinical context retrieval with deterministic BFS graph traversal
- When designing multi-agent clinical workflows where agents need shared, immutable patient context
- When building an MCP server that exposes patient history as a traversable DAG to LLM agents
- When the user needs content-addressable storage for medical records with cryptographic verification
Key Technique
The Context Mismatch Problem. Traditional EMR/FHIR stores data for humans: flat, mutable resources where causality is implicit in timestamps and narrative notes. When an LLM agent needs to understand "why was this medication prescribed?", it must use RAG to retrieve fragments and probabilistically reconstruct the causal chain. This introduces semantic confusion (e.g., confusing "congestive heart failure" with "cardiac arrest" because both match a "heart failure" query) and makes hallucination undetectable.
The Bead + Merkle DAG Solution. MedBeads encodes each clinical event as a Bead: a seven-component tuple B = {T, τ, A, P, C, E, Σ} containing timestamp, type, author (DID), parent bead hashes, JSON content payload, evidence references, and a digital signature. Each Bead's ID is SHA-256(CanonicalJSON(B)), so any mutation breaks the hash chain. Parent links create a Merkle DAG where traversal from any node upward answers "why did this happen?" and downward answers "what happened next?" -- both in O(V+E) time via BFS, with zero probabilistic inference.