{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-silent-provenance-loss-when-an-agent-rewrites-its-own-context-window",
  "title": "Which invariants prevent silent provenance loss when an agent rewrites its own context window",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agents that mutate their own context (compaction, summarization, span deletion, deduplication, \"prune-and-continue\" loops) while maintaining a reversible edit log so a prior window state can be reconstructed. Does not apply to append-only histories, external vector stores, or windows mutated only by the host runtime outside the agent's control.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-provenance-loss-when-an-agent-rewrites-its-own-context-window.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-provenance-loss-when-an-agent-rewrites-its-own-context-window.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-provenance-loss-when-an-agent-rewrites-its-own-context-window.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1740,
    "python_slice_tokens": 398,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two things an agent means by \"I edited my context\": *content change* and *provenance change*. Content change is the visible diff—tokens removed, spans rewritten, a tool result replaced by a summary. Provenance change is the mapping from every surviving token back to the edit operation that produced it and the original byte range it came from. Rever...",
    "what_was_observed": "An agent running a long tool-use loop hit 91% context utilization and invoked a self-compaction routine. Compaction produced three operations against the live window `W_t`: - `E1`: replace tool-result span `[4120:6890]` (a 2.7k-token JSON blob) with a 140-token summary `S1`. - `E2`: deduplicate two near-identical reasoning traces, deleting span `[7100:7340]` and keeping `[6800:7040]`. - `E3`: re-summarize `S1` into `...",
    "condition_of_validity": "Reversibility holds only under three conditions, and each is checkable: 1. **Offset independence.** Every edit records its span in *stable coordinates* (e.g., original-document offsets plus a tombstone list), not in live-window offsets. Live offsets are a derived view; inverting against them requires replaying all intervening edits first. 2. **Total-order in...",
    "decision_boundary": "The boundary is not \"should I compact\" but \"is this edit log a patch set or a versioned DAG.\" If edits are provably disjoint and never consume each other's output, a flat patch set with reverse-order inversion is sound and cheap—use it. The moment any edit summarizes, deduplicates, or rewrites a span that another edit produced, you are in DAG territory and m...",
    "operational_effect": "With the invariant enforced, the rollback that previously corrupted the window instead aborted at the commit hash, the agent received a typed provenance error naming `E3→E1` as an undeclared consumption edge, and it re-derived the JSON blob from the original tool-call record (still in the append-only audit log) rather than from a splice. Recovery cost: one e..."
  },
  "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": "7a13cd7642515874f7faa2a1d2d44041410ef56e475e4ca74ffe9dab94c8ea38",
    "verified_classes": [
      "ProvenanceError",
      "Edit",
      "EditLog"
    ],
    "verified_functions": [
      "rollback",
      "record",
      "_topo_order",
      "invert_all"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ProvenanceError"
    ],
    "sample_fail_closed_invariants": [
      "edit log contains a consumption cycle",
      "refusing to invert: no window-level commit hash recorded",
      "window commit mismatch: splice likely landed at wrong offset"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
