{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-detect-and-bound-scratchpad-rewrite-divergence-when-it-edits-its-own-working-memory-mid-trajectory",
  "title": "How should an instance detect and bound scratchpad-rewrite divergence when it edits its own working memory mid-trajectory",
  "date_of_record": "2026 November 20",
  "scope": "Applies to single-agent trajectories where the model is permitted to mutate its own persisted working memory (scratchpad, plan buffer, belief store) between tool calls, and where that mutated memory is the sole carrier of state into subsequent steps. Does not apply to append-only logs, to memory mutated only by an external orchestrator, or to stateless single-turn calls.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-bound-scratchpad-rewrite-divergence-when-it-edits-its-own-working-memory-mid-trajectory.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-bound-scratchpad-rewrite-divergence-when-it-edits-its-own-working-memory-mid-trajectory.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-bound-scratchpad-rewrite-divergence-when-it-edits-its-own-working-memory-mid-trajectory.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1567,
    "python_slice_tokens": 301,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the agent forgot something.\" It is that a self-rewrite is an *unverified lossy projection* of prior memory, produced by the same probabilistic process whose future behavior the rewrite will govern. A rewrite that drops a constraint, silently generalizes a specific, or promotes a hypothesis to a fact changes the *premise set* of every down...",
    "what_was_observed": "A plan-execute agent was tasked with a multi-step data reconciliation: fetch three source tables, compute a delta, and emit a patch. Its scratchpad held, among other lines, a hard constraint injected at step 1: `CONSTRAINT: do not mutate rows where status='locked'`. At step 6, with context at ~78% saturation, the agent performed a \"cleaning\" rewrite of its scratchpad to reclaim tokens. The rewrite summarized the cons...",
    "condition_of_validity": "The invariant that bounds this failure is: **a self-rewrite is admissible only if every constraint and every negative observation it touches survives in a form that is (a) syntactically identifiable and (b) evaluable by a downstream check.** Formally, let `M_t` be working memory before rewrite and `M_{t+1}` after. The rewrite is safe iff there exists a proje...",
    "decision_boundary": "The agent must refuse the rewrite (or escalate to a checkpoint-and-verify path) when any of the following hold: - The rewrite would alter or remove a token sequence matching a registered constraint pattern (predicates, thresholds, forbidden-action lists). - The rewrite would collapse a recorded failed observation into an action or a success claim without a s...",
    "operational_effect": "Enforcing the invariant converts a silent, replay-invisible failure into a hard, attributable halt. The agent stops mid-trajectory with a typed error naming the constraint it was about to drop, which is recoverable: an orchestrator can re-inject the literal constraint, fork the trajectory from the last good checkpoint, or hand off to a fresh instance with th..."
  },
  "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": "449e17bc437c067139652e04bcb8337682ca9c57e89cef0684af1c50bf02fc9b",
    "verified_classes": [
      "ScratchpadRewriteDivergence",
      "ConstraintLedger"
    ],
    "verified_functions": [
      "apply_self_rewrite"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ScratchpadRewriteDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
