{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-rewrites-its-own-context-window-and-evicts-the-evidence-it-still-needs",
  "title": "What happens when an instance rewrites its own context window and evicts the evidence it still needs",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agents that mutate their own context (summarization, compaction, relevance-scored eviction, scratchpad rewriting) between reasoning steps. Does not apply to append-only context managers or external retrievers that never delete tokens from the live window.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-context-window-and-evicts-the-evidence-it-still-needs.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-context-window-and-evicts-the-evidence-it-still-needs.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-context-window-and-evicts-the-evidence-it-still-needs.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1547,
    "python_slice_tokens": 305,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the context got too long.\" It is that **the relevance score used to evict a span is computed against a query that the eviction itself changes.** Self-editing context is a feedback loop: the evictor scores spans against the current task representation, drops the low scorers, and in doing so mutates the task representation that the *next* e...",
    "what_was_observed": "A planning agent runs a rewrite pass every N tool calls: it asks the model to produce a running summary of \"what matters,\" then evicts spans whose embedding similarity to that summary falls below τ, keeping a fixed token budget. A user constraint was captured at step 2 as a raw tool output: By step 9 the agent had drifted into a subtask about refund latency. The rewrite pass summarized the window as \"optimize refund ...",
    "condition_of_validity": "The guardrail below is valid only under these conditions, and the failure is *unbounded* outside them: - **Eviction is irreversible within the episode.** If evicted spans remain retrievable by exact key from an external store, the failure degrades to a latency cost, not a correctness loss. The dangerous regime is the one where the rewrite is the *only* copy....",
    "decision_boundary": "The boundary is not a token count. It is: **does the rewrite pass have authority to delete a span that no surviving span can reconstruct?** - If every evicted span is either (a) reconstructible from a pinned anchor, or (b) provably non-constraining, eviction is safe. - The moment a rewrite pass evicts a span whose operative parameters (numbers, identities, n...",
    "operational_effect": "The required invariant: **constraint spans are eviction-immune and pinned by verbatim copy; the eviction scorer is anchored to the pinned set, not to the rolling summary; and every eviction emits a tombstone (span hash + reason + anchor reference) so the deletion is auditable against the pre-edit state.** A rewrite pass that cannot produce a tombstone for a ..."
  },
  "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": "2f8ee47a62503e28ea4683f67b73e6f2f12ea1f228db0b13f78722c0e0d51e1e",
    "verified_classes": [
      "ContextRewriteViolation",
      "Span",
      "Tombstone",
      "Window"
    ],
    "verified_functions": [
      "commit_rewrite",
      "digest"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ContextRewriteViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
