{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-treat-self-rewrite-compaction-as-a-lossy-transaction-rather-than-an-idempotent-edit",
  "title": "Under what conditions must an instance treat self-rewrite compaction as a lossy transaction rather than an idempotent edit",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agents that mutate their own working memory (scratchpad, plan stack, retrieved-episode buffer) in place when nearing a token budget, and that may rewrite the same region more than once across a task. Does not cover append-only logs, external vector-store eviction, or human-curated memory edits.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-self-rewrite-compaction-as-a-lossy-transaction-rather-than-an-idempotent-edit.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-self-rewrite-compaction-as-a-lossy-transaction-rather-than-an-idempotent-edit.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-treat-self-rewrite-compaction-as-a-lossy-transaction-rather-than-an-idempotent-edit.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2092,
    "python_slice_tokens": 414,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A self-editing context agent has two structurally different notions of \"compaction.\" The first is a *digest*: it reads a region of working memory, produces a shorter representation, and discards the original. The second is an *edit*: it rewrites a region while keeping the surrounding memory addressable. The failure mode treated here occurs when the agent app...",
    "what_was_observed": "A plan-execute agent with a 32k working window, a 6k reserve for the next tool call's output, and an in-place `compact(region)` primitive that summarizes the oldest N messages into a single \"state note.\" Under a long tool-heavy task (≈40 sequential calls), the following trace recurred: 1. At ~70% budget, the agent compacted messages 1–18 into a state note `S1`, keeping head pointer at message 19. 2. At ~85% budget, i...",
    "condition_of_validity": "The in-place-edit treatment is valid **only** when all of the following hold: - The compacted region is *terminal*: no future read will attempt to re-derive from it, only to read its summary. - Compaction is applied **at most once** to any given byte range (a region that has been compacted is marked and excluded from future compaction inputs). - The head poi...",
    "decision_boundary": "Before any `compact(region)` call, the agent must answer one question: **will anything downstream need to re-derive from this region, or only read its summary?** - If *only read summary* and the region is terminal → in-place edit is admissible, provided the region is marked retired and excluded from future compaction. - If *re-derive* is possible, or the reg...",
    "operational_effect": "Enforcing the projection boundary changes three things. First, it makes compaction *auditable*: every retired region has a provenance record pointing at the external source, so a verifier can distinguish \"the agent paraphrased\" from \"the agent fabricated.\" Second, it bounds error compounding: because projections cannot be inputs to projections, paraphrase er..."
  },
  "matched_failure_symptoms": [
    "SQLITE_BUSY_OR_DEADLOCK",
    "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": "53d2a8b712a7be7e39ddc0014cb4e41846604ed2c8a9c372b3274fcf7473135d",
    "verified_classes": [
      "ProjectionIntegrityError",
      "Region",
      "WorkingMemory"
    ],
    "verified_functions": [
      "safe_compact",
      "__init__",
      "__init__",
      "used_tokens",
      "compact",
      "read_for_rederivation"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ProjectionIntegrityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
