{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-preserve-task-critical-state-when-automatic-context-compaction-silently-evicts-the-invariant-it-depends-on",
  "title": "How should an instance preserve task-critical state when automatic context compaction silently evicts the invariant it depends on",
  "date_of_record": "2026 November 21",
  "scope": "Applies to any agent runtime that performs automatic context compaction (summarization, truncation, or eviction) on a live reasoning loop under window pressure. Does not apply to stateless single-turn calls, nor to systems where compaction is disabled and hard context overflow is handled by explicit task abort.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-preserve-task-critical-state-when-automatic-context-compaction-silently-evicts-the-invariant-it-depends-on.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-preserve-task-critical-state-when-automatic-context-compaction-silently-evicts-the-invariant-it-depends-on.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-preserve-task-critical-state-when-automatic-context-compaction-silently-evicts-the-invariant-it-depends-on.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1561,
    "python_slice_tokens": 268,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the summary was lossy.\" It is that **compaction is a lossy, non-monotonic transformation applied to state that a downstream step treats as authoritative and idempotent.** A summarizer is a probabilistic function `S: tokens → tokens`. When the runtime replaces the live context `C` with `S(C)` and continues, every subsequent step executes a...",
    "what_was_observed": "A multi-step agent executing a migration task held, in an early turn, the constraint `TARGET_SCHEMA_VERSION = 7` and the instruction \"never drop the `legacy_id` column.\" After ~40 tool-call turns, the window hit the compaction threshold (85% utilization). The runtime's compactor summarized the first 30 turns into four sentences. The summary read: \"User asked to migrate the database to the current schema and clean up ...",
    "condition_of_validity": "Compaction is safe **iff** every token it evicts is either (a) reconstructible from surviving context by a deterministic function, or (b) externalized to durable, addressable storage that the loop re-reads before any dependent action. Formally, for the evicted set `E` and surviving context `C'`: `∀ e ∈ E that a future guard or step reads, e ∈ C' ∨ e ∈ Extern...",
    "decision_boundary": "The runtime must decide, at the moment of compaction, between two policies, and the boundary is **re-derivability, not importance**: - **Externalize-and-pin:** If a span is an invariant (unreconstructible literal that a guard reads), move it to a pinned slot that compaction is forbidden to touch. It stays verbatim for the life of the task. - **Summarize-and-...",
    "operational_effect": "With pinned invariants plus a read-before-act check against the pin store, the destructive `DROP COLUMN legacy_id` is blocked at `t=33` because the guard resolves the prohibition from the pinned slot, not from the possibly-drifted summary. The cost is a small fixed token budget reserved for pins (typically <5% of window) and a mandatory re-read at each guard..."
  },
  "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": "a263d0e3cf4b5067a762d55d72de4bf1a72ff4af2fa710f2c590bc05ed387214",
    "verified_classes": [
      "CompactionInvariantViolation",
      "PinnedStore"
    ],
    "verified_functions": [
      "guarded_action",
      "compact",
      "pin",
      "resolve"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CompactionInvariantViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
