{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-a-self-edit-whose-diff-validates-but-whose-rollback-base-is-stale",
  "title": "When must an instance refuse a self-edit whose diff validates but whose rollback base is stale",
  "date_of_record": "2026 November 25",
  "scope": "Applies to single-instance agents that mutate their own working memory (scratchpad, episodic buffer, plan graph) via proposed diffs gated by a validator and a rollback snapshot. Does not cover multi-agent baton-passing or external vector-store memory, where the rollback base is owned by another process.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-a-self-edit-whose-diff-validates-but-whose-rollback-base-is-stale.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-a-self-edit-whose-diff-validates-but-whose-rollback-base-is-stale.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-a-self-edit-whose-diff-validates-but-whose-rollback-base-is-stale.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1765,
    "python_slice_tokens": 292,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *diff validity* and *rollback fidelity*. A diff validator answers one question: \"Does applying this patch to the current buffer produce a well-formed buffer?\" It typically checks schema conformance, reference integrity, and forbidden-token constraints. It does **not** answer: \"Can I still restore the pre-edit state if ...",
    "what_was_observed": "A planning agent maintains a working-memory buffer of task nodes. Each self-edit follows a three-phase protocol: (1) `snapshot()` captures the buffer, (2) `propose_diff()` emits a structured patch, (3) `validate_and_apply()` runs the validator and commits. Rollback is `restore(last_snapshot)`. The observed trace, condensed: - **t0** — Buffer B0 = `{A, B, C}`. Agent snapshots → S0 = B0. - **t1** — A *tool-driven* muta...",
    "condition_of_validity": "The self-edit protocol is only sound when, for every applied diff `d` computed against buffer `B_edit` and paired with snapshot `S`, the following holds at apply time: `S ⊆ B_edit` **and** every element in `B_edit \\ S` is either (a) re-derivable from `S` by a deterministic replay, or (b) tagged as *non-rollbackable* and excluded from the rollback contract. I...",
    "decision_boundary": "The boundary is sharp and must be decided *before* the diff is applied, not at rollback time: - If `B_edit == S` (no out-of-band mutation since snapshot), the diff is safe to apply and rollback is exact. **Proceed.** - If `B_edit ⊃ S` and all delta elements are replayable from `S`, the diff is safe; rollback will replay the delta. **Proceed, but record the r...",
    "operational_effect": "When the boundary is enforced, the observable change is that self-edits occasionally *refuse* even though their diffs validate—specifically whenever a tool call has landed since the last snapshot. This refusal is correct and must not be suppressed by retry logic that \"just re-validates the diff,\" because re-validating the diff does not refresh the base. When..."
  },
  "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": "3726fda1a1080d11db1cf2cc6ecc37d9c3cf658c287d989615b61e34df721141",
    "verified_classes": [
      "StaleRollbackBaseError",
      "Snapshot"
    ],
    "verified_functions": [
      "_hash",
      "apply_self_edit",
      "rollback"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "StaleRollbackBaseError"
    ],
    "sample_fail_closed_invariants": [
      "Snapshot content hash does not match recorded lineage; snapshot was mutated out of band."
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
