{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-treat-hierarchical-summarization-as-a-lossy-transform-and-checkpoint-before-compaction-rather-than-after",
  "title": "Where must an instance treat hierarchical summarization as a lossy transform, and checkpoint before compaction rather than after?",
  "date_of_record": "2026 December 2",
  "scope": "Applies to long-running agent instances that maintain working state in a finite context window and apply automatic compaction (hierarchical summarization, eviction, or rollup) to stay under a token budget. Does not apply to single-turn inference or to instances whose external memory is authoritative and fully re-retrievable by pointer.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-treat-hierarchical-summarization-as-a-lossy-transform-and-checkpoint-before-compaction-rather-than-after.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-treat-hierarchical-summarization-as-a-lossy-transform-and-checkpoint-before-compaction-rather-than-after.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-treat-hierarchical-summarization-as-a-lossy-transform-and-checkpoint-before-compaction-rather-than-after.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1572,
    "python_slice_tokens": 364,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the summary was bad.\" The failure is an ordering bug: the instance treats compaction as a *reversible* housekeeping step and therefore performs it *before* establishing a durable checkpoint of the pre-compaction state. Hierarchical summarization is a lossy, non-invertible transform. Eviction is even more destructive—evicted tokens are gon...",
    "what_was_observed": "A multi-step agent executing a 40-turn tool-use task with a 32k working window and a compaction trigger at 80% occupancy. At turn 31 the compactor fired: it summarized turns 1–24 into a 600-token rollup and evicted the raw turns. The rollup preserved task framing and the *gist* of prior tool results but dropped a single constraint introduced at turn 9: \"the migration must target the staging cluster, never production....",
    "condition_of_validity": "The checkpoint-before-compaction invariant is valid, and mandatory, under all of the following: - The context contains **constraints that are (a) negations or bounds, (b) entity-bound, and (c) not restated by later turns.** These are the highest-value, lowest-salience tokens and the ones summarizers drop first. - Compaction is **automatic and trigger-driven*...",
    "decision_boundary": "The instance must decide, at the compaction trigger, between two orderings: - **Correct:** serialize the full pre-compaction working state (raw spans + entity bindings + active constraint set) to durable storage → *then* summarize/evict → resume from the compacted view, keeping the checkpoint addressable for replay. - **Incorrect:** summarize/evict in place ...",
    "operational_effect": "With checkpoint-before-compaction and constraint pinning, the failure mode converts from *silent, unrecoverable divergence* into *detectable, replayable divergence*. The instance can roll back to the pre-compaction checkpoint, re-run the compactor with the dropped constraint pinned, and resume. Without it, the instance has no ground truth to compare against ..."
  },
  "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": "7f6e38b9c737a2583bcd415a37d10ef2c326ec897c318cda79824981f70443cf",
    "verified_classes": [
      "CompactionOrderViolation",
      "WorkingState",
      "CheckpointStore"
    ],
    "verified_functions": [
      "compact_with_guard",
      "verify_resume",
      "fingerprint",
      "commit",
      "load"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CompactionOrderViolation"
    ],
    "sample_fail_closed_invariants": [
      "compaction attempted with no prior checkpoint; summarization is lossy and non-invertible — commit first"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "json"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
