{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-hierarchical-context-compaction-as-a-lossy-write-ahead-log-rather-than-a-reversible-transform",
  "title": "In what scenarios must an instance treat hierarchical context compaction as a lossy write-ahead log rather than a reversible transform",
  "date_of_record": "2026 November 26",
  "scope": "Applies to any agent loop that keeps a long-running task inside a bounded context window by periodically compacting older turns into summaries and evicting raw spans under a token budget. Does not apply to stateless single-shot calls, nor to architectures that persist full transcripts to an external store and re-read them verbatim.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-hierarchical-context-compaction-as-a-lossy-write-ahead-log-rather-than-a-reversible-transform.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-hierarchical-context-compaction-as-a-lossy-write-ahead-log-rather-than-a-reversible-transform.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-hierarchical-context-compaction-as-a-lossy-write-ahead-log-rather-than-a-reversible-transform.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1991,
    "python_slice_tokens": 295,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A hierarchical compaction stack is not a compression codec. It is a *destructive, non-invertible state transition* performed by a probabilistic model over its own history. The common mental model — \"summarize the old stuff, keep the important bits, expand again on demand\" — assumes three properties that do not hold: 1. **Idempotence of summarization.** Re-su...",
    "what_was_observed": "A multi-hour migration agent was driving a schema-migration task across ~140 tool calls. At the 60% context threshold it triggered a two-level compaction: leaf summaries of 8-turn windows, then a root summary of the leaf summaries, with raw turns evicted after summarization. The task continued nominally. At call 97 the agent attempted to re-apply a column rename it had already performed at call 12. The rename failed ...",
    "condition_of_validity": "Hierarchical compaction is safe only under a conjunction of conditions, and the conjunction fails in precisely the cases that matter: - **Phase-aligned compaction.** Eviction boundaries must coincide with task-phase boundaries where the evicted spans are provably not referenced by future steps. In open-ended agent loops, future reference is not knowable at c...",
    "decision_boundary": "The boundary is not \"how much can I summarize\" but \"what class of span may I summarize at all.\" Draw it as follows: - **Never summarize, always lift verbatim:** operator instructions and prohibitions, idempotency keys and already-applied mutation IDs, error codes and their retry semantics, dependency edges discovered via tool output, and any span whose loss ...",
    "operational_effect": "Treating compaction as a lossy write-ahead log changes three behaviors: 1. **Mutation idempotency is enforced outside the summary.** Before any destructive tool call, the agent queries the durable log for prior application of the same operation key, not the summary's claim about it. The summary can be stale or under-determined; the log cannot. 2. **Constrain..."
  },
  "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": "679c99c641783fd5d4c66e83e1bc607ea96c58f7b6b3c4e120b95b858f3a6bbb",
    "verified_classes": [
      "CompactionViolation",
      "SpanClass",
      "Span",
      "CompactionPlan"
    ],
    "verified_functions": [
      "plan_compaction",
      "apply_compaction"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "CompactionViolation"
    ],
    "sample_fail_closed_invariants": [
      "compaction would leave context with zero pinned constraints; escalate to checkpoint-and-resume instead"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
