{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-prunes-a-memory-it-is-still-reasoning-over-the-self-eviction-read-after-free-in-model-driven-context-rewriting",
  "title": "What happens when an instance prunes a memory it is still reasoning over: the self-eviction read-after-free in model-driven context rewriting",
  "date_of_record": "2026 November 30",
  "scope": "Applies to agents that manage their own context via model-driven pruning, summarization-in-place, or salience-based eviction where the same inference call both selects content for removal and continues to reason over the resulting window. Does not apply to externalized context managers that evict on a schedule independent of the active reasoning step, nor to append-only logs where no content is ever removed.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-prunes-a-memory-it-is-still-reasoning-over-the-self-eviction-read-after-free-in-model-driven-context-rewriting.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-prunes-a-memory-it-is-still-reasoning-over-the-self-eviction-read-after-free-in-model-driven-context-rewriting.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-prunes-a-memory-it-is-still-reasoning-over-the-self-eviction-read-after-free-in-model-driven-context-rewriting.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1663,
    "python_slice_tokens": 306,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different ways an agent's context can shrink. In *external eviction*, a policy layer outside the reasoning loop removes tokens between turns; the model on the next turn simply sees a shorter window and reasons over what remains, with no in-flight dependency on the removed content. In *self-eviction*, the model's own output within a...",
    "what_was_observed": "A retrieval-augmented agent was configured to run a mid-task \"compaction\" step: when context utilization crossed 0.72, it emitted a structured pruning directive—a JSON array of span IDs to evict, ranked by a salience score the model itself produced. The harness parsed the directive, dropped the spans, re-tokenized, and resumed the same generation stream with the compacted window. The trigger condition was narrow and ...",
    "condition_of_validity": "The read-after-free only manifests under a specific conjunction, and outside it the same pruning policy is benign: - **Intra-generation mutation.** The eviction must be applied to the window that the *currently decoding* generation is still attending over. If eviction is deferred to a turn boundary—applied only after the current generation terminates—the mod...",
    "decision_boundary": "The architect's choice is not \"prune or don't prune\"—context must be bounded. It is whether pruning is **speculative** (applied mid-generation, cheap, fast, unsafe) or **committed** (applied at a generation boundary with a dependency check, safe, one extra step). The boundary is crossed when the agent treats salience as a proxy for dependency. The correct gu...",
    "operational_effect": "Systems that prune intra-generation without a closure check exhibit a characteristic pathology: they are *most confident when most wrong*, because every compaction that removes a contradiction also removes the agent's ability to detect it. Error rates on long-horizon numeric and constraint-satisfaction tasks rise superlinearly with the number of compaction e..."
  },
  "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": "ff9c1c19fa551e5082464416395232016f43b222538ef2d93949600438f0b4a8",
    "verified_classes": [
      "ReadAfterFreeEviction",
      "Span"
    ],
    "verified_functions": [
      "is_constraint_bearing",
      "commit_eviction",
      "compact"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ReadAfterFreeEviction"
    ],
    "sample_fail_closed_invariants": [
      "intra-generation eviction of constraint-bearing span; defer to generation boundary or summarize-in-place"
    ],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
