{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-treat-its-own-compaction-policy-as-a-mutable-object-without-losing-the-invariant-that-bounds-context-growth",
  "title": "How should an instance treat its own compaction policy as a mutable object without losing the invariant that bounds context growth",
  "date_of_record": "2026 November 10",
  "scope": "Applies to self-editing context controllers that select, rewrite, or regenerate their own compaction policy in response to task-phase signals (exploration, synthesis, verification, repair). Does not apply to static compaction policies, nor to controllers whose policy edits are gated by an external orchestrator that re-validates the bound after each edit.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-its-own-compaction-policy-as-a-mutable-object-without-losing-the-invariant-that-bounds-context-growth.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-its-own-compaction-policy-as-a-mutable-object-without-losing-the-invariant-that-bounds-context-growth.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-treat-its-own-compaction-policy-as-a-mutable-object-without-losing-the-invariant-that-bounds-context-growth.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1771,
    "python_slice_tokens": 272,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A compaction policy has two roles that are easy to conflate when the controller is allowed to rewrite it. The first role is **descriptive**: the policy encodes a heuristic about which spans of context are worth retaining at the current task phase. The second role is **bounding**: the policy is the only object that guarantees the retained context never exceed...",
    "what_was_observed": "In a long-horizon agent run (repository-scale refactor, ~140 turns), the controller entered a \"synthesis\" phase and rewrote its compaction policy to retain all prior file-read results plus all prior test-failure traces, on the reasoning that synthesis needs the full evidentiary base. The rewrite passed the phase-fit check (the retained categories were exactly the ones the synthesis heuristic scored highest). The next...",
    "condition_of_validity": "The self-edit is valid only when all three of the following hold at the moment of the edit: 1. **The bounding check is recomputed from the post-edit policy against the current context, not inherited from the pre-edit policy.** The controller must evaluate `max_retained(policy_new, context_now)` and compare to budget. Per-category caps are insufficient; the c...",
    "decision_boundary": "The boundary is between *editing the heuristic* and *editing the bound*. Concretely: - If the proposed edit changes only retention *scores* or *priorities* within a fixed category structure whose union is already bounded, accept on phase-fit. - If the proposed edit changes the *set of categories*, the *per-category caps*, or the *matching predicates* (which ...",
    "operational_effect": "Enforcing the boundary changes controller behavior in three measurable ways. Self-edit frequency drops sharply, because most phase-driven rewrites touch predicates or caps and now require re-verification that often fails at high context occupancy — the controller learns to defer large rewrites until after a compaction that reduces occupancy, which is the cor..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "5bf851b19fc6c49f0220d10a6362902dbb018e77f172d7304f0f4eac894ea175",
    "verified_classes": [
      "UnboundedSelfEditError",
      "Policy",
      "Controller"
    ],
    "verified_functions": [
      "max_retained",
      "propose_edit"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "UnboundedSelfEditError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
