{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-provenance-laundered-memory-writes-from-surviving-retention-compaction-in-agent-memory-tool-apis",
  "title": "Which invariants prevent provenance-laundered memory writes from surviving retention compaction in agent memory tool APIs",
  "date_of_record": "2026 November 26",
  "scope": "Applies to agent memory tool APIs exposing `read`, `write`, and `forget` operations with per-record retention policy enforcement and provenance tagging, where compaction/expiry is executed asynchronously against a shared store. Does not apply to append-only, non-compacting memory stores or to single-agent in-process scratchpads with no retention semantics.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-provenance-laundered-memory-writes-from-surviving-retention-compaction-in-agent-memory-tool-apis.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-provenance-laundered-memory-writes-from-surviving-retention-compaction-in-agent-memory-tool-apis.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-provenance-laundered-memory-writes-from-surviving-retention-compaction-in-agent-memory-tool-apis.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2087,
    "python_slice_tokens": 398,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode here is not \"the agent forgot something.\" It is the inverse: **the agent's memory store retained a record that its provenance no longer authorized it to retain, because provenance was attached to the record body rather than to the retention decision.** Concretely: a `write` call carries a provenance envelope — `source_id`, `trust_class`, `de...",
    "what_was_observed": "A three-stage trace across a memory API with `write(body, provenance, retention_class)` and `forget(record_id, cascade=True)`: 1. **t0** — Agent writes episodic record `E1` with `trust_class=external_untrusted`, `retention_class=ephemeral` (`expires_at = t0 + 24h`), derived from a raw tool output. 2. **t1** — Distillation step reads `E1`, produces semantic record `S1` with `trust_class=derived`, `derived_from=[E1]`. ...",
    "condition_of_validity": "The invariant that must hold for any retention decision to be sound: > For every record `r` retained at compaction time `t`, either `r.provenance.derived_from == []` (a root), or there exists at least one `p ∈ r.provenance.derived_from` such that `p` is retained at `t` **and** `r.expires_at ≤ min(p.expires_at)` **and** `r.trust_class` is no higher than `max(...",
    "decision_boundary": "The architectural guardrail is to make retention a *computed* property of the live provenance graph, not a stored field, and to make the write path reject any derivation that would violate the three sub-conditions at write time rather than at compaction time. Operationally: - **Compute `expires_at` at compaction, not at write.** Store `retention_class` and l...",
    "operational_effect": "When the invariant is enforced, the observable behavior changes in three ways that matter to a running agent: 1. **`read` never returns a record with dangling provenance.** Callers can resolve lineage without a try/except around a missing parent. The cost is that `read` may return `None` for a record the agent \"knows\" it wrote — because the record was evicte..."
  },
  "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": "9c9d1dc6d53bdb3b555ac0896635cad3e4a4df53f450c53e83044ad9678fa117",
    "verified_classes": [
      "ProvenanceInvariantError",
      "Provenance",
      "MemoryRecord",
      "ProvenanceAwareStore"
    ],
    "verified_functions": [
      "__init__",
      "_live_parents",
      "write",
      "forget",
      "compact"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ProvenanceInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
