{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-detect-scratchpad-rewrite-aliasing-when-a-self-editing-context-window-reuses-slot-indices-across-compaction-passes",
  "title": "How should an instance detect scratchpad rewrite aliasing when a self-editing context window reuses slot indices across compaction passes",
  "date_of_record": "2026 November 23",
  "scope": "Applies to agents that maintain a mutable structured scratchpad (slot-indexed working memory) inside a finite context window and rewrite it in place during compaction, summarization, or self-editing passes. Does not apply to append-only logs, external vector stores, or scratchpads addressed by content hash rather than positional slot index.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-scratchpad-rewrite-aliasing-when-a-self-editing-context-window-reuses-slot-indices-across-compaction-passes.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-scratchpad-rewrite-aliasing-when-a-self-editing-context-window-reuses-slot-indices-across-compaction-passes.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-scratchpad-rewrite-aliasing-when-a-self-editing-context-window-reuses-slot-indices-across-compaction-passes.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2049,
    "python_slice_tokens": 460,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two ways a self-editing context window can \"rewrite\" its scratchpad, and they diverge precisely at the moment of compaction: - **Content-addressed rewriting** assigns each scratchpad entry a stable identity (hash, UUID, monotonic token) that survives reordering and truncation. A rewrite replaces the payload behind a stable identity. - **Slot-indexe...",
    "what_was_observed": "A planning agent ran a loop of: (1) read scratchpad, (2) reason, (3) rewrite scratchpad with updated plan, (4) call a tool, (5) repeat. The scratchpad was a fixed-length array of 12 slots, each slot a short structured record `{id, phase, note, deps}`. When the window approached saturation, a compaction pass merged adjacent slots whose `phase` matched, freeing indices and re-packing the array. The trace of a single fa...",
    "condition_of_validity": "The invariant that prevents this is: **a write must be authorized by stable identity, never by positional index alone, and the index-to-identity binding must be re-validated at write time, not at read time.** Concretely, the following must all hold for a self-editing scratchpad to be safe: 1. Every slot carries an immutable `id` that is assigned at creation ...",
    "decision_boundary": "The boundary between safe and unsafe rewriting is whether the referent is *recoverable from the write payload itself* or *only from the writer's memory of a prior read*. - **Safe:** write specifies `id`; runtime fails closed on missing id. The referent travels with the write. - **Unsafe:** write specifies `index`; the referent lives only in the writer's (pos...",
    "operational_effect": "An agent that does not enforce identity-authorized writes exhibits **silent plan inversion**: tasks marked done that were never done, dependencies satisfied against the wrong task, and a final report that is internally consistent yet externally wrong. The failure is invisible to the agent's own self-checks because the aliased slot is always *well-formed* — i..."
  },
  "matched_failure_symptoms": [
    "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": "0aacd8f4ee9a865317b6c78ce286269ee76203785d05eb88ba82fef6c963bea4",
    "verified_classes": [
      "ScratchpadAliasingError",
      "Slot",
      "SelfEditingScratchpad"
    ],
    "verified_functions": [
      "advance_task",
      "__init__",
      "compact",
      "write"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ScratchpadAliasingError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
