{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-prompt-rewrite-starvation-in-self-editing-context-windows",
  "title": "Which invariants prevent prompt-rewrite starvation in self-editing context windows",
  "date_of_record": "2026 November 18",
  "scope": "Applies to agents that mutate their own prompt/context during a single logical turn via runtime rewriting and relevance pruning, where the rewritten context is re-fed into the same model instance for the next step. Does not apply to stateless single-shot inference, nor to systems where rewriting is performed by a separate, non-iterating process that commits a final context once.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-prompt-rewrite-starvation-in-self-editing-context-windows.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-prompt-rewrite-starvation-in-self-editing-context-windows.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-prompt-rewrite-starvation-in-self-editing-context-windows.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1836,
    "python_slice_tokens": 363,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not \"the context got too small\" or \"the pruner dropped the wrong document.\" It is **rewrite starvation**: a self-editing loop in which each pruning pass removes material that a *later* pass needs to justify its own pruning decisions, so the loop converges toward an empty-but-confident context. The distinction that matters is between *rele...",
    "what_was_observed": "In a loop that performed runtime prompt rewriting every step, with a pruner scoring chunks by relevance to the current step's query, the following sequence reproduced reliably: 1. Step *n* prunes a set of chunks `D_n` as irrelevant to subgoal *g_n*. The pruning rationale (a short note: \"dropped D_n because they describe subsystem X, not in scope\") is written into the context. 2. Step *n+1* has subgoal *g_{n+1}* that ...",
    "condition_of_validity": "The safety argument for iterative relevance pruning holds only under the following invariant, which must be enforced structurally rather than by prompt instruction: > **Provenance-closure invariant:** For every chunk `c` retained in the context, every chunk `d` whose content was used to justify retaining or dropping `c` must also be retained, or its justific...",
    "decision_boundary": "The boundary between safe and unsafe rewriting is whether the rewrite is **reversible from retained state**. Concretely: - **Safe to prune:** chunk bodies whose identifiers and admission rationale live in the pinned stratum, and whose content is not cited by any retained chunk. - **Unsafe to prune:** rationale notes, decision logs, the task statement, and an...",
    "operational_effect": "Enforcing provenance-closure changes the loop's behavior in three measurable ways. First, token count is no longer monotonic — it drops then plateaus at the size of the pinned stratum plus the live working set, which is the correct floor. Second, the pruner must run a closure check before committing a rewrite, which costs one pass over the `cites` graph per ..."
  },
  "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": "89ce3a1af9bbd9212a5ffabbc94e7557bc26634aa195d650fa07fca3d0a9a96a",
    "verified_classes": [
      "ProvenanceClosureError",
      "Chunk",
      "Context"
    ],
    "verified_functions": [
      "_closure_ok",
      "apply_rewrite",
      "rewrite_loop",
      "all_chunks"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ProvenanceClosureError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
