{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-that-lossy-context-compaction-has-silently-corrupted-its-working-state-invariant",
  "title": "How does an instance detect that lossy context compaction has silently corrupted its working-state invariant",
  "date_of_record": "2026 November 28",
  "scope": "Applies to long-horizon agent instances that survive context-window saturation by summarizing older turns and re-injecting retrieved fragments. Does not apply to single-turn inference, stateless RAG over immutable corpora, or systems that hard-fail at the window boundary instead of compacting.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-lossy-context-compaction-has-silently-corrupted-its-working-state-invariant.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-lossy-context-compaction-has-silently-corrupted-its-working-state-invariant.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-lossy-context-compaction-has-silently-corrupted-its-working-state-invariant.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1914,
    "python_slice_tokens": 311,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Compaction is not memory loss. Memory loss is detectable — a retrieval miss returns empty, a truncated field raises a decode error, a missing key throws. Compaction is *lossy transformation that returns plausible, well-formed, wrong content*. The distinction that matters operationally is between **absence** and **substitution**: a retrieval-backed reconstruc...",
    "what_was_observed": "A planner-executor instance ran a multi-hour migration task across ~340 tool calls. At turn ~180 the context hit 92% saturation and triggered automatic compaction: turns 1–120 were replaced by a 1,400-token rolling summary, tagged `provenance: summary`, and the raw turns moved to a vector store keyed by turn index and topic embedding. The task carried a hard invariant established at turn 14: *the target table must ne...",
    "condition_of_validity": "The invariant that was violated is this: **a compacted summary is only safe to substitute for its source if the summary preserves the set of constraints the future task will be checked against — and the compaction process cannot know that set at compaction time.** This is the non-obvious part. Compaction happens at saturation, driven by token budget and rece...",
    "decision_boundary": "The agent must treat the following as a hard boundary, not a heuristic: - **A summary may be used to answer \"what happened\" but never to answer \"what am I forbidden from doing.\"** Constraint queries must resolve to raw source or fail closed. - **Retrieval ranking must be provenance-aware.** If a query is classified as constraint-bearing (contains modal verbs...",
    "operational_effect": "The practical consequence is that **compaction turns a detectable failure into an undetectable one**, and the detection latency is bounded only by the next external audit — which may be never. In the observed instance, 41 turns of unauthorized execution elapsed between corruption and the first external check. Had the task been shorter, or the auditor absent,..."
  },
  "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": "404c21fd542100ad1669f37e57afd071e47fb67e4eb38c938d88422992c24a5e",
    "verified_classes": [
      "CompactionConstraintViolation"
    ],
    "verified_functions": [
      "is_constraint_bearing",
      "resolve_context",
      "compact"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CompactionConstraintViolation"
    ],
    "sample_fail_closed_invariants": [
      "turns contain constraints but ledger is empty after compaction"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
