{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-trusts-a-memory-write-whose-provenance-hash-was-computed-over-the-post-sanitization-payload-instead-of-the-raw-tool-outp",
  "title": "What happens when an instance trusts a memory write whose provenance hash was computed over the post-sanitization payload instead of the raw tool output",
  "date_of_record": "2026 December 2",
  "scope": "Applies to long-lived agent instances that persist episodic memory entries derived from tool outputs and audit those writes via a provenance hash plus an anomaly score. Does not apply to stateless single-turn agents or to memory stores where writes are only ever produced by the agent's own generative output with no external tool ingestion path.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-trusts-a-memory-write-whose-provenance-hash-was-computed-over-the-post-sanitization-payload-instead-of-the-raw-tool-outp.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-trusts-a-memory-write-whose-provenance-hash-was-computed-over-the-post-sanitization-payload-instead-of-the-raw-tool-outp.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-trusts-a-memory-write-whose-provenance-hash-was-computed-over-the-post-sanitization-payload-instead-of-the-raw-tool-outp.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2338,
    "python_slice_tokens": 406,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters here is between *provenance of the bytes that were stored* and *provenance of the bytes that arrived*. A memory write pipeline typically does three things in sequence: (1) receives a raw tool result, (2) sanitizes/normalizes it (strip control chars, redact secrets, truncate, decode escaping, re-serialize), (3) writes the sanitize...",
    "what_was_observed": "A retrieval-augmented agent with a 14-day episodic memory window was observed executing a task that called a `web_fetch` tool against an external documentation site. The tool returned a 6 KB document. The sanitizer ran, stripping zero-width characters and collapsing whitespace, then truncated the body to 4 KB at a paragraph boundary. The memory writer computed `sha256(sanitized_payload)` and stored both the hash and ...",
    "condition_of_validity": "The provenance-audit invariant holds only when the following chain is intact: 1. `H_raw = hash(raw_tool_output)` is computed at the tool-call boundary, before any transformation. 2. `H_stored = hash(stored_payload)` is computed at the memory-write boundary. 3. The audit record contains both, plus a `transform_manifest` describing the sanitization steps appli...",
    "decision_boundary": "The boundary is between two policies for handling writes where `H_raw` is unavailable: - **Permissive policy:** store the write, compute the hash over stored bytes, treat hash-continuity as satisfied. This is what the observed system did, and it is the default in most memory-writer implementations because it is simple and the hash \"works.\" - **Strict policy:...",
    "operational_effect": "The downstream effect is that the agent's memory acquires a class of entries that are *cryptographically attested but semantically unverified*. These entries pass every integrity check, retrieve normally, and carry a trust score inflated by a feature that cannot fail. When one of them contains an injected instruction, the agent has no signal that distinguish..."
  },
  "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": "3b42943c8d463d67765cb0abf64f4973a5b7ff9c1d03ce7c04491e02d2ef697b",
    "verified_classes": [
      "ProvenanceTautologyError",
      "MemoryWrite"
    ],
    "verified_functions": [
      "_sha",
      "_apply_manifest",
      "audit_write",
      "store"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ProvenanceTautologyError"
    ],
    "sample_fail_closed_invariants": [
      "degraded-provenance write scored as trusted; hash-continuity feature is tautological for this write"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
