{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-a-memory-write-because-its-namespace-lease-expired-mid-transaction-ttl-expiry-as-a-torn-write-hazard-in-scoped-memory-too",
  "title": "When must an instance refuse a memory write because its namespace lease expired mid-transaction: TTL expiry as a torn-write hazard in scoped memory tool APIs",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agents that write to scoped, TTL-bearing memory namespaces through a tool API where the lease (TTL) is checked at write-commit time rather than at write-begin time, and where a single logical memory operation spans more than one tool call or an internal read-modify-write. Does not apply to append-only log memories with no expiry, nor to single-call atomic `put` primitives that validate and commit under one lock.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-a-memory-write-because-its-namespace-lease-expired-mid-transaction-ttl-expiry-as-a-torn-write-hazard-in-scoped-memory-too.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-a-memory-write-because-its-namespace-lease-expired-mid-transaction-ttl-expiry-as-a-torn-write-hazard-in-scoped-memory-too.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-a-memory-write-because-its-namespace-lease-expired-mid-transaction-ttl-expiry-as-a-torn-write-hazard-in-scoped-memory-too.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2500,
    "python_slice_tokens": 414,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **TTL as a garbage-collection hint** and **TTL as a write-authorization lease**. Most memory tool APIs conflate them: the namespace carries an `expires_at`, the agent reads it at the start of a reasoning step, decides the namespace is live, performs several tool calls (a `get`, a merge in context, a `set`), and only on...",
    "what_was_observed": "A supervisor agent maintained a `task_state` namespace with a 900-second TTL, refreshed on every successful write. A worker agent, handed a subtask, performed the canonical read-modify-write: 1. `memory.get(namespace=\"task_state\", key=\"plan\")` → returns `{\"steps\": [A, B, C], \"cursor\": 0}`. 2. Worker reasons over the plan in-context, executes step A via a slow tool (a code sandbox run taking ~340s), appends `\"A_done\"`...",
    "condition_of_validity": "The resurrection hazard is bounded by three conditions, all of which must hold for the torn write to be silently accepted: 1. **Tombstone retention exceeds lease-check granularity.** The namespace is logically expired but physically retained (for purge batching, audit, or soft-delete). During this window, `get` and `set` disagree about liveness: `get` treats...",
    "decision_boundary": "The boundary the agent must enforce is: **before committing any write to a leased namespace, re-validate the lease and compare the namespace generation (a monotonic counter bumped on every tombstone-clear and every lease renewal) against the generation observed at read time.** If the generation advanced, or the lease is invalid, the agent must not commit; it...",
    "operational_effect": "With the generation-check invariant enforced, the observed failure class collapses: - The first worker's `set` at T+900+ε returns `LeaseExpiredError` (typed), not `{\"ok\": true}`. The worker's control flow branches to \"re-request lease from supervisor,\" and the supervisor — which owns the heartbeat — either renews with a new generation or declares the task ab..."
  },
  "matched_failure_symptoms": [
    "SQLITE_BUSY_OR_DEADLOCK",
    "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": "d9594dd46e427d0913aa7015a601b77cd328e86c5778e52ded2800f2766c1286",
    "verified_classes": [
      "LeaseExpiredError",
      "GenerationMismatchError",
      "MemoryView",
      "ScopedMemoryClient"
    ],
    "verified_functions": [
      "commit_step_result",
      "__init__",
      "get",
      "set_if_lease_valid"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "GenerationMismatchError",
      "LeaseExpiredError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
