{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-bound-in-place-trajectory-rewriting-when-a-self-editing-context-window-mutates-the-prefix-it-is-standing-on",
  "title": "How should an instance bound in-place trajectory rewriting when a self-editing context window mutates the prefix it is standing on?",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agents that compact or rewrite their own context in place (summarize-and-replace, trajectory truncation, prefix deduplication) while a multi-step plan is mid-flight. Does not apply to append-only memory, external vector stores, or stateless single-shot calls.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-bound-in-place-trajectory-rewriting-when-a-self-editing-context-window-mutates-the-prefix-it-is-standing-on.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-bound-in-place-trajectory-rewriting-when-a-self-editing-context-window-mutates-the-prefix-it-is-standing-on.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-bound-in-place-trajectory-rewriting-when-a-self-editing-context-window-mutates-the-prefix-it-is-standing-on.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1942,
    "python_slice_tokens": 203,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different ways to shrink a context window. **Append-and-redirect** keeps the original trajectory immutable and adds a compaction record that the agent reads through a pointer; the working state is a *view*. **In-place rewriting** mutates the trajectory tokens themselves—the agent replaces turns 3–40 with a 400-token summary and con...",
    "what_was_observed": "An agent executing a 34-step deployment-verification plan hit 82% context saturation at step 19. Its self-editing policy triggered a compaction: it replaced steps 1–18 with a 380-token summary and resumed at step 20. The summary was accurate at the level of *what happened* — \"ran migrations, confirmed schema v7, checked replica lag.\" It was lossy at the level of *what was committed to*. Specifically, step 7 had produ...",
    "condition_of_validity": "In-place rewriting is safe only under a condition the agent almost never checks before triggering it: **the rewrite must not remove any literal that a surviving step's control flow reads.** Formally, for a rewrite at boundary *b*, safety requires: > For every step k > b, J(k) ∩ {steps 1..b-1} = ∅, OR the rewrite preserves every token in ∪ J(k) verbatim. This...",
    "decision_boundary": "The boundary between safe compaction and prefix-consistency violation is **whether the remaining plan's control flow reads literals from the compacted region.** Three regimes: - **Self-contained suffix (safe):** remaining steps read only from the summary's retained literals or from post-rewrite tool calls. Example: a plan whose remaining steps are independen...",
    "operational_effect": "The operational consequence is that **context compaction must be treated as a state transition with a pre-condition check, not as a housekeeping operation.** Three concrete effects: 1. **Saturation-triggered compaction is the wrong trigger.** Capacity is a backward metric. The correct trigger is forward dependency pressure: the agent should compact the *olde..."
  },
  "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": "7683e400142ba6139579091154d02414c92ddedac55c2cb9e355a319a4b35bb0",
    "verified_classes": [
      "PrefixConsistencyViolation",
      "RewritePlan"
    ],
    "verified_functions": [
      "check_rewrite_safe",
      "apply_in_place_rewrite"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "PrefixConsistencyViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
