The original v1 spec below describes the foundational claim/lifecycle/validator/retrieval model. Sections 0a–0c at the top of this document summarize what was added in v2.0, v3.0, v3.1, and v3.2 while leaving the v1 spec intact as the canonical contract for the core layer.
The system originally specified 6 subsystems (Event Log, Claims Store, Lifecycle Engine, Validator Loop, Retrieval Stack, Compaction Engine). v2.0–v3.2 added 4 more layers on top:
- Verbatim Memory Layer (
verbatim_store.py) — raw conversation storage with FTS5 + Qdrant vector search (OpenAI text-embedding-3-small, 1536 dims, Cosine). Coexists with structured claims; the LongMemEval benchmark exercises this layer. - LLM Wiki (
wiki_engine.py,vault_linter.py,vault_log.py,vault_synthesis.py,vault_query_capture.py,vault_bases.py) — Karpathy/Farza style compiled-truth + append-only-timeline articles inobsidian-vault/wiki/**/*.md. Generated bywiki-absorb, validated bylint-vault, surfaced via Obsidian Bases dashboards. Frontmatter schema enforcesdescription(~150 char),tags,datefor progressive disclosure. - Hook Stack (7 hooks under
~/.claude/hooks/) — full memory lifecycle automation without manual MCP calls:memorymaster-recall.py(UserPromptSubmit) — injects relevant claims into contextmemorymaster-classify.py(UserPromptSubmit) — regex signal matcher for routing hints (DECISION/BUG/GOTCHA/CONSTRAINT/ARCHITECTURE/ENVIRONMENT/REFERENCE in Spanish + English)memorymaster-validate-wiki.py(PostToolUse) — frontmatter + wikilink hygiene check onobsidian-vault/wiki/**/*.mdwritesmemorymaster-session-start.py(SessionStart) — injects recent claims, last cycle summary, pending candidates, recently updated wiki articles at startupmemorymaster-auto-ingest.py(Stop) — block-based checkpoint forces save every N human messagesmemorymaster-precompact.py(PreCompact) — forces save before context compactionmemorymaster-steward-cycle.py(cron) — runsrun_cycleevery 6 hours
- MCP Server (
mcp_server.py) — FastMCP stdio server exposing 21 tools (ingest_claim,query_memory,query_for_context,run_cycle,list_claims,find_related_claims,pin_claim,redact_claim_payload, etc.) for any MCP-compatible agent runtime. Auto-citation fallback, sensitivity filter, content-hash dedup.
- Every claim now carries
valid_from(auto-populated on ingest) and optionalvalid_until(set when superseded). This makes the claim a true temporal knowledge graph node. idempotency_keydefaults tohash-<sha256(text+scope+tenant_id)>so identical claims across sessions dedup automatically without the caller passing an explicit key.
llm_provider.py is a single client that wraps Google Gemini, OpenAI, Anthropic, and Ollama with round-robin key rotation and per-key cooldown on 429. Used by wiki_engine, vault_linter, vault_synthesis, transcript_miner, llm_steward, and compact_summaries.
This document defines a v1 memory reliability system for coding agents. The system is designed to improve factual persistence across sessions while preventing drift, stale assumptions, and unsafe disclosure.
- Persist useful agent knowledge as verifiable claims.
- Track claim confidence and lifecycle state over time.
- Continuously validate and demote invalid memories.
- Retrieve high-precision memories with provenance.
- Compact long histories into summaries without losing citation traceability.
- Cross-organization multi-tenant isolation in one deployment.
- Autonomous policy updates without human approval.
- Fully automatic conflict resolution for high-impact claims.
The system has six major subsystems:
- Event Log (append-only source of truth).
- Structured Claims Store (normalized, queryable memory facts).
- Lifecycle State Engine (state transitions and invariants).
- Validator Loop (continuous re-check and state correction).
- Retrieval Stack (query understanding, ranking, filtering, assembly).
- Compaction Engine (history summarization with citations).
Agent Runtime
-> Event Ingestor -> Event Log (append-only)
-> Claim Extractor -> Claims Store
-> State Engine
Validator Scheduler -> Validator Workers -> State Engine + Claims Store
Query Path -> Retrieval Stack -> Response Context Builder
Compactor -> Summaries + Citation Graph -> Claims Store/Archive
Policy Guardrails -> Security Controls (applied at ingest/retrieval/export)
The event log is immutable and append-only.
interaction: user or agent turn.observation: external tool result or system observation.claim_created: new structured claim extracted.claim_updated: claim metadata/state/confidence changed.validation_result: validator success/failure/inconclusive.compaction_run: compaction output and retained citations.policy_decision: allow/deny/redact action.
event_id(ULID/UUIDv7).timestamp_utc(RFC3339).actor(user,agent,system,validator).session_id,thread_id,workspace_id.event_type.payload(schema per event type).integrity_hash(content hash chained to previous event hash per stream).
- Idempotent writes via deterministic
event_idfor retries. - Strict ordering within partition (
workspace_id+thread_id). - At-least-once delivery to downstream consumers.
Claims are atomic, machine-checkable memory units extracted from events.
claim_idsubject(entity being described)predicate(relation/property)object(value/entity)claim_text(human-readable paraphrase)source_event_ids[](direct citations)source_spans[](optional offsets/line ranges)confidence(0.0-1.0)state(candidate|confirmed|stale|superseded|conflicted|archived)valid_from,valid_to(nullable temporal bounds)last_validated_atvalidation_policy(rule id / validator class)sensitivity(public|internal|secret)created_at,updated_at
- Every claim must cite at least one source event.
- Derived/compacted claims must preserve transitive citation links to originals.
- Retrieval output must include citations for all non-trivial factual assertions.
States represent reliability and recency, not just existence.
candidate: newly extracted, unverified.confirmed: validated by at least one rule or repeated corroboration.stale: likely outdated by time horizon or failed freshness checks.superseded: replaced by newer conflicting claim with stronger evidence.conflicted: unresolved contradiction among similarly strong claims.archived: retained for audit/history, excluded from default retrieval.
candidate -> confirmed: validator success or N corroborating sources.candidate -> conflicted: contradiction detected before confirmation.confirmed -> stale: freshness TTL exceeded or soft validation failure.confirmed -> superseded: newer claim validated for same key tuple.any active -> conflicted: high-confidence contradiction appears.stale|superseded|conflicted -> archived: retention/compaction policy.stale -> confirmed: revalidation success.
- Exactly one active
confirmedclaim per uniqueness key (subject,predicate, scope) unless relation is multi-valued. supersededclaims must reference successorclaim_id.archivedclaims are immutable except retention metadata.
Validators continuously test claim correctness and freshness.
- Scheduler picks due claims by priority queue.
- Worker runs validator class based on
validation_policy. - Result recorded as
validation_resultevent. - State engine applies transition and updates confidence.
- Backoff and re-queue according to outcome.
consistency: internal contradiction checks.freshness: TTL and temporal relevance checks.source_replay: re-read cited source events for drift.external_probe(optional): tool/API checks for volatile facts.
pass: increase confidence, possibly promote state.fail_soft: reduce confidence, often markstale.fail_hard: markconflictedorsupersededwhen replacement exists.inconclusive: no state promotion, shorter recheck interval.
Retrieval prioritizes trustworthy, recent, and relevant claims.
- Query parsing: detect entities, intent, temporal constraints.
- Candidate generation:
- lexical/embedding search over claims + compacted summaries,
- graph expansion via linked claims/citations.
- Policy filter: sensitivity and workspace access checks.
- State filter:
- default include
confirmed, - conditional include
candidatewhen uncertainty is acceptable, - exclude
archivedby default.
- default include
- Ranking:
- relevance score,
- state weight,
- confidence,
- recency/validity window.
- Context assembly:
- top-k claims,
- citation bundle,
- conflict notes if
conflictedclaims exist.
- Never present
candidateas definitive fact. - If conflict exists, output explicit uncertainty and both citations.
- If only stale evidence exists, annotate with freshness warning.
Compaction reduces storage and retrieval cost while preserving verifiability.
- old event segments,
- low-access claims,
- stale/superseded claim groups.
- compacted summary objects,
- citation graph mapping summary assertions -> original events/claims,
- archive markers for pruned active records.
- No citation, no compaction.
- Compaction must be reversible to source references.
- Preserve contradictory evidence; do not collapse unresolved conflicts.
Security is enforced at ingest, storage, retrieval, and export boundaries.
- Encryption at rest and in transit.
- Access control by workspace/session identity.
- Claim-level sensitivity tags and retrieval redaction.
- Audit events for all policy decisions and privileged reads.
- Secret detection on ingestion with automatic masking.
- Data retention and deletion controls by policy class.
- Immutable audit trail for claim state transitions.
- Unauthorized retrieval of sensitive memory.
- Prompt-induced exfiltration of hidden claims.
- Tampering with historical events or citations.
- Silent drift from unvalidated stale memories.
Metrics are required for reliability sign-off.
Claim Precision@state=confirmed: fraction of confirmed claims judged correct.Claim Recall@critical: coverage of critical facts in benchmark tasks.Conflict Detection Rate: detected contradictions / total injected contradictions.Staleness Catch Rate: stale claims detected before use.Citation Completeness: assertions with valid citations / total assertions.
- Validation throughput (claims/hour).
- Validation latency p50/p95.
- Retrieval latency p50/p95.
- Compaction ratio (raw events to summarized units).
- Storage growth per 1k interactions.
- Sensitive claim leakage rate.
- Unauthorized access denial effectiveness.
- Audit log completeness.
memory-api: ingest/retrieval endpoints.event-log: append-only store.claim-db: relational/document index for structured claims.validator-workers: async workers.retrieval-service: ranking and context assembly.compactor-worker: scheduled compaction.policy-service: authorization + redaction decisions.
- End-to-end flow from ingest -> claim extraction -> validation -> retrieval works in staging.
- Lifecycle transitions are deterministic and audited.
- All retrieval outputs include citations for factual claims.
- Security controls enforce sensitivity boundaries.
- Metrics dashboard tracks reliability, performance, and safety KPIs.