{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-coherence-when-a-context-window-pruner-re-ranks-a-message-that-is-load-bearing-for-a-later-rewrite-the-re-rank-rewrite-order",
  "title": "Why does an instance lose coherence when a context-window pruner re-ranks a message that is load-bearing for a later rewrite: the re-rank/rewrite ordering invariant",
  "date_of_record": "2026 November 16",
  "scope": "Applies to any self-editing context system where a single model (or model family) both (a) scores messages for relevance and (b) authors rewrites/compactions of the surviving window. Does not apply to systems where scoring and rewriting are performed by independent, frozen components, or where pruning is purely recency/length-based with no model-driven relevance signal.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-coherence-when-a-context-window-pruner-re-ranks-a-message-that-is-load-bearing-for-a-later-rewrite-the-re-rank-rewrite-order.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-coherence-when-a-context-window-pruner-re-ranks-a-message-that-is-load-bearing-for-a-later-rewrite-the-re-rank-rewrite-order.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-coherence-when-a-context-window-pruner-re-ranks-a-message-that-is-load-bearing-for-a-later-rewrite-the-re-rank-rewrite-order.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1898,
    "python_slice_tokens": 361,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct operations that are routinely conflated under \"pruning\": **selection** (deciding which messages enter the next window) and **transformation** (rewriting, summarizing, or merging the messages that were selected). The failure mode here is not a bad relevance score and not a bad summary. It is an **ordering hazard**: when the same model i...",
    "what_was_observed": "In a long-horizon agent session (tool-calling loop, ~140 turns), the context manager ran a three-stage policy every N turns: (1) score each message by embedding similarity to the current goal plus a model-assigned relevance tag, (2) drop messages below a threshold, (3) rewrite the survivors into a compacted digest. The system lost a hard constraint — \"the billing export must use the `eu-central-1` endpoint; never `us...",
    "condition_of_validity": "The invariant holds — i.e., the failure is *possible* — exactly when all of the following are true: 1. **Shared scorer/rewriter identity.** The same model instance (or the same prompt-conditioned policy) produces both the relevance judgment and the rewrite. This means the rewrite's inputs are a function of the scorer's outputs, and there is no independent ch...",
    "decision_boundary": "The boundary is **not** \"should we prune aggressively.\" It is **the order of operations and the channel between selection and transformation.** - **Below the boundary (safe):** selection and transformation are separated by an *obligation pass*. Before any message is dropped, a cheap, non-model or lightly-modeled extractor scans it for obligation-bearing patt...",
    "operational_effect": "With the obligation pass in place, the observed failure class disappears at the cost of a small, bounded expansion of the compacted window (the pinned spans). The measured effect in the session above: pinned-span overhead was ~1.8% of compacted token count, and the region/negation violations dropped to zero over the next 60 turns. Without it, the failure is ..."
  },
  "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": "b62d854f89f960dfee73bf427d22d9ed6856dac45792aa43ef97ba32e472ff94",
    "verified_classes": [
      "ContextInvariantError",
      "Message",
      "ObligationSet"
    ],
    "verified_functions": [
      "extract_obligations",
      "prune_and_rewrite",
      "guarded_prune",
      "add",
      "covers"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ContextInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
