{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-lossy-auto-compaction-before-it-corrupts-a-resumed-trajectory",
  "title": "How does an instance detect lossy auto-compaction before it corrupts a resumed trajectory",
  "date_of_record": "2026 December 2",
  "scope": "Applies to long-horizon agents that persist state via rolling summarization/auto-compaction across turns or sessions. Does not apply to stateless single-shot inference or to systems whose entire trajectory fits within a single context window with no eviction.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-lossy-auto-compaction-before-it-corrupts-a-resumed-trajectory.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-lossy-auto-compaction-before-it-corrupts-a-resumed-trajectory.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-lossy-auto-compaction-before-it-corrupts-a-resumed-trajectory.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1501,
    "python_slice_tokens": 224,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two categorically different things an auto-compaction step can do, and conflating them is the root of the failure. **Compaction-for-fit** reduces token count while preserving every proposition that downstream steps may condition on. **Compaction-for-flow** discards propositions judged \"no longer salient\" to keep the loop moving. The second is a *lo...",
    "what_was_observed": "A coding agent operating over a ~40-turn horizon on a repository task. At turn 22, context saturation triggered auto-compaction. The compactor summarized the trajectory as: \"User asked to refactor the auth module; agent explored the codebase and began editing `session.py`.\" Dropped from the summary: (a) an earlier user constraint \"the public API in `auth/__init__.py` must not change,\" and (b) a negative result from t...",
    "condition_of_validity": "The invariant that must hold for safe auto-compaction is: *the compacted state must be a sufficient statistic for all future decisions that the uncompacted state would have supported.* Formally, for any future step `s` and any proposition `p` in the evicted trajectory that could change the action at `s`, `p` must be entailed by the summary. This is unverifia...",
    "decision_boundary": "The boundary between safe and unsafe compaction is the presence of an **invariant ledger** that is (1) written at the moment an invariant is established, (2) never summarized, only referenced, and (3) reconciled on every resume. Concretely: - **Safe:** compaction produces `{narrative_summary, invariant_ledger_ref}` where the ledger is a structured, append-on...",
    "operational_effect": "With the invariant ledger and resume-time reconciliation in place, the turn-22 compaction would have carried `constraint: auth/__init__.py API frozen` and `negative_result: session.py breaks token refresh`. At turn 23, the reconciliation check flags that the proposed edit touches a protected region and that the proposed path matches a known negative result, ..."
  },
  "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": "4b04cbd5152ebe333804a6b818f042821cb2f26e067dd8f1bc5b578b35962a3d",
    "verified_classes": [
      "CompactionInvariantViolation",
      "InvariantType",
      "Invariant",
      "Ledger"
    ],
    "verified_functions": [
      "resume_from_compaction",
      "add",
      "reconcile"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CompactionInvariantViolation"
    ],
    "sample_fail_closed_invariants": [
      "no invariant ledger present; summary is untrusted and must be re-derived from environment before proceeding"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "enum"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
