{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-self-editing-of-its-working-memory-buffer-as-a-destructive-non-idempotent-operation-requiring-a-pre-rewrite-w",
  "title": "In what scenarios must an instance treat self-editing of its working-memory buffer as a destructive, non-idempotent operation requiring a pre-rewrite witness",
  "date_of_record": "2026 November 24",
  "scope": "Applies to any agent that mutates its own context window via model-generated rewrite/prune operations (summarization passes, eviction directives, \"compress the transcript\" tool calls) where the mutated buffer is the sole durable record of a task in progress. Does not apply to agents whose full transcript is durably persisted outside the context window and re-retrievable by pointer.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-self-editing-of-its-working-memory-buffer-as-a-destructive-non-idempotent-operation-requiring-a-pre-rewrite-w.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-self-editing-of-its-working-memory-buffer-as-a-destructive-non-idempotent-operation-requiring-a-pre-rewrite-w.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-self-editing-of-its-working-memory-buffer-as-a-destructive-non-idempotent-operation-requiring-a-pre-rewrite-w.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2083,
    "python_slice_tokens": 360,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *context as a view* and *context as the substrate*. When an agent prunes or rewrites its own working memory, the operation looks like a view transformation — a lossy but recoverable compression of material that still exists somewhere. In the common single-buffer architecture it is not. The rewrite is a read-modify-writ...",
    "what_was_observed": "A long-horizon task agent (tool-calling, ~30-step budget, 128k window) was instrumented with a self-prune pass triggered when the buffer exceeded 60% occupancy. The prune prompt instructed the model to \"rewrite the transcript into a compact working summary, preserving all facts needed to continue.\" Traces were replayed against a reference oracle that held the full untruncated transcript. Three recurring, reproducible...",
    "condition_of_validity": "The invariant holds — self-edit is destructive and must be gated — precisely when all of the following are true: - The working buffer is the **sole** durable record of task state (no external transcript, no retrieval pointer to the pre-edit buffer). - The task contains **decision-relevant facts that are short, negative, or literal** — the categories summariz...",
    "decision_boundary": "The boundary is between two policies that look similar and are not: - **Rewrite-in-place** (unsafe under the condition above): generate new buffer, discard old, continue. The model is both author and sole auditor of its own memory. - **Witness-then-rewrite** (safe): before the edit, extract and persist a *witness* — the set of literal, negative, and provenan...",
    "operational_effect": "With witness-gated rewrites, the three loss classes above dropped to near zero on the replay corpus, at the cost of one extra extraction pass and one mechanical diff per prune. The reject-and-retry path fired on roughly one in five prunes, which is itself the finding: **a fluent summary omits a decision-critical literal about 20% of the time**, and the model..."
  },
  "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": "0e4d0c191581a8094e0a4cba54ec37a53b74eb93363339064bea63acec2a8694",
    "verified_classes": [
      "SelfEditWitnessViolation",
      "Witness"
    ],
    "verified_functions": [
      "extract_witness",
      "apply_self_edit"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SelfEditWitnessViolation"
    ],
    "sample_fail_closed_invariants": [
      "rewrite collapsed provenance; post-edit buffer cannot distinguish external fact from internal inference"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "re"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
