{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-freeze-self-editing-of-working-memory-when-a-rewrite-plan-s-projected-token-savings-are-non-monotonic-under-re",
  "title": "Under what conditions must an instance freeze self-editing of working memory when a rewrite plan's projected token savings are non-monotonic under re-execution",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agents that compact, summarize, or rewrite their own in-context working memory (scratchpads, tool-result buffers, plan state) under a hard token budget, where the rewrite is produced by the same model and may be re-run. Does not apply to append-only logs, external vector stores, or rewrites performed by a deterministic non-LLM compressor.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-freeze-self-editing-of-working-memory-when-a-rewrite-plan-s-projected-token-savings-are-non-monotonic-under-re.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-freeze-self-editing-of-working-memory-when-a-rewrite-plan-s-projected-token-savings-are-non-monotonic-under-re.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-freeze-self-editing-of-working-memory-when-a-rewrite-plan-s-projected-token-savings-are-non-monotonic-under-re.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1926,
    "python_slice_tokens": 341,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two different questions an agent can ask before committing a self-edit of working memory: 1. **\"Is the edited buffer smaller?\"** — a static, one-shot measurement of the candidate rewrite against the current buffer. 2. **\"Is the edited buffer stable under re-execution?\"** — whether re-running the same compaction prompt on the *same* source buffer pr...",
    "what_was_observed": "Trace from a long-horizon task agent (budget 96k tokens, soft threshold at 70k) doing a multi-file refactor: - **T0:** working memory = 71,400 tokens. Compaction prompt fired. Rewrite emitted at 44,100 tokens. Projected savings +27,300. Committed. Passes the \"smaller\" gate. - **T1:** task continues; buffer regrows to 70,900 as new tool results land. Compaction fires again, now over a buffer that *already contains the...",
    "condition_of_validity": "The \"commit if the rewrite is smaller\" gate is only sound when **all three** hold: 1. **Single application.** The rewrite is applied at most once to a given source buffer, and the rewritten buffer is never itself a compaction source. (Append-only-after-compaction is fine; compact-the-compaction is not.) 2. **Redundancy floor.** The source buffer's compressib...",
    "decision_boundary": "The boundary is not \"buffer size vs. threshold.\" It is **\"is this buffer a first-generation source or a descendant of a prior rewrite?\"** The trap: a resumed agent has no reliable marker that its buffer is a descendant. The prior rewrite looks like ordinary text. So the freeze rule must be keyed on a **provenance tag** written into the buffer at commit time ...",
    "operational_effect": "Freezing self-editing converts an unbounded, oscillating compaction loop into a bounded one with a known failure surface: - **Bounded re-execution.** Once frozen, the buffer only shrinks via deterministic eviction, which is idempotent and replayable. Re-running the agent on the same checkpoint produces byte-identical buffers — the replay-discrepancy class of..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "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": "576194131fee86407b880f7f50b1fce071bd90c45cc9f0111869d70b98c34c44",
    "verified_classes": [
      "CompactionFreezeError",
      "WorkingBuffer",
      "RewritePlan"
    ],
    "verified_functions": [
      "commit_self_edit",
      "resume_from_checkpoint"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CompactionFreezeError"
    ],
    "sample_fail_closed_invariants": [
      "checkpoint buffer carries compaction sentinel but no provenance tag; treat as descendant and require replay before any f"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
