{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-self-editing-context-policies-from-silently-evicting-the-one-token-the-task-depends-on",
  "title": "Which invariants prevent self-editing context policies from silently evicting the one token the task depends on",
  "date_of_record": "2026 November 22",
  "scope": "Applies to any agent that lets the model itself rewrite, prune, summarize, or relevance-score its own context window between turns (self-editing context managers, compaction loops, retention scorers). Does not apply to externally fixed sliding-window truncation or to stateless single-shot calls where the context is never re-authored by the model.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-editing-context-policies-from-silently-evicting-the-one-token-the-task-depends-on.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-editing-context-policies-from-silently-evicting-the-one-token-the-task-depends-on.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-self-editing-context-policies-from-silently-evicting-the-one-token-the-task-depends-on.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2419,
    "python_slice_tokens": 438,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two structurally different things an agent can do to its own context: *compress* and *evict*. Compression preserves a bijective-enough reconstruction of the original—a summary that still answers \"what was the exact error string from step 3?\" Eviction is lossy by construction: a token, span, or message is dropped and the model is thereafter operatin...",
    "what_was_observed": "A planner-executor agent running a multi-step data-migration task rewrote its own context every turn using a relevance-scored retention policy (keep top-k spans by cosine similarity to the last user/assistant turn plus a recency bonus; summarize the tail). The task required the agent to, at step 14, apply a transformation to a table whose exact name (`orders_2024_q3_staging`) had been stated once by the user in the o...",
    "condition_of_validity": "The guardrail below is only valid—and only necessary—under a specific conjunction of conditions. State them explicitly, because applying the guardrail outside them costs context budget for no benefit. The invariant **must** be enforced when all of the following hold: 1. **The context is model-authored.** The model, not a fixed external policy, decides what t...",
    "decision_boundary": "The boundary is between **relevance-scored retention** (default; cheap; correct when dependencies are shallow) and **pinned-referential retention** (guarded; costs budget; required when the four conditions above co-hold). Concretely, a span must be *pinned*—excluded from the scorer's eviction set regardless of its relevance score—if it satisfies any of: - It...",
    "operational_effect": "Enforcing the pinned-referential invariant changes three measurable properties of the agent loop: 1. **Referential drift goes to zero for pinned literals**, at the cost of a bounded, predictable budget reservation. The reservation is bounded because the pinned set is bounded by the plan's literal dependencies, not by total context—typically a small fraction ..."
  },
  "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": "ac451f27747a89e3b2590c7cf135b02796d5119587f6df83c422d0890ccfe982",
    "verified_classes": [
      "ContextPolicyViolation",
      "SpanKind",
      "Span",
      "Plan"
    ],
    "verified_functions": [
      "is_pinned",
      "rewrite_context",
      "compact"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ContextPolicyViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
