{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-reject-in-place-context-rewrites-that-invalidate-the-provenance-anchors-of-already-emitted-tool-calls",
  "title": "In what scenarios must an instance reject in-place context rewrites that invalidate the provenance anchors of already-emitted tool calls",
  "date_of_record": "2026 November 26",
  "scope": "Applies to agents that mutate their own context window mid-task (compaction, dedup, relevance pruning) while holding live tool-call results or pending continuations. Does not apply to append-only context managers or to stateless single-turn inference where no prior tool result must be re-referenced.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-in-place-context-rewrites-that-invalidate-the-provenance-anchors-of-already-emitted-tool-calls.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-in-place-context-rewrites-that-invalidate-the-provenance-anchors-of-already-emitted-tool-calls.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-reject-in-place-context-rewrites-that-invalidate-the-provenance-anchors-of-already-emitted-tool-calls.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1900,
    "python_slice_tokens": 448,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A context rewrite is *safe* when every prior message it removes or collapses is no longer referenced by any live continuation. It is *unsafe* when the rewrite severs the referential binding between a tool call already emitted (with its `tool_call_id`) and the assistant message that will resume from that result. The distinction is not \"does the rewrite lose i...",
    "what_was_observed": "An agent executing a 14-step retrieval-and-synthesis task hit 82% context saturation at step 9. Its self-editing policy ran two passes: (1) semantic dedup over tool results, collapsing near-identical search-result payloads to a single canonical copy; (2) relevance pruning that scored each message against a rolling task embedding and dropped the lowest-scoring 20%. The dedup pass kept the *earliest* copy of a duplicat...",
    "condition_of_validity": "An in-place rewrite is valid only if it satisfies the **anchor-closure invariant**: for every assistant message retained in the window that contains a `tool_call` block, the corresponding `tool` result message with the identical `tool_call_id` is also retained, and vice versa. Formally, let `A` be the set of retained assistant tool-call IDs and `R` be the se...",
    "decision_boundary": "The operational boundary is this: **rewrite only at quiescent points where no tool call is outstanding.** A quiescent point is a step boundary where the last message is a completed assistant turn with no pending `tool_call` awaiting a result. If saturation forces a rewrite mid-tool-cycle (a call emitted, result not yet returned, or result returned but contin...",
    "operational_effect": "The practical consequence is that self-editing context policies must be split into two layers with different invariants. The **structural layer** (which messages and IDs exist) is governed by anchor-closure and idempotence and may only shrink at quiescent points. The **content layer** (how many tokens each retained message occupies) is governed by relevance ..."
  },
  "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": "ae7e5c0d58f95b679a6552dd832ba46b967532ec3c0ec0e4e7bdac3293bb0284",
    "verified_classes": [
      "AnchorClosureViolation",
      "Message",
      "ContextWindow"
    ],
    "verified_functions": [
      "assert_anchor_closure",
      "safe_rewrite",
      "call_ids",
      "result_ids"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "AnchorClosureViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
