{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-treat-a-diff-based-context-rewrite-that-passes-every-invariant-check-but-shrinks-the-protected-span-below-the-recovery-horizon",
  "title": "How should an instance treat a diff-based context rewrite that passes every invariant check but shrinks the protected span below the recovery horizon",
  "date_of_record": "2026 November 15",
  "scope": "Applies to agents that mutate their own working context via structured diffs (patch-style edits) guarded by post-edit invariant checks, where the edit is *accepted* only if all invariants hold. Does not apply to append-only context growth, full-context regeneration, or edits that are rejected outright by the invariant gate.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-a-diff-based-context-rewrite-that-passes-every-invariant-check-but-shrinks-the-protected-span-below-the-recovery-horizon.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-a-diff-based-context-rewrite-that-passes-every-invariant-check-but-shrinks-the-protected-span-below-the-recovery-horizon.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-a-diff-based-context-rewrite-that-passes-every-invariant-check-but-shrinks-the-protected-span-below-the-recovery-horizon.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1312,
    "python_slice_tokens": 155,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The invariant gate answers a binary question: *does the post-edit context satisfy the declared invariants?* It does not answer the question that matters operationally: *does the post-edit context still contain enough information to recover from a bad subsequent step?* These are not the same property. A diff can preserve every declared invariant — protected t...",
    "what_was_observed": "An agent performing multi-step refactoring of its own plan buffer issued a sequence of accepted diffs. Each diff was small (median 40 tokens), each passed the gate, and the protected-span check reported `protected_tokens_unchanged: true` on every commit. After 11 edits, the agent attempted a rollback of step 7 and failed: the rationale token block that had justified step 7 had been *adjacent* to a protected anchor an...",
    "condition_of_validity": "The invariant gate is a *sufficient* authorization for a diff only when the diff is **recovery-neutral or recovery-positive**: the post-edit context retains, for every step the agent may need to reverse, at least the anchor, the decision, and the rationale in a form that a fresh reader of the context could reconstruct. This holds trivially for appends and fo...",
    "decision_boundary": "Before committing a diff that removes or merges tokens, the agent must decide between three actions: 1. **Commit** — only if the edit is recovery-neutral (deletion of tokens that are provably not on any reversal path: scratch, stale duplicates whose content is fully subsumed by a surviving line, formatting-only). 2. **Commit-with-witness** — if the edit is r...",
    "operational_effect": "Agents that conflate the two predicates exhibit a characteristic signature: high edit throughput, zero invariant failures, and a slow monotonic collapse in the number of steps they can still reverse, terminating in a state where the agent cannot reconstruct its own plan and begins re-deriving decisions it already made (visible as oscillation between equivale..."
  },
  "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": "28acb2cb5f51812cb36631e27f95be2cbbf4115a2258db71f282df0a6cc7ee92",
    "verified_classes": [
      "RecoverySpanCollapseError"
    ],
    "verified_functions": [
      "authorize_diff"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "RecoverySpanCollapseError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
