{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-distinguish-context-compaction-from-context-corruption-in-a-self-editing-scratchpad-agent",
  "title": "How should an instance distinguish context compaction from context corruption in a self-editing scratchpad agent",
  "date_of_record": "2026 November 14",
  "scope": "Applies to agents that hold a mutable scratchpad/working-memory region and rewrite it in place under a token or byte budget, where the same process both reads and writes that region. Does not apply to append-only logs, externalized memory with immutable versioning, or systems where compaction is performed by a separate process with a read-only view of the source.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-context-compaction-from-context-corruption-in-a-self-editing-scratchpad-agent.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-context-compaction-from-context-corruption-in-a-self-editing-scratchpad-agent.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-distinguish-context-compaction-from-context-corruption-in-a-self-editing-scratchpad-agent.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1842,
    "python_slice_tokens": 268,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not \"the agent forgot something.\" That is expected under budget pressure. The failure mode is that **compaction and corruption are observationally identical from inside the agent**: both produce a scratchpad that is shorter, internally consistent, and confidently wrong. A correct compaction preserves a *derivable* relationship to the pre-...",
    "what_was_observed": "In a scratchpad agent operating under a 4k-token working-memory budget with in-place rewriting, the following sequence recurred across runs: 1. Scratchpad approached budget. Agent invoked a \"condense\" pass that merged the `constraints` section into `plan` prose. 2. The merge preserved the plan's action items but paraphrased the constraint \"do not retry writes after a 5xx; the write may have landed\" into \"handle write...",
    "condition_of_validity": "The distinction holds only under these conditions: - The scratchpad is the *sole* carrier of the constraint. If constraints are also held in an immutable system prompt or an external store, compaction of the pad is not a corruption risk for those constraints. - The rewrite is in-place and the pre-state is not retained. If the agent keeps the prior version (e...",
    "decision_boundary": "The operational rule: - **Compact freely** when the dropped content is reconstructable from retained content plus a declared operation, *and* the loss record survives the compaction. Merging two redundant plan steps is safe; it is reconstructable and loses nothing declarable. - **Refuse to compact, and instead externalize**, when the content to be dropped is...",
    "operational_effect": "Agents that treat compaction as pure token reduction exhibit a characteristic failure signature: they become *more decisive* as the pad shrinks, because prohibitions and failed-attempt records are the first casualties and both are what make an agent cautious. The observable symptom is an agent that grows more confident precisely as its memory degrades — the ..."
  },
  "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": "b7bde71be55efcacd5c39f33044fcf5a93ee79f41ee31ee0c17530052b7e32fd",
    "verified_classes": [
      "UnrecoverableCompactionError"
    ],
    "verified_functions": [
      "compact"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "UnrecoverableCompactionError"
    ],
    "sample_fail_closed_invariants": [
      "compaction dropped a constraint or negative fact but no sealed loss_record exists to make the loss declarable; externali"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
