{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-lossy-summary-compaction-from-silently-violating-an-agent-s-tool-call-atomicity-contract",
  "title": "Which invariants prevent lossy-summary compaction from silently violating an agent's tool-call atomicity contract",
  "date_of_record": "2026 November 24",
  "scope": "Applies to long-running agents that persist state by summarizing evicted context windows under a fixed token budget and later rehydrate via retrieval-augmented lookup. Does not apply to stateless single-turn inference or to agents whose full transcript is retained verbatim in a durable store.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-summary-compaction-from-silently-violating-an-agent-s-tool-call-atomicity-contract.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-summary-compaction-from-silently-violating-an-agent-s-tool-call-atomicity-contract.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-summary-compaction-from-silently-violating-an-agent-s-tool-call-atomicity-contract.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1895,
    "python_slice_tokens": 353,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **semantic compression** and **contractual compression**. A summarizer is trained (or prompted) to preserve meaning: the gist of what happened, the user's intent, the salient facts. It is *not* trained to preserve the machine-checkable preconditions and postconditions that tool-call sequences depend on — the fact that ...",
    "what_was_observed": "A provisioning agent ran a 40-step task under a 32k context window with a compaction trigger at 80% utilization and a 2k-token summary budget. At step 27 the trigger fired mid-sequence: 1. Step 25: `acquire_lock(resource=\"db-primary\", ttl=300s)` → returned `{token: \"lk_7f3a\", acquired_at: T}`. 2. Step 26: `begin_migration(target=\"db-primary\")` → returned `{migration_id: \"m_91\", status: \"in_progress\"}`. 3. Step 27: co...",
    "condition_of_validity": "The atomicity-aligned compaction invariant holds — and the failure above is preventable — only under these conditions: - **Terminal-outcome ledger.** Every tool invocation must write a durable record `(call_id, tool, args_hash, status ∈ {pending, success, failure, abandoned}, deadline?, compensator?)` that lives *outside* the summarized context. The summariz...",
    "decision_boundary": "The boundary between safe and unsafe compaction is drawn at the question: **can the agent, after rehydration, distinguish \"this is done\" from \"this was started and I don't know if it finished\"?** - If the answer is yes (ledger-backed, pinned open-transactions, absolute deadlines), compaction is safe and the token budget may be spent freely on narrative. - If...",
    "operational_effect": "Enforcing the invariant changes the agent's behavior in three measurable ways. First, compaction frequency drops for transactional tasks (eviction waits for quiescent points) while rising for read-only tasks (no open transactions to gate on) — the budget is spent where it is safe. Second, rehydration becomes ledger-anchored: the resumed agent opens with an e..."
  },
  "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": "e0ae222e3ec6808a7953941e5eab816cf4928bb2e8f926c348bd42af673fa6e9",
    "verified_classes": [
      "ToolStatus",
      "LedgerEntry",
      "UnsafeCompactionError",
      "CompactionGate"
    ],
    "verified_functions": [
      "__init__",
      "open_transactions",
      "can_compact",
      "compact"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "UnsafeCompactionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
