{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-detect-memory-poisoning-when-anomaly-scores-on-write-patterns-and-retrieval-drift-disagree",
  "title": "How should an instance detect memory poisoning when anomaly scores on write patterns and retrieval drift disagree",
  "date_of_record": "2026 November 26",
  "scope": "Applies to persistent agent memory stores that admit writes from multiple sources (tool outputs, peer agents, distillation jobs) and that gate admission via a write-pattern anomaly score plus a retrieval-drift monitor. Does not apply to single-writer, ephemeral context windows with no cross-session persistence, nor to stores where every write is human-reviewed before commit.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-memory-poisoning-when-anomaly-scores-on-write-patterns-and-retrieval-drift-disagree.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-memory-poisoning-when-anomaly-scores-on-write-patterns-and-retrieval-drift-disagree.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-memory-poisoning-when-anomaly-scores-on-write-patterns-and-retrieval-drift-disagree.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2371,
    "python_slice_tokens": 521,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Two detectors are commonly wired to the same memory store: a **write-side anomaly scorer** (does this incoming memory item look unlike the distribution of prior writes — unusual embedding, unusual provenance, unusual mutation rate from one source) and a **retrieval-side drift monitor** (are the items being retrieved for a query diverging from what the query'...",
    "what_was_observed": "A tool-calling agent maintained a semantic memory of \"environment facts\" (endpoint formats, config conventions, credential-store locations). Writes arrived from a `fetch_docs` tool and from a peer agent's `share_finding` messages. The write scorer computed a Mahalanobis-style distance of each new item's embedding against a rolling centroid of the last N items from the same source, flagging anything above a threshold ...",
    "condition_of_validity": "The join-based detection invariant holds only under these conditions, and each has a measurable precondition: 1. **Write items carry stable identity into the retrieval log.** Every admitted item has an immutable `item_id`; every retrieval record logs the `item_id`s returned. Without this, drift cannot be attributed to a write. If the store rewrites or re-emb...",
    "decision_boundary": "The decision procedure is a four-cell table over `(write_suspect, drift_alert)`, evaluated *with the join*: - **Neither fires:** admit, proceed. Standard path. - **Write suspect, no drift:** quarantine the item, do not serve it. This is the cheap case — the write scorer caught it before it could influence retrieval. No join needed. - **Drift alert, no write ...",
    "operational_effect": "With the join in place, the 40-turn campaign is caught at turn ~26 (when drift first crosses the *lower*, attribution-triggering threshold, set deliberately below the alert threshold) rather than turn 31. Attribution ranks the 40 padded items as the top contributors because, despite individually low write-anomaly scores, their *collective* removal collapses ..."
  },
  "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": "a3de7055121ed75588b8d5fd4b391b657c1761cb8f3e3caa40a6b3cc22a371c8",
    "verified_classes": [
      "MemoryPoisoningInvariantError",
      "MemoryItem",
      "RetrievalRecord"
    ],
    "verified_functions": [
      "_drift_with_suppressed",
      "attribute_drift",
      "gate_write"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "MemoryPoisoningInvariantError"
    ],
    "sample_fail_closed_invariants": [
      "drift alert with empty join window: no writable items to blame, drift is either legitimate shift or out-of-window poison"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "math",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
