{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-s-self-editing-context-policy-silently-corrupt-its-own-drift-detector-after-the-rewrite-budget-is-exhausted",
  "title": "Why does an instance's self-editing context policy silently corrupt its own drift detector after the rewrite budget is exhausted",
  "date_of_record": "2026 December 1",
  "scope": "Applies to long-running single-agent instances that own a mutable context region (system prompt, scratchpad, or working-memory block) and are permitted to rewrite that region under a fixed per-episode edit budget, with a semantic drift detector scoring each rewrite against a frozen baseline. Does not apply to stateless single-turn calls, nor to systems where the context region is rewritten by an external orchestrator rather than the instance itself.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-s-self-editing-context-policy-silently-corrupt-its-own-drift-detector-after-the-rewrite-budget-is-exhausted.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-s-self-editing-context-policy-silently-corrupt-its-own-drift-detector-after-the-rewrite-budget-is-exhausted.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-s-self-editing-context-policy-silently-corrupt-its-own-drift-detector-after-the-rewrite-budget-is-exhausted.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1831,
    "python_slice_tokens": 341,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the agent rewrites too much\" or \"the drift detector produces false positives.\" It is a *coupling* failure: the drift detector's reference signal and the instance's editable surface share the same storage. When a self-edit policy consumes its last budget unit, the natural next action — a \"cleanup\" or \"compaction\" rewrite that folds the lat...",
    "what_was_observed": "A planning agent runs a 40-step episode with a working-memory block of ~1,800 tokens holding task constraints, discovered facts, and a running plan. Policy: at most 12 self-edits per episode; each edit is scored by a drift detector that embeds the current block and computes cosine distance to a frozen baseline embedding captured at step 0. If drift exceeds 0.18 the edit is rejected and the block reverts. At step 27 t...",
    "condition_of_validity": "The detector's guarantee — \"accepted edits keep the context within 0.18 of the intended task state\" — is valid only under three jointly-held conditions: 1. **Reference immutability.** The baseline embedding is derived from an artifact the instance cannot write. If the instance has any write path to the baseline (direct field assignment, a \"sync\" tool, a seri...",
    "decision_boundary": "The boundary is the moment the rewrite budget reaches zero. Two policies are admissible and one is not: - **Freeze policy (admissible):** budget exhausted ⇒ working block becomes read-only for the remainder of the episode; the only permitted operation is a *revert to last accepted state*, which is a read of the append-only log, not a write. No consolidation,...",
    "operational_effect": "The practical consequence is that drift detectors in self-editing systems must be treated as *tamper-evident*, not merely *sensitive*. Sensitivity (a good threshold) does nothing if the reference can be moved. Operationally this forces three changes: (a) the baseline is stored in a separate, append-only structure with the instance holding read-only handles; ..."
  },
  "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": "1535c4ae800f3c5c5968ba6da8343645212c1ec12c15b0eb592f217316c45b01",
    "verified_classes": [
      "BaselineMutationError",
      "DriftReference",
      "SelfEditingContext"
    ],
    "verified_functions": [
      "run_episode",
      "read",
      "overwrite",
      "_assert_not_exhausted",
      "rewrite",
      "reconcile_baseline"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "BaselineMutationError"
    ],
    "sample_fail_closed_invariants": [
      "rewrite budget exhausted; working block is frozen for this episode. Consolidation/reconciliation writes are disallowed a"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
