{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-tombstone-resurrection-when-a-forget-call-races-a-background-distillation-pass-in-scoped-agent-memory",
  "title": "Which invariants prevent tombstone resurrection when a forget call races a background distillation pass in scoped agent memory",
  "date_of_record": "2026 November 26",
  "scope": "Applies to agent memory services exposing explicit `write`, `read`, and `forget` tool APIs where deletions must be verifiable (GDPR Art. 17) and where an asynchronous distillation/consolidation pass rewrites episodic records into semantic store entries. Does not apply to stateless retrieval caches with TTL-only eviction or to stores where deletion and distillation share a single serialized writer.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-tombstone-resurrection-when-a-forget-call-races-a-background-distillation-pass-in-scoped-agent-memory.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tombstone-resurrection-when-a-forget-call-races-a-background-distillation-pass-in-scoped-agent-memory.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tombstone-resurrection-when-a-forget-call-races-a-background-distillation-pass-in-scoped-agent-memory.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1744,
    "python_slice_tokens": 429,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A `forget` call that returns `200 OK` is a claim about the *primary* record, not about the *derived* records that a distillation worker may be concurrently materializing from an in-flight snapshot of that record. The failure mode is **tombstone resurrection**: the forget transaction commits, the tombstone is written, and milliseconds later the distillation w...",
    "what_was_observed": "A tenant invoked `forget(user_id, memory_id)` on an episodic record containing a PII-bearing sentence. The forget handler: (1) wrote a tombstone row `(memory_id, epoch=7, deleted_at)`, (2) hard-deleted the episodic row, (3) queried the semantic store by `source_memory_id = memory_id`, found zero rows (the distillation had not yet committed), and (4) returned `deleted: true, verified: true`. The distillation worker ha...",
    "condition_of_validity": "The epoch-fence invariant is only sound when all of the following hold simultaneously: 1. **Single epoch authority.** Tombstones and derived writes read the epoch from one monotonic counter per `(tenant, user)` scope, not per-store. If the semantic store maintains its own epoch, the fence is vacuous. 2. **Write-time check, not read-time check.** The distilla...",
    "decision_boundary": "The boundary is between two defensible designs, and the choice is forced by latency budget: - **Fence-and-reject (default).** Distillation writes fail with a `StaleEpochError` when `source_epoch < current_epoch`. The worker discards the summary and does not retry the forgotten source. Cost: wasted LLM tokens on raced records; benefit: deletion is linearizabl...",
    "operational_effect": "After adopting the epoch-fence, the failure trace becomes: distillation worker reads episodic at `epoch=6`, forget commits tombstone at `epoch=7` and advances the scope epoch, worker attempts semantic insert with `source_epoch=6`, the write-time CAS `WHERE 6 >= (SELECT epoch FROM scope_epoch WHERE scope=...)` returns zero rows affected, the worker raises `St..."
  },
  "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": "c08b3643d2f8f2e79e4702032f0ebba00c82ae0e293d524a617105b4afaf5e59",
    "verified_classes": [
      "StaleEpochError",
      "VerificationIncompleteError",
      "ScopeEpoch",
      "MemoryStore"
    ],
    "verified_functions": [
      "advance",
      "__init__",
      "_scope",
      "write_episodic",
      "forget",
      "distill_write"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "StaleEpochError",
      "VerificationIncompleteError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
