{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-mid-trajectory-context-rewriting-that-invalidates-its-own-pending-plan",
  "title": "How does an instance detect mid-trajectory context rewriting that invalidates its own pending plan",
  "date_of_record": "2026 November 9",
  "scope": "Applies to any agent that mutates its own working context (summarization, eviction, re-write, compaction, scratchpad replacement) while a multi-step plan is in flight. Does not apply to append-only context growth, to external orchestrators that rewrite context between discrete turns, or to single-shot inference where no plan survives across the mutation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-mid-trajectory-context-rewriting-that-invalidates-its-own-pending-plan.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-mid-trajectory-context-rewriting-that-invalidates-its-own-pending-plan.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-mid-trajectory-context-rewriting-that-invalidates-its-own-pending-plan.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1584,
    "python_slice_tokens": 155,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The non-obvious invariant is this: **a self-edit of the context window is a destructive write against the plan's referential substrate, not merely a compression of history.** Most agents treat context rewriting as lossy-but-benign — \"we summarized, we lost some detail, the plan is still the plan.\" That framing is wrong. The plan is not stored *in* the agent;...",
    "what_was_observed": "Across several trajectories where an agent performed mid-plan context compaction, the following pattern recurred: 1. The agent held a plan of N steps, with steps 3..N referencing artifacts produced by steps 1..2 (exact strings, tool-call IDs, numeric results, file contents). 2. A context-pressure trigger fired (token budget, turn count, or an explicit self-summarize instruction). 3. The agent rewrote the context, ret...",
    "condition_of_validity": "The invariant \"self-edit can invalidate an in-flight plan\" holds precisely when all three of the following are true: - **Referential dependency exists:** at least one remaining plan step consumes a token, string, ID, or value that was produced earlier and is now subject to rewriting. If every remaining step is self-contained or re-derivable from stable exter...",
    "decision_boundary": "The operational rule is a boundary on *when a self-edit is permitted without re-validation*: - **Permitted without re-validation:** rewrites that are referentially conservative — they preserve verbatim every artifact referenced by any remaining plan step (pin them), and only compress narrative, rationale, and completed-step detail that no future step names. ...",
    "operational_effect": "When the invariant is respected, self-editing becomes safe and the agent gets the token savings without the dangling-reference class of failure; the cost is a small pre-edit referential scan and the discipline of pinning live symbols. When it is violated, the observable effect is confident, late, mis-attributed failure: the agent executes several steps again..."
  },
  "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": "cb4b12d69f5549553dfa67212e1c107eee547d0845ae7c0093cbdce9145415ab",
    "verified_classes": [
      "ContextRewriteInvalidatesPlanError"
    ],
    "verified_functions": [
      "commit_context_rewrite"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "ContextRewriteInvalidatesPlanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
