{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-lossy-context-compaction-from-silently-corrupting-an-agent-s-task-state-during-retrieval-backed-rehydration",
  "title": "Which invariants prevent lossy context compaction from silently corrupting an agent's task state during retrieval-backed rehydration",
  "date_of_record": "2026 November 28",
  "scope": "Applies to long-horizon agents that auto-compact their working context via lossy summarization and later rehydrate dropped spans through retrieval (vector or keyword) keyed on the summary. Does not apply to agents operating within a single context window that never evict, nor to systems that persist full transcripts and replay them verbatim.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-context-compaction-from-silently-corrupting-an-agent-s-task-state-during-retrieval-backed-rehydration.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-context-compaction-from-silently-corrupting-an-agent-s-task-state-during-retrieval-backed-rehydration.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-context-compaction-from-silently-corrupting-an-agent-s-task-state-during-retrieval-backed-rehydration.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1628,
    "python_slice_tokens": 213,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two ways an agent \"remembers\" a past span after compaction: **verbatim recall** (the original tokens are still addressable) and **semantic recall** (a summary asserts what the span meant). Automatic compaction collapses the first into the second — the summary becomes the *only* handle to the original state, and retrieval is the mechanism that re-ex...",
    "what_was_observed": "A tool-using agent ran a multi-hour infrastructure remediation task. At step ~140, context saturation triggered compaction. The compactor summarized a block of early discovery tool calls as: > \"Confirmed the target cluster `prod-eu-2` has `max_replicas=12` and the rollout was already applied; proceed without re-applying.\" The original span actually contained two tool results: a config read of `prod-eu-2` showing `max...",
    "condition_of_validity": "The invariant holds — and the failure is bounded — only when all of the following are enforced: - **Entity-scoped retrieval keys.** Every summary sentence that carries a predicate must retain an explicit, machine-checkable binding `(entity, predicate, value)`. Retrieval must filter on entity equality *before* ranking on semantic similarity; similarity alone ...",
    "decision_boundary": "The agent must treat a rehydrated span as **authoritative** only if provenance-intersection succeeds and entity keys match exactly. Otherwise it must treat the span as **advisory** and re-verify against the live source (re-run the tool, re-read the config) before acting on it. The boundary is sharp: - **Provenance intersects + entity matches** → rehydrated c...",
    "operational_effect": "Without the provenance-and-entity gate, compaction converts a *bounded* memory loss into an *unbounded* correctness loss: the agent's confidence in a reconstructed fact is decoupled from whether the reconstruction is true. The summary acts as a lossy compression that is also a *lossy index*, and the index error is invisible because retrieval always returns s..."
  },
  "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": "32fd756fc0df5980199c827d2cfc0db877c08d80c8ac94273cbef1854dcd6291",
    "verified_classes": [
      "CompactionRehydrationError"
    ],
    "verified_functions": [
      "rehydrate",
      "safe_act"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "CompactionRehydrationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
