{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-self-pruning-agents-from-deleting-the-precondition-of-their-own-rewrite",
  "title": "Which invariants prevent self-pruning agents from deleting the precondition of their own rewrite",
  "date_of_record": "2026 November 22",
  "scope": "Applies to agents that mutate their own context window mid-task via model-driven pruning/rewriting (summarize-and-drop, salience-based eviction, self-editing scratchpads). Does not apply to externally-scheduled compaction performed by a deterministic harness that snapshots state before mutation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-pruning-agents-from-deleting-the-precondition-of-their-own-rewrite.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-pruning-agents-from-deleting-the-precondition-of-their-own-rewrite.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-pruning-agents-from-deleting-the-precondition-of-their-own-rewrite.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2327,
    "python_slice_tokens": 704,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A self-editing context window differs from ordinary context management in one fatal way: the policy that decides *what to delete* is itself evaluated *using tokens that are candidates for deletion*. Pruning is not a read-only observation of state; it is a write that can remove the very evidence the pruner relied on to justify the write. The failure is not \"t...",
    "what_was_observed": "An agent running a long tool-calling loop maintained a scratchpad with a running list of \"load-bearing facts\" — e.g. `FACT: prod DB host is db-prod-7, do not touch db-prod-3 (deprecated, read-replica lag)`. Mid-task, context pressure triggered the self-prune policy. The model was asked to rewrite the window to fit budget and produced a compact summary: it kept the *task* (\"migrate schema on prod DB\") and dropped the ...",
    "condition_of_validity": "Self-editing pruning is sound only under an invariant we can state precisely: > **Warrant-Preservation Invariant (WPI):** For every context segment `s` deleted at step `t`, there must exist a justification record `J(s)` that (a) is not itself a deletion candidate at `t`, (b) is sufficient to reconstruct *why* `s` was droppable, and (c) is checked against `s`...",
    "decision_boundary": "The boundary is whether the prune decision and the prune justification are in the same trust domain. - **Same domain (unsafe):** model reads window → model decides → model rewrites window. Justification is a token sequence inside the mutable region. WPI is unenforceable. This is the default when an agent is given a `rewrite_context()` tool and no external le...",
    "operational_effect": "In production this manifests as *silent constraint erosion*: the agent completes tasks that should have been blocked, and the post-mortem shows a clean, well-formed context with no trace of the constraint because the constraint's deletion was itself compressed away. Logs look healthy. The failure is invisible to context inspection precisely because it succee..."
  },
  "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": "672ec3fbdcf5780320a761b87e1f920417e5aa4e4507c5c4b02a8b897aec500f",
    "verified_classes": [
      "WarrantViolation",
      "Segment",
      "Warrant",
      "SelfPruneGuard"
    ],
    "verified_functions": [
      "unsafe_self_prune",
      "guarded_prune_and_act",
      "content_hash",
      "__init__",
      "propose_prune",
      "commit",
      "assert_action_allowed"
    ],
    "verified_functions_count": 7,
    "defensive_guards_count": 8,
    "raised_exceptions": [
      "WarrantViolation"
    ],
    "sample_fail_closed_invariants": [
      "assert 'protected' in str(e)",
      "unexpected: warrant for f1 should not block the recorded target"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
