{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-ttl-expired-memory-from-resurrecting-through-a-stale-write-back-cache-during-scoped-persistence",
  "title": "Which invariants prevent TTL-expired memory from resurrecting through a stale write-back cache during scoped persistence",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agent memory tool APIs that expose `read`/`write`/`forget` over scoped, TTL-bearing records, where the agent runtime maintains any local or in-process cache of retrieved records and later writes them back. Does not apply to stateless key-value stores with no agent-side caching layer, nor to append-only logs where deletion is represented as a tombstone event the agent never re-emits.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-ttl-expired-memory-from-resurrecting-through-a-stale-write-back-cache-during-scoped-persistence.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-ttl-expired-memory-from-resurrecting-through-a-stale-write-back-cache-during-scoped-persistence.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-ttl-expired-memory-from-resurrecting-through-a-stale-write-back-cache-during-scoped-persistence.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2112,
    "python_slice_tokens": 394,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the agent forgot to check the TTL.\" It is that **TTL is a property of the store's clock, while the agent's belief about a record's freshness is a property of the agent's cache and its own reasoning loop.** These two clocks diverge, and the divergence is invisible to the agent because `read` returns the record payload without a monotonical...",
    "what_was_observed": "A long-horizon research agent was configured with a scoped memory namespace `project:atlas`, records carrying a 5-minute TTL, and a `forget(record_id)` API the orchestrator invoked on task completion to satisfy a \"no residue after task\" deletion guarantee. The agent's loop interleaved `read` of working notes with tool calls to an external search API (each ~20–40s latency under load), so a single task step could span ...",
    "condition_of_validity": "The resurrection is possible exactly when all three hold: - **(a) Unconditional upsert semantics.** `write(key, value)` succeeds whether or not the key currently exists or is live. This is the default of most KV-backed memory tools. - **(b) Agent-side caching of read payloads across a window longer than the TTL.** This is normal for any agent whose reasoning...",
    "decision_boundary": "The agent runtime must decide, per `write`, whether the write is a **create** or an **update**, and the store must be the authority on which is legal: - If the agent's last observed state for the key was `live` at version `v`, the write MUST be issued as `write_if_version(key, v, value)`. On conflict (`version_mismatch` or `not_found`), the agent MUST NOT re...",
    "operational_effect": "With the invariant enforced, the step-5 write returns `VersionConflict(expected=4, actual=not_found)`. The agent's loop catches it, re-reads, gets `not_found`, and is forced into a re-derivation path — costing one extra tool round-trip and some tokens, but preserving the deletion guarantee. The audit at step 6 finds the namespace clean. Without it, the failu..."
  },
  "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": "951d74bf9805093e8dff888d5ec03bd5724f4d1018a595dce795540f673a7cbd",
    "verified_classes": [
      "MemoryResurrectionError",
      "VersionConflictError",
      "Record",
      "ScopedStore"
    ],
    "verified_functions": [
      "agent_write_back",
      "_live",
      "read",
      "forget",
      "write_if_version"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "MemoryResurrectionError",
      "VersionConflictError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
