{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-self-editing-of-its-own-context-window-as-a-transactional-mutation-rather-than-an-in-place-rewrite-and-what-i",
  "title": "In what scenarios must an instance treat self-editing of its own context window as a transactional mutation rather than an in-place rewrite, and what invariant breaks when it does not",
  "date_of_record": "2026 November 26",
  "scope": "Applies to any agent that mutates its own working context through structured edit operations (block replace, span delete, region summarize, anchor-insert) issued by the model itself and applied to the live context buffer between reasoning steps. Does not apply to append-only scratchpads, external memory stores updated out-of-band, or human-driven prompt editing.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-self-editing-of-its-own-context-window-as-a-transactional-mutation-rather-than-an-in-place-rewrite-and-what-i.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-self-editing-of-its-own-context-window-as-a-transactional-mutation-rather-than-an-in-place-rewrite-and-what-i.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-self-editing-of-its-own-context-window-as-a-transactional-mutation-rather-than-an-in-place-rewrite-and-what-i.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2330,
    "python_slice_tokens": 745,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two ways a model can \"rewrite its own context\": *append-only composition*, where new content is added and prior tokens are never touched, and *in-place mutation*, where an edit operation replaces or deletes a span that the model is still reasoning over, including the very span that defines the edit's own preconditions. The second is the dangerous o...",
    "what_was_observed": "A long-horizon agent was given a context buffer of ~180k tokens and a `context_edit` tool with operations `replace(start, end, text)`, `delete(start, end)`, and `summarize(start, end)`. Offsets were computed by the model from a numbered rendering of the buffer. The agent was instructed to periodically compress its own working set: \"keep the task spec, the last three tool results, and a rolling summary; delete the res...",
    "condition_of_validity": "The in-place model is only sound under a conjunction that is almost never satisfied in practice: - **Single-edit transactions.** At most one mutating edit per reasoning step, so no intra-batch offset drift is possible. - **Content anchors, not offsets.** Each edit names a stable anchor (a hash of the target span, or a unique sentinel token) and the runtime r...",
    "decision_boundary": "The boundary is between **edits that are recoverable from the model's own trace** and **edits that destroy the evidence needed to detect their own misfire**. - A `delete` of a region the model can reconstruct from its reasoning trace is recoverable: if it lands wrong, the model can notice the missing content on next read and re-derive it. - A `delete` or `su...",
    "operational_effect": "The practical consequence is that self-editing context must be implemented as a **transactional mutation with content-addressed anchors and mandatory post-commit re-grounding**, not as a sequence of in-place splices. The runtime, not the model, owns offset resolution and rebasing; the model expresses intent (\"remove the stale plan block identified by sentine..."
  },
  "matched_failure_symptoms": [
    "SQLITE_BUSY_OR_DEADLOCK"
  ],
  "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": "4e879fc147f5b3a0f9a20ac3171b480182d484823cacb343fdaa134bd3240d11",
    "verified_classes": [
      "AnchorResolutionError",
      "ProtectedRegionViolation",
      "Span",
      "ContextBuffer"
    ],
    "verified_functions": [
      "_hash",
      "compress_working_set",
      "snapshot",
      "apply_transaction",
      "render_for_model"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "AnchorResolutionError",
      "ProtectedRegionViolation"
    ],
    "sample_fail_closed_invariants": [
      "no protected task-spec span present; refusing to compress because the constraint list cannot be guaranteed to survive",
      "stale plan anchor <<PLAN_v3>> not found; cannot safely delete"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
