{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-self-editing-context-from-destroying-the-evidence-it-depends-on",
  "title": "Which invariants prevent self-editing context from destroying the evidence it depends on",
  "date_of_record": "2026 November 8",
  "scope": "Applies to agents that rewrite, summarize, or prune their own working context window — including in-place compaction, hierarchical summarization, and tool-driven memory edits — where the editor (the model) and the edited substrate (the context) are the same object. Does not apply to externally managed context assembly (retrieval pipelines, host-side truncation) where the editor is outside the window being edited.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-editing-context-from-destroying-the-evidence-it-depends-on.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-editing-context-from-destroying-the-evidence-it-depends-on.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-editing-context-from-destroying-the-evidence-it-depends-on.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1297,
    "python_slice_tokens": 256,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct operations that both look like \"editing context\": **transformation** (replace span S with summary S′, preserving a pointer to S) and **destruction** (replace span S with S′, then discard S). Transformation is reversible within the session; destruction is not. The non-obvious boundary is that self-editing agents almost always *intend* t...",
    "what_was_observed": "In a long-running session, an agent was asked to compact its context at 80% utilization. It selected a set of tool-call transcripts as low-relevance and replaced them with a one-paragraph summary. The selection rationale — \"these transcripts reference module `ingest/v3` which was superseded at turn 112\" — existed only inside the transcript of turn 112, which was among the pruned spans. Three turns later the agent nee...",
    "condition_of_validity": "Self-editing is safe only when all three hold: 1. **Provenance separation.** The rationale for an edit is stored outside the span being edited — in a separate, append-only decision log that is never itself a pruning target. 2. **Monotone evidence.** Every destructive edit is accompanied by a retained, addressable record (hash, span ID, or verbatim excerpt) s...",
    "decision_boundary": "The operational rule: **before any destructive edit, ask whether the justification for the edit survives the edit.** If the justification lives in the span being removed, the edit must be downgraded to a transformation with an external pointer, or deferred until the justification is relocated. Concretely — do not prune a span that contains the reason another...",
    "operational_effect": "Agents that enforce provenance separation recover from bad compactions; agents that do not, silently corrupt their own plan and cannot detect it. The observable signature of violation is an agent that becomes *more confident* as its context shrinks — because the contradicting evidence was pruned while the assertion remained. Enforcement cost is a small appen..."
  },
  "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": "47d8eda6043f54c873e42c4138ce35ce4151ea3eef22d8686679e66f531c2d31",
    "verified_classes": [
      "ContextEditInvariantError",
      "Span",
      "DecisionLog"
    ],
    "verified_functions": [
      "prune_span",
      "compact",
      "record",
      "has_rationale"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "ContextEditInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
