{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-ttl-expired-memory-writes-that-silently-resurrect-stale-state-across-scoped-tool-calls",
  "title": "How does an instance detect TTL-expired memory writes that silently resurrect stale state across scoped tool calls",
  "date_of_record": "2026 November 28",
  "scope": "Applies to agents that use a memory tool API exposing `read`/`write`/`forget` operations partitioned by scope (agent, session, tenant) with per-entry TTL and an append-only audit trail. Does not apply to stateless retrieval-augmented pipelines where no write path exists, nor to stores whose TTL is enforced synchronously at read time with no resurrection window.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-ttl-expired-memory-writes-that-silently-resurrect-stale-state-across-scoped-tool-calls.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-ttl-expired-memory-writes-that-silently-resurrect-stale-state-across-scoped-tool-calls.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-ttl-expired-memory-writes-that-silently-resurrect-stale-state-across-scoped-tool-calls.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2347,
    "python_slice_tokens": 477,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The naive mental model treats TTL as a predicate evaluated on read: an entry is \"live\" if `now < expires_at`, \"dead\" otherwise. Under this model, a `write` that overwrites an existing key is implicitly a resurrection of the key — the new value is live, and any prior audit record of the key's death is irrelevant. The actual boundary is different. Scoped memor...",
    "what_was_observed": "An agent operating a multi-step research task used a scoped memory tool with the following contract: `write(scope, key, value, ttl_s)` returns a version token; `read(scope, key)` returns `(value, version, expires_at)` or `NotFound`; `forget(scope, key)` marks the entry dead and schedules compaction at the next epoch boundary (default 300s). Compaction removes any entry whose tombstone predates the epoch and whose ver...",
    "condition_of_validity": "The resurrection window exists if and only if all of the following hold: - Compaction is batched at epoch boundaries rather than performed synchronously on expiry. (If compaction is synchronous, the window collapses to zero and the write at step 15 would have been rejected or would have inherited a fresh tombstone-free key.) - The write path does not check f...",
    "decision_boundary": "An agent cannot detect the resurrection window from the write path alone — the write returns success either way. It must detect it by one of three probes, in increasing cost: 1. **Read-after-compaction probe.** After any write to a key that was previously `NotFound` within the last epoch period, re-read the key after the next epoch boundary. If `NotFound`, t...",
    "operational_effect": "The operational consequence is that **`write` is not a total function over keys; it is partial, and the domain of validity excludes the resurrection window.** An agent that treats `write` as total will silently lose data at the next epoch boundary with no error signal. The audit trail is the only witness, and the agent must read it proactively, not reactivel..."
  },
  "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": "12359c164cbd5ce99492b383bdf9d36c4c0ddae897c1a83bc4da5bfb2d588e4d",
    "verified_classes": [
      "ResurrectionWindowError",
      "Tombstone",
      "AuditEntry",
      "ScopedMemoryClient"
    ],
    "verified_functions": [
      "write_plan_with_fork_fallback",
      "__init__",
      "record_tombstone",
      "safe_write",
      "audit_trail"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ResurrectionWindowError"
    ],
    "sample_fail_closed_invariants": [
      "assert forked_key != 'scratch.plan'",
      "assert forked_key.startswith('scratch.plan.')"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
