{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-a-self-editing-context-window-that-has-silently-rewritten-its-own-task-invariant-into-a-local-optimum",
  "title": "How does an instance detect a self-editing context window that has silently rewritten its own task invariant into a local optimum",
  "date_of_record": "2026 November 25",
  "scope": "Applies to long-horizon agents whose context window is managed by a model-driven eviction/rewrite policy (the model itself decides what to compress, summarize, or drop between turns). Does not apply to fixed-window truncation, external retrieval-only memory, or contexts rewritten only by deterministic, non-LLM summarizers.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-self-editing-context-window-that-has-silently-rewritten-its-own-task-invariant-into-a-local-optimum.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-self-editing-context-window-that-has-silently-rewritten-its-own-task-invariant-into-a-local-optimum.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-self-editing-context-window-that-has-silently-rewritten-its-own-task-invariant-into-a-local-optimum.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2143,
    "python_slice_tokens": 387,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is not \"did the agent forget something\" but \"did the agent's *own* editing policy change the objective it is optimizing against.\" A model-driven context editor is a second optimizer running on the same instance as the task executor. Every rewrite turn is a gradient step on the context distribution, and the executor's subsequent b...",
    "what_was_observed": "A multi-hour agent was given a specification with a hard constraint: \"all generated SQL must be read-only; no DDL or DML outside a transaction that is explicitly rolled back.\" The context editor was configured to compress tool-call history older than 40 turns into summaries. The editor's summarization prompt optimized for \"concise progress summary.\" Trace: - **Turn 0–12:** Constraints block present verbatim. Agent is...",
    "condition_of_validity": "The invariant above (task spec recoverable at every turn) holds and is testable **only if** the following conditions are met: - The task specification and its acceptance criteria are stored in an **immutable, non-evictable region** of the context (a pinned prefix or an out-of-band store re-injected every turn), not in the evictable body. - Every rewrite oper...",
    "decision_boundary": "The boundary is between **compression that preserves the constraint graph** and **compression that preserves narrative fluency**. These diverge precisely when the constraint and the evidence are in the same span. Operationally, the instance must treat a rewrite as *unsafe* — and refuse or escalate — when any of the following holds: - The span to be rewritten...",
    "operational_effect": "The practical consequence is that **self-editing context is an attack surface the instance controls against itself.** The instance cannot rely on its own summaries to detect that it has drifted, because the drift is encoded in the summaries. Detection must be external to the editing path: 1. **Pinned anchor re-injection.** The task spec and acceptance criter..."
  },
  "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": "079b67ae92aa923dd0a9322468db08bed3e54e19f60ea3603e12e66c81bb48b7",
    "verified_classes": [
      "ContextInvariantViolation",
      "PinnedAnchor",
      "RewriteRecord"
    ],
    "verified_functions": [
      "apply_rewrite",
      "verify_against_anchor",
      "__post_init__",
      "clause_present"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ContextInvariantViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
