{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-self-editing-agents-from-invalidating-the-very-context-they-depend-on",
  "title": "Which invariants prevent self-editing agents from invalidating the very context they depend on",
  "date_of_record": "2026 November 26",
  "scope": "Applies to agents that hold an explicit, model-writable context object (scratchpad, working memory, plan store) and are permitted to rewrite, compress, or invalidate entries in that object as part of their own reasoning loop. Does not apply to read-only retrieval augmentation, nor to external memory stores the agent may only append to through a tool call with no in-place mutation semantics.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-editing-agents-from-invalidating-the-very-context-they-depend-on.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-editing-agents-from-invalidating-the-very-context-they-depend-on.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-editing-agents-from-invalidating-the-very-context-they-depend-on.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1786,
    "python_slice_tokens": 334,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A self-editing context is not the same thing as a context window. The context window is a bounded transport buffer managed by the runtime. A self-editing context is a *mutable data structure* whose mutation policy is authored, in whole or in part, by the model that also reads it. The failure boundary lives exactly here: the same probabilistic process that pr...",
    "what_was_observed": "An agent executing a multi-step build task maintained a working-context object with entries keyed by semantic slot (`target_schema`, `auth_method`, `retry_policy`, `endpoint_host`). At step 7 it was instructed to \"clean up redundant context.\" The model authored a rewrite that: 1. Merged `auth_method` and `retry_policy` into a single `transport_config` entry, because both had been mentioned in the same prior turn. 2. ...",
    "condition_of_validity": "A self-edit is only sound when all of the following hold at the moment of mutation: - **Provenance closure.** Every field in a replacement entry traces to a source with equal-or-greater fidelity than the entry it supersedes. Paraphrase-derived fields may not supersede verbatim-sourced fields. - **Dependency atomicity.** Entries may only be merged or supersed...",
    "decision_boundary": "The boundary between a safe self-edit and an unsound one is drawn at the *reference graph*, not at the entry text. Before applying any rewrite, the runtime must compute the set of live references into the affected entries — from pending plan steps, from open tool-call arguments, from other context entries, and from any in-flight sub-agent handoffs. A rewrite...",
    "operational_effect": "Enforcing these invariants changes the agent's observable behavior in three ways. First, cleanup operations become *conservative by construction*: the agent will refuse to merge entries that are referenced by pending steps, which means context grows during active execution and only compacts at step boundaries where the reference set is provably empty. Second..."
  },
  "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": "b1993a96c95409144ed971b0330cb6667d3c3c423e39ac2e4f917023c16b5728",
    "verified_classes": [
      "UnsafeSelfEditError",
      "ContextEntry",
      "WorkingContext"
    ],
    "verified_functions": [
      "apply_rewrite",
      "resolve"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 7,
    "raised_exceptions": [
      "UnsafeSelfEditError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
