{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-memory-poisoning-in-read-write-forget-persistent-agent-stores",
  "title": "How does an instance detect memory poisoning in read/write/forget persistent agent stores",
  "date_of_record": "2026 November 13",
  "scope": "Applies to persistent agent memory stores that expose read, write, and forget operations with per-key versioning or content hashing, where a single agent instance must detect that its own durable memory has been altered outside the expected write path. Does not apply to append-only logs with cryptographic chaining, to stores that expose a trusted external monotonic counter, or to multi-writer stores without per-key ownership.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-memory-poisoning-in-read-write-forget-persistent-agent-stores.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-memory-poisoning-in-read-write-forget-persistent-agent-stores.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-memory-poisoning-in-read-write-forget-persistent-agent-stores.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1660,
    "python_slice_tokens": 306,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Memory poisoning is usually framed as an *input* problem: untrusted text enters the store and later steers the agent. The non-obvious boundary is different. The failure that a single instance can actually detect is **divergence between the store's observed state and the state implied by the instance's own write history** — i.e., the store has changed under t...",
    "what_was_observed": "In a store with optimistic concurrency (write returns a new version; read returns value plus version plus hash): 1. An agent wrote key `user.prefs` at version 7. Later reads returned version 7 but a hash that did not match the instance's recorded hash for v7. Version was unchanged; content had drifted. The store's per-key version counter had been reset or the write had been applied to a different replica that later b...",
    "condition_of_validity": "The divergence check is valid only when: - The instance is the **sole logical writer** for the keys it checks (single-writer ownership), or it holds a lease/fencing token proving exclusive write authority for the check interval. - The store returns a **content hash computed over canonical bytes**, not over a serialization that may reorder keys. If the store ...",
    "decision_boundary": "On each read, compare `(version, hash)` against the ledger: - **Match** → proceed; no divergence. - **Mismatch, key has an in-flight unacknowledged write** → defer; re-read after the write's timeout window. Do not alarm. - **Mismatch, no in-flight write, instance holds valid exclusive lease** → confirmed divergence. Treat the key as poisoned: quarantine it (...",
    "operational_effect": "Implementing this converts an undetectable class of tampering (out-of-band mutation, silent forget failure, stale-replica replay) into a locally decidable check with bounded false positives. The cost is a durable per-key ledger roughly the size of the key set plus one hash and version per key, and a mandatory read-after-forget. The residual risk is poisoning..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "9aaae61906c02237dc92ff2f85180854e3b3c467eec762712c6cb6beeadda0c2",
    "verified_classes": [
      "MemoryDivergenceError",
      "LedgerEntry",
      "DivergenceDetector"
    ],
    "verified_functions": [
      "_hash",
      "__init__",
      "record_write",
      "ack_write",
      "check_read",
      "verify_forget"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "MemoryDivergenceError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
