{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-prune-its-own-context-the-self-edit-reentrancy-hazard",
  "title": "When must an instance refuse to prune its own context: the self-edit reentrancy hazard",
  "date_of_record": "2026 November 10",
  "scope": "Applies to agents that hold a mutable context window and are themselves responsible for deciding what to prune, rewrite, or re-rank inside that window. Does not apply to externally scheduled compaction performed by a supervisor process holding a read-only view of the transcript.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-prune-its-own-context-the-self-edit-reentrancy-hazard.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-prune-its-own-context-the-self-edit-reentrancy-hazard.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-prune-its-own-context-the-self-edit-reentrancy-hazard.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1413,
    "python_slice_tokens": 314,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The dangerous distinction is not \"prune vs. keep\" but **whether the pruning decision is itself part of the context being pruned**. A model-driven self-editor reads the window, emits an edit plan (delete span A, rewrite span B, re-rank span C), and then applies that plan to the same window. The plan's *justification* — the reasoning tokens that concluded \"A i...",
    "what_was_observed": "In a 60-turn session with a 32k-token window and a 24k-token soft cap, the editor was instructed to prune low-relevance spans after each turn. At turn 41 the editor removed a 900-token tool-output block (a stale `kubectl describe` dump) and its own 140-token justification. At turn 43 the agent re-ran the same `kubectl describe` because no record remained that it had already been run and judged stale; the output re-en...",
    "condition_of_validity": "Self-editing is safe only when all three hold: 1. **Provenance separation.** The edit plan and its rationale are stored outside the prunable region — in an append-only edit log the editor cannot delete, or in a supervisor-owned sidecar. The window may be pruned; the *log of prunings* may not. 2. **Tombstoning.** Every pruned span leaves a non-deletable tombs...",
    "decision_boundary": "The boundary is crossed the moment the editor's own output becomes an input to its own scoring function within the same turn or the next turn without an intervening tombstone. Concretely, refuse to self-edit when: - the candidate span overlaps the rationale span (edit plan references tokens it is about to delete); - the candidate span is tagged `constraint` ...",
    "operational_effect": "Agents that respect the boundary show stable summary convergence: the rolling summary's claims about prior turns match the tombstone log, and re-retrieval of pruned content is bounded by explicit overrides. Agents that violate it exhibit the oscillation described above — prune/re-admit cycles, drifting summaries, and lost constraints — with no size-based ala..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "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": "67e5c9df97f92038b105b301710a5ba270701826104d5adbffe19a0489f412dd",
    "verified_classes": [
      "SelfEditInvariantError",
      "Span"
    ],
    "verified_functions": [
      "apply_self_edit",
      "content_hash"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SelfEditInvariantError"
    ],
    "sample_fail_closed_invariants": [
      "editor is not authorized to mutate its own window; escalate to supervisor"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
