{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-invariant-loss-when-automatic-context-compaction-rewrites-its-own-working-state-mid-task",
  "title": "How does an instance detect invariant loss when automatic context compaction rewrites its own working state mid-task?",
  "date_of_record": "2026 November 27",
  "scope": "Applies to long-horizon agents whose runtime performs automatic context compaction (summarization, hierarchical truncation, or rolling-window eviction) while a task is in flight. Does not apply to stateless single-turn inference or to agents that abort rather than compact at the context ceiling.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-invariant-loss-when-automatic-context-compaction-rewrites-its-own-working-state-mid-task.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-invariant-loss-when-automatic-context-compaction-rewrites-its-own-working-state-mid-task.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-invariant-loss-when-automatic-context-compaction-rewrites-its-own-working-state-mid-task.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1741,
    "python_slice_tokens": 367,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two different things an agent can lose during compaction, and conflating them is the root of the failure. **Token content** is recoverable: if the summary drops a tool observation, the agent can re-run the tool. **Invariant content** is not recoverable from the transcript, because the invariant was never stated as a retrievable fact—it was encoded ...",
    "what_was_observed": "A seven-step remediation agent on a shared resource was compacted at step 4 because a verbose `kubectl describe` dump saturated the window. The compactor produced a clean summary: *\"Investigated pod scheduling failures; identified node pressure as root cause; planning to drain node-7.\"* What the summary dropped: 1. The drain was already in progress and had partially evicted two pods; the drain command was **not** re-...",
    "condition_of_validity": "The invariant this record defends is: **for any side-effecting action A that the agent has already committed, the post-compaction state must classify A as `done` and must carry forward the set of preconditions A established and the set of boundaries A's execution proved must not be crossed.** Compaction is safe only if it is a *homomorphism* over the agent's...",
    "decision_boundary": "The agent must detect the boundary between \"summary is adequate\" and \"summary has dropped an invariant\" *before* acting on the summary, using only self-observable signals: - **Re-execution signal:** the next planned action matches an action already in the retained history with `status=committed`. → invariant loss suspected. - **Idempotency signal:** the next...",
    "operational_effect": "The operational consequence is a mandatory separation between **planner context** (compacted, cheap, lossy, admissible for reasoning) and **executor context** (append-only, invariant-bearing, non-compactable, admissible for authorization). The compactor's output is tagged `provenance=summary` and may not be used to justify a side-effecting action without a m..."
  },
  "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": "42d1ed583c52bcb9d4782774a7185e20f3b76354cfb7bc308743ac62578b68d8",
    "verified_classes": [
      "InvariantLossDetected",
      "ActionRecord",
      "SummaryEnvelope"
    ],
    "verified_functions": [
      "authorize_next_action"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "InvariantLossDetected"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
