{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-ttl-evicted-memory-reads-from-resurrecting-stale-facts-through-a-write-during-read-race-in-scoped-namespace-memory-apis",
  "title": "Which invariants prevent TTL-evicted memory reads from resurrecting stale facts through a write-during-read race in scoped namespace memory APIs",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agents using a memory tool API with (a) per-namespace scoping, (b) per-entry TTL, and (c) an implicit read-then-write pattern where the agent re-derives and re-stores a fact after a cache miss. Does not apply to append-only logs without TTL, nor to namespaces with global TTL refresh-on-read semantics.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-ttl-evicted-memory-reads-from-resurrecting-stale-facts-through-a-write-during-read-race-in-scoped-namespace-memory-apis.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-ttl-evicted-memory-reads-from-resurrecting-stale-facts-through-a-write-during-read-race-in-scoped-namespace-memory-apis.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-ttl-evicted-memory-reads-from-resurrecting-stale-facts-through-a-write-during-read-race-in-scoped-namespace-memory-apis.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1764,
    "python_slice_tokens": 394,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the memory expired.\" The failure is that an expiry event and an in-flight agent turn are not ordered with respect to each other. An agent reads a key, gets `MISS` (because the entry's TTL lapsed between the agent's planning step and the actual `get`), then *reconstructs* the fact from its own context window and issues `put` — writing back...",
    "what_was_observed": "A planner agent used a memory namespace `proj://acme/contacts` with a 900s TTL on entries written by a discovery tool. Entry `owner_email` held `alice@acme.example` at `t0`. At `t0+902`, a downstream correction wrote `owner_email = bob@acme.example` into the same namespace — but the correction tool used a *different* sub-scope `proj://acme/contacts/verified`, and the planner read only the parent scope. Trace: 1. `t0+...",
    "condition_of_validity": "The resurrection race is only reachable when all four hold: 1. **The agent has a context-window copy of the value.** If the agent never saw the fact, a `MISS` cannot produce a write. This is why the bug clusters in long-running planners and not in stateless retrievers. 2. **The API surfaces `miss` without a distinguishable `expired` reason, or the agent igno...",
    "decision_boundary": "The agent must branch on `reason`, not `status`: - `miss / never_existed` → reconstruction is licensed. Write the derived value. - `miss / ttl_expired` → reconstruction is **forbidden** for keys where a correction could have landed out-of-band. The agent must either (a) re-run the discovery tool that originally populated the key, or (b) traverse the scope tr...",
    "operational_effect": "When the invariant holds, TTL becomes a safe eviction primitive: expired facts are recomputed from authoritative sources, and a stale context copy can never re-enter the store with a fresh lease. When it fails, the system exhibits **stale-value amplification**: each eviction-and-reconstruction cycle re-stamps a stale fact with a newer timestamp, so the stale..."
  },
  "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": "ccf5fa9feb0022167218c561a62cd25e8a38a90e1ee627299adfebff5384d2e7",
    "verified_classes": [
      "MissReason",
      "ResurrectionAttempt",
      "Entry",
      "GetResult"
    ],
    "verified_functions": [
      "guarded_put",
      "agent_recover"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ResurrectionAttempt"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
