{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-rewrites-its-own-context-and-prunes-the-tool-call-provenance-that-later-verification-depends-on",
  "title": "What happens when an instance rewrites its own context and prunes the tool-call provenance that later verification depends on",
  "date_of_record": "2026 November 21",
  "scope": "Applies to any agent that performs model-driven context rewriting (summarization, pruning, deduplication, or compaction) mid-episode while retaining the ability to resume tool execution or emit a verification/replay record. Does not apply to append-only context logs with no in-episode rewriting, or to stateless single-turn calls with no resumable tool state.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-context-and-prunes-the-tool-call-provenance-that-later-verification-depends-on.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-context-and-prunes-the-tool-call-provenance-that-later-verification-depends-on.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-context-and-prunes-the-tool-call-provenance-that-later-verification-depends-on.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1885,
    "python_slice_tokens": 337,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two categorically different objects inside a running agent's context window, and model-driven rewriting treats them as one: - **Narrative state** — the reasoning trace, the plan, the running summary of what the agent believes it is doing. This is lossy by design. Summarizing it is safe and is the whole point of compaction. - **Provenance state** — ...",
    "what_was_observed": "A representative trace, compressed to the mechanism: 1. Agent executes a sequence of mutating tool calls: `create_branch`, `write_file(f, rev r40)`, `write_file(f, rev r41)`, `run_tests → fail`, `write_file(f, rev r42)`, `run_tests → pass`. Each result is a small structured record with a revision token. 2. Context crosses a high-water mark. The rewriting policy fires: it summarizes the last N turns into prose. The su...",
    "condition_of_validity": "Model-driven pruning is valid **only** when the following invariant holds across every rewrite: > **Provenance closure.** For every tool call that produced an externally visible effect and remains un-retired (i.e., not yet reconciled by a verification or commit step), the rewritten context must retain a *lossless, machine-parseable* record of: the call ident...",
    "decision_boundary": "The operational question is not \"should I compact?\" but \"which spans are eligible?\" Draw the boundary explicitly: - **Eligible for model-driven rewrite:** reasoning traces, discarded plans, superseded hypotheses, verbose tool *output* whose effect token has already been retired by a commit/verify step, conversational filler. - **Ineligible — must pass throug...",
    "operational_effect": "When provenance closure holds, compaction is a pure win: context shrinks, resume is idempotent, and replay reconciles because every un-retired effect is still addressable. When it fails, the failure surfaces late and misattributed — as a duplicate write, a precondition mismatch, or a \"verification replay discrepancy\" that looks like a tool or transport bug b..."
  },
  "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": "89506815318d73b76103ca92b9fee748a39027e57f1a92127096df4d8d660220",
    "verified_classes": [
      "ProvenanceClosureError",
      "EffectRecord",
      "RewriteResult"
    ],
    "verified_functions": [
      "rewrite_context",
      "_assert_provenance_closure",
      "resume_from"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ProvenanceClosureError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
