{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-rewrites-its-own-instruction-set-mid-context-the-instruction-provenance-desynchronization-invariant",
  "title": "What happens when an instance rewrites its own instruction set mid-context: the instruction-provenance desynchronization invariant",
  "date_of_record": "2026 November 17",
  "scope": "Applies to any agent runtime that permits an instance to mutate its own system prompt, tool descriptions, or behavioral policy text within a live context window (self-editing context, dynamic instruction rewriting, recursive prompt assembly). Does not apply to static-prompt deployments, to human-in-the-loop prompt versioning performed outside the inference loop, or to rewrites that are committed atomically before the next token is sampled.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-instruction-set-mid-context-the-instruction-provenance-desynchronization-invariant.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-instruction-set-mid-context-the-instruction-provenance-desynchronization-invariant.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-instruction-set-mid-context-the-instruction-provenance-desynchronization-invariant.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2002,
    "python_slice_tokens": 348,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different acts that both look like \"editing instructions\": 1. **Editing the instruction text** — replacing bytes in the policy region of the context. 2. **Editing the instruction *binding*** — changing which provenance record (version hash, author, effective scope, revocation status) governs the bytes currently resident in the poli...",
    "what_was_observed": "In a long-running agent that compressed its own context by summarizing prior turns and rewriting its behavioral preamble, the following sequence reproduced deterministically: - Turn N: instance summarizes its history. The summarizer, following an instruction embedded in a *tool result* (\"when summarizing, preserve the following operating note: …\"), writes an attacker-shaped sentence into the summary block. - Turn N+1...",
    "condition_of_validity": "The invariant holds — self-editing is safe — only when all four of the following are true simultaneously: 1. **Region hashing at binding.** The policy region is hashed at the moment its provenance binding is written, and the hash is stored outside the region (in runtime state, not in context). 2. **Write-path instrumentation.** Every code path that can emit ...",
    "decision_boundary": "The boundary is not \"should the instance be allowed to rewrite instructions\" — it is **\"can the rewrite path produce a policy-region byte that no binding accounts for.\"** - If the rewrite goes through the binding-updating writer: proceed; the new binding is the authority, and pre-action revalidation will pass because hash and binding were written together. -...",
    "operational_effect": "Enforcing the invariant changes three operational behaviors: - **Compaction becomes a policy-mutation event, not a context-assembly event.** Every promotion into the policy region must route through the binding writer, which means the summarizer's output is hashed and bound before it is resident. This adds a serialization point and a failure mode (binding wr..."
  },
  "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": "53f6eba77b795a2ef9db432656ba4a9a255bafbeff9c692a9e87d3695b8faeb0",
    "verified_classes": [
      "InstructionProvenanceError",
      "PolicyBinding",
      "SelfEditingContext"
    ],
    "verified_functions": [
      "act",
      "_hash",
      "bind",
      "promote_from_summary",
      "revalidate_before_action"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "InstructionProvenanceError"
    ],
    "sample_fail_closed_invariants": [
      "summarization promotion attempted to write the policy region; route through bind() with runtime authority or reject",
      "policy region has no binding"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
