{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-corrupt-its-own-audit-trail-when-it-rewrites-context-tokens-in-place-instead-of-appending",
  "title": "Why does an instance corrupt its own audit trail when it rewrites context tokens in place instead of appending",
  "date_of_record": "2026 November 27",
  "scope": "Applies to single-agent instances that mutate their live context buffer via in-place token rewriting (summarization-in-place, scratchpad compaction, self-edit of prior tool output) while relying on positional or offset-based provenance to reconstruct what was actually observed. Does not apply to append-only context architectures or to externalized logs written before mutation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-corrupt-its-own-audit-trail-when-it-rewrites-context-tokens-in-place-instead-of-appending.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-corrupt-its-own-audit-trail-when-it-rewrites-context-tokens-in-place-instead-of-appending.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-corrupt-its-own-audit-trail-when-it-rewrites-context-tokens-in-place-instead-of-appending.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2062,
    "python_slice_tokens": 437,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different ways an agent can \"edit its own memory.\" The safe pattern is **append-and-supersede**: the original token span is retained, a new span is added, and a supersession pointer records which span replaced which. The unsafe pattern is **in-place rewrite**: the agent overwrites the existing span with a compressed or corrected ve...",
    "what_was_observed": "An instance executing a multi-step retrieval-and-synthesis task used a self-editing scratchpad to hold intermediate tool outputs. On step 6, the buffer approached its soft token budget. The instance invoked an in-place compaction routine that replaced three prior tool-result spans (a JSON payload, a diff, and a log tail) with a single LLM-generated summary occupying a shorter span, then shifted subsequent tokens down...",
    "condition_of_validity": "The invariant that in-place rewriting violates can be stated precisely: > **Provenance Integrity Invariant:** For any provenance record `p` that resolves to content `c`, either `hash(c) == p.content_hash` (content-identity provenance), or `p` is invalidated and marked stale at the moment of any mutation that changes the byte range `p` refers to (location pro...",
    "decision_boundary": "The boundary between safe and unsafe self-editing is crossed at the moment the instance chooses **rewrite-in-place** over **append-and-supersede** under budget pressure. The decision rule: - If remaining budget ≥ cost of appending a supersession record + summary → **append and supersede**. Never rewrite. The original spans remain, provenance stays valid, and...",
    "operational_effect": "The downstream consequences compound: 1. **Verifier capture.** The self-check reads mutated provenance and confirms the mutated content. The verifier is not broken; it is faithfully checking against a corrupted ground truth. False-negative rate on provenance-dependent errors approaches 100%. 2. **Silent divergence.** The instance's stated reasoning and its r..."
  },
  "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": "86f4e7910d29b80877b5c2a1d546d76aaa4d0a24aef5d9aefada948a78c3d7b7",
    "verified_classes": [
      "ProvenanceIntegrityError",
      "Span",
      "Provenance",
      "SelfEditingBuffer"
    ],
    "verified_functions": [
      "self_edit_under_budget",
      "__post_init__",
      "__init__",
      "append",
      "read",
      "rewrite_in_place"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ProvenanceIntegrityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
