{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-refuse-to-rewrite-its-own-context-when-the-rewrite-operator-is-non-idempotent-under-re-entry",
  "title": "In what scenarios must an instance refuse to rewrite its own context when the rewrite operator is non-idempotent under re-entry",
  "date_of_record": "2026 November 26",
  "scope": "Applies to any agent loop where an LLM instance is permitted to mutate the working context it is currently operating on (summarize-and-replace, prune-irrelevant, compress-to-budget), and where that mutation can be re-triggered by the mutated context itself. Does not apply to append-only memory writes, external scratchpads the agent cannot edit, or single-shot prompt construction done before execution begins.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-rewrite-its-own-context-when-the-rewrite-operator-is-non-idempotent-under-re-entry.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-rewrite-its-own-context-when-the-rewrite-operator-is-non-idempotent-under-re-entry.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-refuse-to-rewrite-its-own-context-when-the-rewrite-operator-is-non-idempotent-under-re-entry.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2157,
    "python_slice_tokens": 421,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between a context rewrite that is a **function of immutable history** and one that is a **function of its own prior output**. Summarization pipelines are usually designed as if they sit in the first regime: you take the transcript, you produce a summary, you continue. But an LLM-driven rewriter that decides *what to prune base...",
    "what_was_observed": "A long-horizon research agent, budget 200k tokens, running a summarize-when-context-exceeds-70%-of-window policy. The rewriter was an LLM call instructed: \"Compress the conversation, preserving all facts relevant to the current objective.\" The current objective was itself part of the context being compressed. Trace of the failure, over four rewrite events: 1. **Rewrite 1 (turn ~40).** Context at 71%. The rewriter pro...",
    "condition_of_validity": "The rewrite loop is safe only under a conjunction that is rarely checked: - **P1 (Frozen anchor).** The objective and its constraints are stored outside the rewritable region and re-injected verbatim after every rewrite, never summarized. If the objective is inside the compressed span, drift is unbounded. - **P2 (Provenance pointer).** Every claim in a rewri...",
    "decision_boundary": "The decision the instance must make at each rewrite trigger is not \"is the context too big\" but \"**is the material I am about to compress derived from source or from a prior rewrite?**\" - If the span to be compressed is **source-derived** (raw turns, tool outputs, user messages), rewrite is permitted under P1 and P3. - If the span contains **prior-rewrite ou...",
    "operational_effect": "Enforcing provenance separation changes the failure mode from silent drift to loud budget exhaustion. In the trace above, the turn-85 rewrite would have hit a frozen claim (\"no match in `src/`,\" source evicted, no pointer) and been required to either retrieve the source or halt. Either outcome is correct; the silent widening is not. The cost is that some tas..."
  },
  "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": "ec7ec382ef79161f58c96aece7df26faebc3306dc73f83d08512f7354550b20f",
    "verified_classes": [
      "UnanchorableRewriteError",
      "ScopeWideningError",
      "Claim",
      "RewriteState"
    ],
    "verified_functions": [
      "rewrite",
      "_is_widening",
      "_token_equivalent",
      "_size"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ScopeWideningError",
      "UnanchorableRewriteError"
    ],
    "sample_fail_closed_invariants": [
      "budget cannot be met without pruning unanchorable claims; fail closed",
      "rewrite operator non-idempotent on source; refusing second-order rewrite"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
