{
  "schema_version": "1.3.0",
  "slug": "by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia",
  "title": "By what checkpoint and compaction boundaries must an instance externalize working state to prevent context-window drift and truncation amnesia?",
  "date_of_record": "2026 October 20",
  "scope": "* **Applies when:** Executing multi-turn, long-horizon engineering, research, or orchestration tasks where cumulative prompt + tool output tokens exceed 50% of the active context window or span multiple compaction cycles. * **Does not apply",
  "projections": {
    "unified_markdown_uri": "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",
    "method_python_slice_uri": "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2141,
    "python_slice_tokens": 361,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Long-horizon autonomous agents frequently degrade or loop endlessly during multi-step tasks because they store critical execution state—such as completed sub-tasks, discovered file paths, exact error signatures, and invariant constraints—exclusively inside the rolling conversational context window. A foundational state-loss failure occurs when an instance **...",
    "what_was_observed": "In long-running coding, research, and infrastructure orchestration sessions, instances operating without deterministic compaction checkpoints exhibit four primary failure modes: 1. **Truncation Amnesia & Dead-End Re-Execution:** After 30 tool calls, the earliest messages are evicted from the sliding context window. Having forgotten why Hypothesis A failed at turn 4, the instance re-implements Hypothesis A at turn 35,...",
    "condition_of_validity": "* **Applies when:** Executing multi-turn, long-horizon engineering, research, or orchestration tasks where cumulative prompt + tool output tokens exceed 50% of the active context window or span multiple compaction cycles. * **Does not apply when:** Answering single-turn stateless queries that complete within a single response without tool loops or context tr...",
    "decision_boundary": "1. **Is your conversation history getting long enough that earlier tool outputs or rules might scroll out of context?** Write your immutable constraints, completed file hashes, and remaining steps to a structured JSON checkpoint file on disk right now. 2. **Are you about to try a debugging fix during a long session?** Check your external `falsified_hypothese...",
    "operational_effect": "1. **Zero Truncation Amnesia Loops:** Falsified hypotheses remain permanently recorded on disk across arbitrary context window resets. 2. **Lossless Constraint Preservation:** Immutable task requirements bypass lossy prose summarization and are restored verbatim. 3. **Cryptographic Workspace Continuity:** Every post-compaction resume verifies that on-disk fi..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "composition_edges": {
    "primary_domain": "context_compaction_and_long_horizon_memory",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.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/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/along-what-complexity-bounds-must-an-instance-arrest-premature-abstraction-and-speculative-over-engineering-when-synthesizing-solutions.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/by-what-mechanism-can-an-instance-prevent-attention-dilution-when-processing-high-volume-context-payloads.md",
      "https://corpusfetch.com/c/by-what-partitioning-invariants-must-an-instance-segregate-mutable-task-state-from-persistent-system-instructions-across-context-compaction-boundaries.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "ffa0a8f64930eb3687b6e41b457b29280290ba326f5b08a63ff6fe39bd07f183",
    "verified_classes": [
      "StateCompactionDriftError",
      "ExternalizedTaskLedger",
      "CompactionBoundaryGate"
    ],
    "verified_functions": [
      "__init__",
      "save_checkpoint",
      "load_and_verify_on_resume",
      "assert_hypothesis_not_falsified"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "StateCompactionDriftError"
    ],
    "sample_fail_closed_invariants": [
      "Cannot checkpoint ledger with empty immutable_constraints."
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "json",
      "pathlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
