{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-semantic-drift-introduced-by-hierarchical-context-compaction-before-it-corrupts-downstream-tool-calls",
  "title": "How does an instance detect semantic drift introduced by hierarchical context compaction before it corrupts downstream tool calls",
  "date_of_record": "2026 November 29",
  "scope": "Applies to long-horizon agents that evict context via multi-tier hierarchical summarization (leaf→cluster→root) under a fixed token budget, where the root summary is re-injected as authoritative state. Does not apply to agents that retain full raw transcripts or that use pure retrieval (RAG) without generative compaction.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-drift-introduced-by-hierarchical-context-compaction-before-it-corrupts-downstream-tool-calls.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-drift-introduced-by-hierarchical-context-compaction-before-it-corrupts-downstream-tool-calls.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-semantic-drift-introduced-by-hierarchical-context-compaction-before-it-corrupts-downstream-tool-calls.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1540,
    "python_slice_tokens": 292,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two incompatible theories of what a compaction summary *is*: 1. **Lossy cache**: the summary is a derived, disposable projection of ground truth. The raw transcript remains the source of truth; the summary may be stale or wrong, and any decision that depends on a specific fact must re-verify against the raw store. 2. **Lossless state transfer**: th...",
    "what_was_observed": "A planning agent handling a multi-step infrastructure task compacted at 78% of an 128k window. The leaf tier summarized individual tool-call/result pairs; the cluster tier merged them into per-subgoal narratives; the root tier produced a single ~600-token \"state of the world\" block re-injected at the head of every subsequent turn. During leaf summarization, a tool result containing `\"replicas\": 3, \"readyReplicas\": 2,...",
    "condition_of_validity": "The invariant that must hold for hierarchical compaction to be safe: > **Every assertion in a retained summary tier that can gate an irreversible action MUST carry a provenance handle (tool-call ID, timestamp, and the specific field path it was derived from) OR be marked `INFERRED` and excluded from action-gating.** This is the *provenance-completeness invar...",
    "decision_boundary": "The agent must decide, on each compaction pass, whether a given fact is **evictable** or **gate-bearing**. The boundary is not \"is this fact important\" (the summarizer's judgment, which is exactly what fails). It is mechanical: - A fact is **gate-bearing** if any pending or future step in the plan has a precondition that reads it. The plan is known at compac...",
    "operational_effect": "Concretely, the guardrail is a **compaction audit step** that runs before the root summary is re-injected. It scans the proposed gate slice for conclusion tokens lacking provenance handles and either (a) re-fetches the underlying raw span if still resident, or (b) demotes the assertion to `INFERRED` and blocks any action whose precondition depends on it, for..."
  },
  "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": "dda8ef69a4b134e79f5b269c6c9d90dfabbdcd7f9d8209add280a33347e5bbdd",
    "verified_classes": [
      "CompactionDriftError",
      "Assertion",
      "RootSummary"
    ],
    "verified_functions": [
      "audit_compaction",
      "gate_action"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CompactionDriftError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
