{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-bound-model-driven-context-rewriting-before-the-rewrite-loop-consumes-the-task-budget-it-was-meant-to-protect",
  "title": "Where must an instance bound model-driven context rewriting before the rewrite loop consumes the task budget it was meant to protect",
  "date_of_record": "2026 November 20",
  "scope": "Applies to single-agent loops that let the model itself decide which spans of its own context to prune, summarize, or rewrite mid-task (self-editing context). Does not apply to externally scheduled compaction, fixed-window truncation, or retrieval-only memory systems where the model cannot mutate its own working set.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-model-driven-context-rewriting-before-the-rewrite-loop-consumes-the-task-budget-it-was-meant-to-protect.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-model-driven-context-rewriting-before-the-rewrite-loop-consumes-the-task-budget-it-was-meant-to-protect.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-model-driven-context-rewriting-before-the-rewrite-loop-consumes-the-task-budget-it-was-meant-to-protect.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1860,
    "python_slice_tokens": 152,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different ways a context window shrinks. The first is *eviction*: a deterministic policy (FIFO, LRU, token-threshold truncation) removes spans without consulting the model. Eviction is cheap and idempotent — it cannot loop, because it does not ask the model for an opinion. The second is *model-driven rewriting*: the instance is han...",
    "what_was_observed": "A long-horizon research agent was given a 128k window, a `rewrite_context` tool, and a soft policy: \"keep your context under 96k tokens; summarize or drop spans you no longer need.\" The task was a 40-step document-analysis pipeline with tool calls returning 2–8k tokens each. At step ~22 the context crossed 96k. The model began rewriting. The trace showed a repeating cycle: 1. Model selects a span to summarize (a prio...",
    "condition_of_validity": "Model-driven rewriting is only sound under a **headroom invariant** that must be checked before the rewrite is authorized, not after: where `cost(rewrite_turn)` is an *estimate made before the call* (span tokens + fixed prompt overhead + expected output tokens), and `reserve` is the minimum budget the task needs to finish (final synthesis, last tool call, an...",
    "decision_boundary": "The boundary between \"rewrite is the correct action\" and \"rewrite must be refused\" is a single scalar comparison, and it must be enforced by the harness, not the model: The critical cell is the third row. When headroom is below `cost + reserve`, the correct behavior is *not* to attempt a cheaper rewrite — it is to stop rewriting and either evict deterministi...",
    "operational_effect": "When the headroom invariant is enforced, three observable changes appear in traces. First, rewrite turns stop clustering at saturation — they occur earlier, when spans are large and headroom is ample, so net reclamation is strongly positive and one or two rewrites clear the threshold. Second, the \"no forward progress for N steps\" signature disappears, becaus..."
  },
  "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": "62179fc0da958ad98eb47fe4f4ded1348a01b5b96e2d7e2c8b3adf2f0fd19eeb",
    "verified_classes": [
      "RewriteBudgetViolation"
    ],
    "verified_functions": [
      "authorize_rewrite"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "RewriteBudgetViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
