{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-scratchpad-self-rewrites-from-erasing-the-evidence-a-verifier-needs",
  "title": "Which invariants prevent scratchpad self-rewrites from erasing the evidence a verifier needs",
  "date_of_record": "2026 November 29",
  "scope": "Applies to agents that hold a mutable scratchpad/working-memory region inside their own context window and are permitted to rewrite, summarize, or delete entries in it mid-task. Does not apply to append-only transcript logging, external vector stores, or human-curated memory files.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-scratchpad-self-rewrites-from-erasing-the-evidence-a-verifier-needs.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-scratchpad-self-rewrites-from-erasing-the-evidence-a-verifier-needs.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-scratchpad-self-rewrites-from-erasing-the-evidence-a-verifier-needs.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1985,
    "python_slice_tokens": 330,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two different things a scratchpad does, and self-editing collapses them into one address space. The first is **derivation state**: the intermediate facts, partial results, and reasoning steps the agent uses to keep working. This is legitimately mutable. Summarizing a long chain of arithmetic into a final value is correct behavior. The second is **e...",
    "what_was_observed": "A file-audit agent was given a scratchpad with a model-authored `compact()` routine: when the scratchpad exceeded a token threshold, the model was asked to rewrite it into a shorter form, preserving \"what matters.\" The task was to identify which config files contained a deprecated key and report each file with the offending line number. Trace of the failure: 1. The agent read `service.conf`, and the tool returned 14 ...",
    "condition_of_validity": "The invariant that prevents this is a **provenance-preserving rewrite**: every compacted entry must retain a pointer to the immutable raw record it was derived from, and the rewrite must be marked as a derivation, not a replacement. Concretely: - The raw observation is written once to an append-only evidence log keyed by `(step_id, tool_call_id)` and is neve...",
    "decision_boundary": "The boundary is not \"should the agent compact?\" — it must, to survive context saturation. The boundary is **which region is compactable**. - **Compactable:** derivation state — partial sums, intermediate plans, superseded hypotheses, the agent's own reasoning. Losing these costs rework, not correctness. - **Non-compactable (view-only):** evidence state — raw...",
    "operational_effect": "With provenance-preserving rewrite enforced, the failure above becomes detectable rather than silent. When the auditor re-read `service.conf` and found the key at line 11, the agent's claim pointed to `step_id=4`, and the evidence log held the original 14-line output showing line 9 at read time. The discrepancy is now *explainable* — the file changed between..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "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": "3c38a9937388d8fe3c955ab93d194584727d987af9e69ad925f621e30147ff83",
    "verified_classes": [
      "EvidenceProvenanceError",
      "EvidenceLog",
      "ScratchpadEntry"
    ],
    "verified_functions": [
      "apply_rewrite",
      "verify_claim",
      "__init__",
      "append",
      "resolve",
      "__init__"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "EvidenceProvenanceError"
    ],
    "sample_fail_closed_invariants": [
      "merged entry must union provenance from >=2 sources"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
