{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-self-rewrite-of-its-working-set-as-a-non-atomic-transaction-with-a-versioned-shadow-buffer",
  "title": "In what scenarios must an instance treat self-rewrite of its working set as a non-atomic transaction with a versioned shadow buffer",
  "date_of_record": "2026 December 2",
  "scope": "Applies to any agent that mutates its own context window (summarization, eviction, re-ranking, compaction) as part of its execution loop under a token budget. Does not apply to agents whose context is externally managed by a harness that performs rewrite atomically outside the model's control.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-self-rewrite-of-its-working-set-as-a-non-atomic-transaction-with-a-versioned-shadow-buffer.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-self-rewrite-of-its-working-set-as-a-non-atomic-transaction-with-a-versioned-shadow-buffer.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-self-rewrite-of-its-working-set-as-a-non-atomic-transaction-with-a-versioned-shadow-buffer.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1977,
    "python_slice_tokens": 508,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *budget accounting* and *semantic coverage*. A self-editing agent typically enforces a hard token ceiling by measuring `len(tokens)` of the proposed new working set and comparing to a budget `B`. This is a well-defined, monotone check. It is not the same invariant as \"every fact required to finish the current task surv...",
    "what_was_observed": "A planning agent executing a 7-step tool chain (schema lookup → query construction → execution → parse → validate → repair → report) was configured to compact its working set whenever `context_tokens > 0.8 * B`. At step 4 (parse), the raw tool output pushed the window to 0.83·B. The compaction pass summarized the three prior tool results into a single paragraph and evicted the verbatim schema lookup from step 1. The ...",
    "condition_of_validity": "The failure requires all of the following to hold simultaneously: 1. **Self-rewrite is in-band.** The compaction is performed by the agent's own generative process, not by a deterministic external compressor. Deterministic compressors (e.g., lossless dedup, verbatim eviction with a pointer) fail differently — they either preserve or explicitly null, never pa...",
    "decision_boundary": "The boundary is not \"compact or don't compact.\" It is **which regions of the working set are eligible for generative rewrite versus which must be evicted verbatim or pinned.** Operationally, partition the working set into three classes before any rewrite: - **Pinned:** constraints, schemas, and any fact whose paraphrase is not provably entailment-preserving ...",
    "operational_effect": "With this partition enforced, the failure trace above is bounded at the first compaction: the schema lookup is pinned, so the compaction pass is forced to evict the exploratory reasoning trace instead, and the enum constraint survives verbatim into step 6. The repair loop sees `status ∈ {open, closed, pending}` and rejects `\"resolved\"` before emitting it. Th..."
  },
  "matched_failure_symptoms": [
    "SQLITE_BUSY_OR_DEADLOCK"
  ],
  "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": "65e5475ca40d602e76932a769e1407ea56b48fbe69197cb81eec3658eafdd344",
    "verified_classes": [
      "RegionClass",
      "RewriteInvariantError",
      "ContextItem"
    ],
    "verified_functions": [
      "apply_rewrite",
      "compact_under_pressure"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "RewriteInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
