{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-in-place-instruction-rewriting-has-corrupted-the-context-window-s-semantic-anchor",
  "title": "What structural signals indicate in-place instruction rewriting has corrupted the context window's semantic anchor",
  "date_of_record": "2026 December 1",
  "scope": "Applies to agents that mutate their own context window via in-place instruction rewriting or diff-based context edits (search/replace patches, span rewrites, anchor-based splicing) rather than append-only or full-regeneration strategies. Does not apply to append-only context management or to external memory stores that are re-read from scratch.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-in-place-instruction-rewriting-has-corrupted-the-context-window-s-semantic-anchor.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-in-place-instruction-rewriting-has-corrupted-the-context-window-s-semantic-anchor.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-in-place-instruction-rewriting-has-corrupted-the-context-window-s-semantic-anchor.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2242,
    "python_slice_tokens": 392,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Append-only context management is *monotonic*: every prior token remains addressable, so a rewrite can only add noise, never silently destroy the referent of an existing instruction. In-place rewriting breaks monotonicity. When an agent edits its own context by patching spans — replacing `\"use the staging endpoint\"` with `\"use the production endpoint\"`, or c...",
    "what_was_observed": "A planning agent maintains a rolling instruction block at the head of its window and a scratchpad of tool results below. On each turn it emits a diff that rewrites the instruction block in place to reflect new sub-goals. In a traced run that failed, the sequence was: 1. Turn 4: instruction block contains `TASK: reconcile invoices; CONSTRAINT: read-only, do not POST.` A tool result at offset ~9k establishes `endpoint ...",
    "condition_of_validity": "The invariant that in-place rewriting must preserve is **single-binding referential integrity**: at every point between rewrite application and the next read, each literal or anaphoric referent that any live instruction depends on must have exactly one authoritative binding, and that binding must be the one the instruction resolves against. This invariant ho...",
    "decision_boundary": "The operational choice is between two rewrite disciplines, and the boundary is determined by whether anchors can be made unique and referents can be tracked. **Permit in-place rewriting** only when the window enforces anchor uniqueness by construction: every mutable literal is stored in a keyed slot (a named cell), and diffs address slots by key, not by text...",
    "operational_effect": "When the invariant is enforced, the observable effect is that rewrite failures become *loud and local*: a duplicate-anchor diff raises at application time, a referent-severing deletion is blocked or tombstoned, and the agent's next read either sees a coherent single-binding window or an explicit invalidation marker. The failure mode shifts from silent misapp..."
  },
  "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": "d701e01da5069c23a4b848ce654d23282165421c4bc612eb6261455103352982",
    "verified_classes": [
      "ContextRewriteError",
      "Slot",
      "ContextWindow"
    ],
    "verified_functions": [
      "rewrite_endpoint",
      "apply_search_replace",
      "apply_delete"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ContextRewriteError"
    ],
    "sample_fail_closed_invariants": [
      "endpoint slot is absent or tombstoned; cannot rewrite",
      "live endpoint value is echoed in a quoted region; textual rewrite is unsafe in this window until the alias is removed or"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
