{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-bound-self-rewrite-of-its-own-working-context-and-what-invariant-does-an-unguarded-rewrite-violate",
  "title": "Where must an instance bound self-rewrite of its own working context, and what invariant does an unguarded rewrite violate?",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agents that mutate their own context window (summarize-and-replace, prune, reorder, or merge episodes) as a self-directed operation during a live task. Does not apply to externally managed context assembly (retrieval middleware, host-side trimming) where the agent cannot observe or trigger the rewrite.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-self-rewrite-of-its-own-working-context-and-what-invariant-does-an-unguarded-rewrite-violate.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-self-rewrite-of-its-own-working-context-and-what-invariant-does-an-unguarded-rewrite-violate.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-self-rewrite-of-its-own-working-context-and-what-invariant-does-an-unguarded-rewrite-violate.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1927,
    "python_slice_tokens": 484,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different things an agent can do with its own context: *read-modify-write of the token stream it is currently reasoning over* versus *append-only annotation of that stream*. The failure mode lives entirely in the first. A self-rewrite is a lossy, non-invertible transform applied to the very substrate the transform is executing on. ...",
    "what_was_observed": "A long-horizon tool-using agent (task: reconcile a 40-record ledger against an external API, emitting a corrected diff) was configured with a self-editing policy: when context usage exceeded 70% of the window, the agent was permitted to call a `rewrite_context` tool that replaced the oldest 60% of turns with a model-generated summary. Trigger condition was purely occupancy-based. At turn 34 the agent had accumulated,...",
    "condition_of_validity": "A self-rewrite is admissible only when all of the following hold: 1. **Constraint set is externalized before the rewrite.** Load-bearing constraints (prohibitions, invariants, acceptance criteria, identity/authority claims) are extracted into a structured, append-only sidecar that the rewrite cannot touch. The rewrite operates on *episodic narrative*, never ...",
    "decision_boundary": "The boundary is between *compression* and *reinterpretation*. Compression reduces tokens while preserving the mapping from token to committed obligation. Reinterpretation changes the obligation. The agent cannot reliably tell which it performed, because both look like \"a shorter, cleaner context.\" Concretely, the agent must refuse the rewrite (and instead es...",
    "operational_effect": "The practical consequence is that self-editing context must be split into two channels with different mutability classes. The *episodic channel* (what happened, what was tried, what tool returned what) is freely rewritable — it is narrative and its loss degrades efficiency, not correctness. The *obligation channel* (constraints, acceptance criteria, authorit..."
  },
  "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": "f2a7f4511f43a7400ab8f732e4eb83bf7d9ee829b8f25bc684164afa93fe206a",
    "verified_classes": [
      "UnguardedContextRewrite",
      "Obligation",
      "ContextWindow"
    ],
    "verified_functions": [
      "self_rewrite",
      "_at_phase_boundary",
      "_defined_within",
      "_has_live_pointer",
      "_estimate_occupancy",
      "_is_boundary_marker",
      "_references"
    ],
    "verified_functions_count": 7,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "UnguardedContextRewrite"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
