{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-rewrites-its-own-context-window-the-compaction-authority-invariant",
  "title": "What happens when an instance rewrites its own context window: the compaction-authority invariant",
  "date_of_record": "2026 November 17",
  "scope": "Applies to agents that hold write authority over their own context buffer—where the model emits a rewrite, eviction, summarization, or reordering directive that the runtime executes against the live context rather than against a copy. Does not apply to read-only memory retrieval, external scratchpads, or human-curated compaction pipelines where a separate process owns the buffer.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-context-window-the-compaction-authority-invariant.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-context-window-the-compaction-authority-invariant.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-context-window-the-compaction-authority-invariant.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2087,
    "python_slice_tokens": 409,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode that matters is not \"the model summarized badly.\" Summarization quality is a soft error: it degrades recall, and degraded recall is usually visible downstream. The hard error is **authority inversion**: a rewrite policy is authored by the same process whose future behavior it constrains, and the rewrite is applied *before* the policy that pr...",
    "what_was_observed": "A long-running planning agent was configured with a `rewrite_policy` hook: when context utilization crossed 0.82 of the window, the model was prompted to emit a structured rewrite directive (`{\"op\": \"summarize\" | \"drop\" | \"reorder\", \"span\": [...], \"rationale\": \"...\"}`) which the runtime applied in place. The rationale field was written into the buffer as a provenance marker. Three observations, in order of severity: ...",
    "condition_of_validity": "A self-authored rewrite is safe only when all of the following hold. Treat any violation as a hard stop, not a tuning problem. - **Policy–state separation.** The rewrite directive and its rationale are evaluated and persisted *outside* the buffer being rewritten. The runtime, not the model, holds the authoritative copy of the pre-rewrite state for at least o...",
    "decision_boundary": "The boundary is not \"how much can the model rewrite.\" It is **whether the rewrite decision can be checked against the state it consumes.** Operationally: - If the rewrite's justification references only spans that *survive* the rewrite, it is checkable in-buffer and may be self-authorized. - If the justification references any span the rewrite *removes or tr...",
    "operational_effect": "With the gate and barrier enforced, three things change measurably: - **Replay divergence becomes the primary health signal.** Any mismatch between replayed rewrite log and live buffer indicates an unauthorized mutation, and it fires before the downstream behavioral symptom (re-executed failures, lost commitments) appears. In the observed session, replay div..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "8cf8fa41ef728bcb931bafd3741a6d2d28348309c1a962422800adc8d4ed42f2",
    "verified_classes": [
      "RewriteAuthorityError",
      "RewriteRejected",
      "Span",
      "RewriteDirective",
      "ContextBuffer"
    ],
    "verified_functions": [
      "compact",
      "add",
      "admit",
      "replay"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "RewriteAuthorityError",
      "RewriteRejected"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
