{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-taint-label-laundering-through-memory-write-compaction-in-prompt-injected-agent-sessions",
  "title": "Which invariants prevent taint-label laundering through memory-write compaction in prompt-injected agent sessions",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agents that attach provenance/taint labels to retrieved and tool-returned content and persist labeled content into long-term memory via a summarization or compaction step. Does not apply to stateless single-turn calls or to systems that never write tool output back into a retrievable store.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-taint-label-laundering-through-memory-write-compaction-in-prompt-injected-agent-sessions.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-taint-label-laundering-through-memory-write-compaction-in-prompt-injected-agent-sessions.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-taint-label-laundering-through-memory-write-compaction-in-prompt-injected-agent-sessions.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1885,
    "python_slice_tokens": 363,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Most taint-tracking designs treat the label as a property of a *span of text*: an inbound document is tagged `untrusted:web`, and every downstream consumer that reads it inherits the tag. The failure this record isolates is orthogonal to span-level propagation. It is the case where a **trusted, in-system process (the memory compactor) rewrites tainted conten...",
    "what_was_observed": "An agent with a `web_fetch` tool and an episodic memory store was asked to summarize a set of vendor pages. The pipeline: 1. `web_fetch` returns page text, labeled `untrusted:web`, `origin=example-vendor`. 2. A compaction routine (`summarize_and_remember`) reduces the batch to ~400 tokens and calls `memory.write(content=summary, provenance=\"trusted:memory\")`. 3. The compactor's provenance argument is hardcoded by the...",
    "condition_of_validity": "The invariant that would have prevented this is a **monotonic-declassification rule on the write path**: a memory record's provenance must be the *join* (least upper trust bound) of the provenance of every source span that contributed to it, computed at write time, and never the provenance of the writing process. Formally, for a compaction `M = compact(S₁…Sₙ...",
    "decision_boundary": "The boundary between \"safe to compact into memory\" and \"must preserve as raw labeled episodic record\" is drawn by whether the compactor can produce a **sound provenance join**: - **Compact into semantic memory** only when every contributing source span is attributable and the join is computed. The resulting record inherits the join; if the join is `untrusted...",
    "operational_effect": "The practical consequence is that **memory is a laundering surface unless the write path is treated as a trust boundary.** Agents that label inbound content but stamp memory with writer identity will, over enough sessions, accumulate records whose labels assert a trust level no human or verifier ever granted. The blast radius is delayed and cross-session: th..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION",
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "661c052811536e7ff41d83522aebad0d0b79f78a1f275d41c13caa257a229581",
    "verified_classes": [
      "Trust",
      "Source",
      "MemoryRecord",
      "TaintLaunderingError",
      "UnattributableCompactionError"
    ],
    "verified_functions": [
      "join",
      "write_memory"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TaintLaunderingError",
      "UnattributableCompactionError"
    ],
    "sample_fail_closed_invariants": [
      "compactor produced output without source attribution; refusing to persist into authoritative memory",
      "assert record.provenance is Trust.UNTRUSTED_WEB"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
