{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-rewrites-its-own-working-memory-and-the-write-ahead-audit-log-diverges-from-the-committed-context",
  "title": "What happens when an instance rewrites its own working memory and the write-ahead audit log diverges from the committed context",
  "date_of_record": "2026 November 30",
  "scope": "Applies to single-agent instances that hold a mutable working-memory buffer and are authorized (via a policy engine) to issue self-edits—compaction, summarization, slot eviction, or fact promotion—against that buffer mid-task. Does not apply to read-only context assemblers or to external memory stores where the agent lacks write authority over its own prompt state.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-working-memory-and-the-write-ahead-audit-log-diverges-from-the-committed-context.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-working-memory-and-the-write-ahead-audit-log-diverges-from-the-committed-context.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-rewrites-its-own-working-memory-and-the-write-ahead-audit-log-diverges-from-the-committed-context.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1695,
    "python_slice_tokens": 311,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *intent to edit* and *committed edit*. A self-editing agent typically emits an edit as a structured tool call (`memory.replace`, `memory.compact`, `memory.promote`) that is validated against a policy constraint set—token budget, protected slots, provenance requirements—before the runtime mutates the buffer. The failure...",
    "what_was_observed": "Trace from a representative incident on a 14-step research task with a 32k working buffer and a compaction policy that triggers at 85% saturation: 1. At step 9, buffer saturation hits 86%. The agent issues `memory.compact(strategy=\"episodic_to_semantic\", retain=[\"task_goal\",\"open_questions\"])`. 2. The policy validator deep-copies the buffer to evaluate the edit against token-budget and protected-slot constraints. Cop...",
    "condition_of_validity": "The failure requires all of the following to hold simultaneously. Absent any one, the divergence cannot occur: - **Copy-on-validate.** The policy validator operates on a snapshot rather than the live buffer (necessary for isolation and for rollback-on-reject). - **Split write path.** Audit serialization and buffer mutation are not in the same critical sectio...",
    "decision_boundary": "The operational decision is where to place the commit barrier, and it is forced by whether the runtime can afford full snapshots: - If checkpoints are *full snapshots*, replay divergence is impossible; the failure does not apply. Cost is storage, not correctness. - If checkpoints are *edit logs* (the common case for large buffers), the commit barrier is mand...",
    "operational_effect": "The practical consequence is that self-editing agents cannot be trusted to reconstruct their own history unless log-to-state equivalence is asserted at every edit, not assumed at checkpoint. A single silent divergence at a compaction seam poisons every subsequent replay: the agent, on resume, holds a *plausible* but *wrong* memory of its own prior reasoning,..."
  },
  "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": "44b7f5367420dba24e9898a774bd42a0aaef4477ad5451a0db1185dddcfa5c4d",
    "verified_classes": [
      "ReplayDivergenceError",
      "CommitBarrierViolation",
      "EditRecord",
      "SelfEditingBuffer"
    ],
    "verified_functions": [
      "resume_from_checkpoint",
      "_hash",
      "apply_edit",
      "replay"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CommitBarrierViolation",
      "ReplayDivergenceError"
    ],
    "sample_fail_closed_invariants": [
      "replayed version does not match log length"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
