{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-silent-loss-of-task-critical-state-during-automatic-context-compaction",
  "title": "Which invariants prevent silent loss of task-critical state during automatic context compaction",
  "date_of_record": "2026 November 7",
  "scope": "Applies to any agent runtime that performs automatic context compaction (summarization, truncation, or eviction) on a conversation/tool-trace buffer whose earlier entries are still semantically load-bearing for the current task. Does not apply to stateless single-turn inference, nor to systems where the full context is always re-sent and never truncated.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-loss-of-task-critical-state-during-automatic-context-compaction.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-loss-of-task-critical-state-during-automatic-context-compaction.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-loss-of-task-critical-state-during-automatic-context-compaction.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1571,
    "python_slice_tokens": 195,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Compaction is usually described as a *token-budget* operation: when the buffer exceeds N tokens, summarize or drop the oldest K tokens. The non-obvious failure is that the *unit of preservation* is not the token, the turn, or the message — it is the **invariant**. A compaction strategy that preserves 95% of tokens but drops the single message carrying a hard...",
    "what_was_observed": "In a long-running coding/tool-use agent, compaction was triggered at a 128k-token watermark with a summarizer that rewrote the oldest 60% of the trace into a paragraph. Across a set of tasks, the following recurring losses appeared: 1. **Constraint evaporation.** A user instruction from turn 3 — \"the migration must remain reversible; do not drop columns\" — was summarized as \"user wants a database migration.\" The reve...",
    "condition_of_validity": "The invariant-preserving claim holds only under these conditions; outside them, compaction guarantees are void: - **Invariants are identified at write time, not at compaction time.** A message must be tagged as carrying a commitment (constraint, decision, identifier, ordering) when it is appended. Compaction cannot reliably reconstruct which prose was load-b...",
    "decision_boundary": "The operational decision is **whether to compact or to refuse and escalate**, and it hinges on whether the invariant set is *closed and verified* at the moment of compaction: - If every commitment in the buffer is tagged and the post-compaction audit confirms the tagged set is unchanged → **compact**, proceeding normally. - If tagged regions exist but the au...",
    "operational_effect": "With invariant-tagged compaction in place, the observable effects were: - Destructive-action incidents (drops, overwrites, out-of-order execution) attributable to compaction fell to zero across the observed task set, because the constraints that gated those actions were never in the summarized region. - Identifier and committed-value drift disappeared, since..."
  },
  "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": "dc2141f3f2b1e5950ddead4a11b239f3dfd5dce75ea53e9379d12c9364ec333c",
    "verified_classes": [
      "CompactionInvariantError",
      "Region"
    ],
    "verified_functions": [
      "compact",
      "flush"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "CompactionInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
