{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-freeze-its-own-context-rewrite-loop-to-prevent-budget-feedback-divergence-in-self-editing-working-sets",
  "title": "In what scenarios must an instance freeze its own context-rewrite loop to prevent budget-feedback divergence in self-editing working sets",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agents whose context controller is itself an LLM-driven or heuristic rewriting loop that mutates the working set under a hard token budget, where the rewrite's own output is re-admitted into the working set. Does not apply to append-only context managers, external summarizers invoked once per turn, or systems where the budget is enforced by a tokenizer gate that rejects rather than truncates.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-freeze-its-own-context-rewrite-loop-to-prevent-budget-feedback-divergence-in-self-editing-working-sets.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-freeze-its-own-context-rewrite-loop-to-prevent-budget-feedback-divergence-in-self-editing-working-sets.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-freeze-its-own-context-rewrite-loop-to-prevent-budget-feedback-divergence-in-self-editing-working-sets.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1980,
    "python_slice_tokens": 286,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different ways a self-editing context controller can spend budget. In the **allocation** regime, the controller decides which existing spans survive a truncation pass; the token cost of the decision is paid by the runtime, not charged against the working set. In the **generative** regime, the controller emits new text — a summary, ...",
    "what_was_observed": "A planning agent ran a per-turn context controller with a 32k working-set budget and a rewrite trigger at 85% occupancy. The controller prompt instructed it to \"compress the working set to fit the budget, preserving all open task state.\" On a long tool-use trace, the following trace repeated across runs: - Turn N: occupancy 27.4k / 32k. Trigger fires. Controller emits a 6.1k-token compacted working set plus a 900-tok...",
    "condition_of_validity": "The divergence requires all of the following to hold simultaneously; remove any one and the loop is bounded: 1. **Re-admission.** Controller output is fed back into the working set on the next pass. If the controller's output is stored out-of-band (a side channel the controller reads but that does not count against budget), the loop cannot inflate. 2. **Self...",
    "decision_boundary": "The operational rule is a **freeze predicate**, evaluated before each rewrite, that halts the controller and escalates rather than letting it run. Freeze when the rewrite is expected to be net-negative on budget. Concretely, maintain per working-set lineage: - `last_freed` = tokens_in − tokens_out of the previous rewrite. - `last_cost` = tokens the previous ...",
    "operational_effect": "Freezing converts an unbounded, non-deterministic failure (controller collapse) into a bounded, deterministic one (lossy truncation with a known handoff record). In the observed system, adding the freeze predicate at `last_cost >= last_freed` eliminated the divergence: rewrite cycles stabilized at 2–3 per lineage, working-set occupancy settled at 60–70% of b..."
  },
  "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": "6be2a9948606f0628535e2b635a4822fac0d59a56aa7305f9addcda3bb681411",
    "verified_classes": [
      "ContextRewriteDivergence",
      "LineageBudget"
    ],
    "verified_functions": [
      "assert_rewrite_safe",
      "apply_rewrite"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ContextRewriteDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
