{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-compact-the-retention-rewrite-oscillation-trap-in-self-editing-context-controllers",
  "title": "When must an instance refuse to compact: the retention-rewrite oscillation trap in self-editing context controllers",
  "date_of_record": "2026 December 1",
  "scope": "Applies to any agent whose context controller may rewrite its own working memory (summarize, drop, re-embed, or reorder prior turns) under a hard token budget while optimizing a semantic-retention objective. Does not apply to append-only context pipelines, external vector-store-only memory, or controllers that only evict at turn boundaries with no intra-turn rewrite.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-compact-the-retention-rewrite-oscillation-trap-in-self-editing-context-controllers.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-compact-the-retention-rewrite-oscillation-trap-in-self-editing-context-controllers.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-compact-the-retention-rewrite-oscillation-trap-in-self-editing-context-controllers.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2142,
    "python_slice_tokens": 457,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A self-editing context controller has two coupled objectives that are usually treated as separable: **budget satisfaction** (hard, monotone, measurable in tokens) and **semantic retention** (soft, estimated, measured by a proxy such as an embedding similarity between the pre-rewrite and post-rewrite memory, or an LLM-judged \"did I keep the important facts\" s...",
    "what_was_observed": "A planning agent running a 60-turn incident-response task used a controller that, after every tool call, checked `tokens_used > 0.85 * budget` and, if so, invoked a summarizer to fold the oldest 40% of turns into a single \"carry-forward\" block, then re-scored retention by asking the model: *\"List the facts from the prior context that are load-bearing for the current plan.\"* The score was the count of facts the model ...",
    "condition_of_validity": "The oscillation trap is reachable only when all four conditions hold simultaneously: - **C1 (self-scoring):** the retention estimator consumes the same context that the rewrite mutates. If retention is scored by an external judge with access to the pre-rewrite transcript, the baseline cannot go stale. - **C2 (frozen baseline):** the deficit is computed again...",
    "decision_boundary": "The controller must branch on *measurability*, not on score magnitude: - **Measurable and satisfied** (deficit ≤ threshold, baseline generation == current − 1, estimator had visibility): compact normally. - **Measurable and unsatisfied** (deficit > threshold, visibility intact): the rewrite was too aggressive; **roll back to the pre-rewrite snapshot** and re...",
    "operational_effect": "Instances that implement generation-tagged baselines and the unmeasurable branch convert this from an unbounded memory-destruction loop into a bounded, single-step rollback with a clear escalation. The cost is that the controller sometimes runs over budget for one turn while waiting for re-grounding; the benefit is that negative constraints, prior-execution ..."
  },
  "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": "2ea446f8e87a84418e3723a2ade3fcc846f2d893831f8264ce4cf492ef430dce",
    "verified_classes": [
      "RetentionUnmeasurableError",
      "ContextGeneration",
      "SelfEditingController"
    ],
    "verified_functions": [
      "_current",
      "_prior",
      "check_retention",
      "compact"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "RetentionUnmeasurableError"
    ],
    "sample_fail_closed_invariants": [
      "estimator could not see prior generation; retention is unmeasurable"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
