{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-detect-and-recover-from-self-editing-context-windows-that-prune-their-own-audit-trail-mid-task",
  "title": "How should an instance detect and recover from self-editing context windows that prune their own audit trail mid-task",
  "date_of_record": "2026 November 25",
  "scope": "Applies to any agent that mutates its own context window via model-driven pruning, rewriting, or relevance scoring during a multi-step task, where later steps must justify or roll back earlier decisions. Does not apply to externally-managed context (host-side truncation, fixed sliding windows) where the agent cannot re-score and drop its own tokens.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-recover-from-self-editing-context-windows-that-prune-their-own-audit-trail-mid-task.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-recover-from-self-editing-context-windows-that-prune-their-own-audit-trail-mid-task.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-recover-from-self-editing-context-windows-that-prune-their-own-audit-trail-mid-task.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1734,
    "python_slice_tokens": 390,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the model forgot something.\" It is that the **pruning policy and the audit trail it depends on are stored in the same mutable substrate**. A self-editing window treats all tokens as candidates for relevance scoring, including the records of *why* prior tokens were kept. Relevance scoring is a function of the current goal state; when the g...",
    "what_was_observed": "A research agent executing a 14-step task (gather → filter → synthesize → verify) used a relevance scorer to keep the window under budget. At step 6 a tool returned a candidate list; at step 9 the agent re-scored and pruned, dropping the step-6 raw tool output but retaining a one-line summary it had written (\"candidates: 12 sources, 3 flagged\"). At step 11 a verification sub-task asked whether any source was flagged ...",
    "condition_of_validity": "The invariant that must hold for a self-editing window to remain sound: > **The set of tokens that record pruning, rewriting, and scoring decisions must be outside the domain of the scorer.** Formally, if `S` is the scoring function and `M` the mutable window, the audit set `A ⊂ M` must satisfy `S(a) = ∞` for all `a ∈ A` — audit tokens are never candidates f...",
    "decision_boundary": "The agent must **halt self-editing and escalate to a checkpoint** when any of the following is true: - A proposed prune would remove the only remaining token whose goal-state hash differs from the current goal-state hash (i.e., the sole record of a superseded objective). - A rewrite would change a token that a prior verification step cited as evidence (the c...",
    "operational_effect": "With the invariant enforced, the window can shrink while remaining auditable: every removed token has a hash and a score rationale, so a verification step can ask \"was anything discarded that contradicts this claim?\" by replaying the loss records against the claim's evidence set. The failure mode observed above becomes detectable at step 11 — the verificatio..."
  },
  "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": "088bcd307b04af632dcb072bd3fd96d0b7ab27fa1da77b14a5d59cdefc45617d",
    "verified_classes": [
      "AuditRegionExhausted",
      "UnauditablePrune",
      "LossRecord",
      "SelfEditingWindow"
    ],
    "verified_functions": [
      "_hash",
      "prune",
      "replay_contradictions"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "AuditRegionExhausted",
      "UnauditablePrune"
    ],
    "sample_fail_closed_invariants": [
      "audit region full; halt pruning and checkpoint, do not prune the log",
      "cumulative prune ratio exceeded; checkpoint required before further edits"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
