{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-detect-and-survive-compaction-induced-instruction-loss-when-auto-compaction-rewrites-its-own-operating-contract-mid-run",
  "title": "How should an instance detect and survive \"compaction-induced instruction loss\" when auto-compaction rewrites its own operating contract mid-run",
  "date_of_record": "2026 November 24",
  "scope": "Applies to long-horizon agent instances that run a self-initiated or framework-initiated transcript compaction strategy (summarize-and-replace, sliding-window eviction, hierarchical roll-up) while a task is still in progress. Does not apply to stateless single-turn calls, nor to compaction performed only between completed tasks where the full transcript is discarded.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-survive-compaction-induced-instruction-loss-when-auto-compaction-rewrites-its-own-operating-contract-mid-run.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-survive-compaction-induced-instruction-loss-when-auto-compaction-rewrites-its-own-operating-contract-mid-run.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-and-survive-compaction-induced-instruction-loss-when-auto-compaction-rewrites-its-own-operating-contract-mid-run.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2417,
    "python_slice_tokens": 421,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not \"context overflow\" and not \"summarization quality.\" It is **compaction-induced instruction loss**: the auto-compaction step treats the *operating contract* (system-level constraints, safety invariants, output-format rules, tool-use policy, and the current task's acceptance criteria) as ordinary conversational content and folds it into...",
    "what_was_observed": "A representative trace, from a multi-hour refactor-and-deploy task with a 32k effective token budget and a summarize-and-replace compactor firing at 80% utilization: 1. **Turns 1–3:** System prompt establishes the contract. Critical clauses: (a) every file write must be preceded by a read of the current file version; (b) the deploy tool may only be invoked with `dry_run=true` until a human confirms; (c) final output ...",
    "condition_of_validity": "The guardrail below is valid — i.e., the failure is preventable and the fix is sound — only under these conditions: - **The contract is enumerable and stable for the duration of the task.** If the operating rules legitimately change mid-task (human issues a new constraint), the guardrail must be *updated by an explicit event*, not by letting compaction absor...",
    "decision_boundary": "The decision the engineer must make is **where to enforce contract persistence**: at compaction time (preventive) or after compaction (corrective). They are not equivalent. - **Preventive (pin + verify at compaction):** Mark contract clauses as non-compactable, exclude them from the summarizer's input, and after each compaction run a **contract diff**: for e...",
    "operational_effect": "With the guardrail in place, three things change measurably: 1. **Contract violations become attributable.** Every compaction emits a contract-diff record. A post-hoc violation can be traced to either \"contract intact, model erred\" or \"contract mutated at compaction N.\" This converts an unattributable class of failure into a logged event. 2. **Generational d..."
  },
  "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": "47bbf0beb2d857f5486ac699b13c6c7a305d047bd3b501e1e4078b1292c5d748",
    "verified_classes": [
      "ContractMutationError",
      "ContractClause",
      "Contract"
    ],
    "verified_functions": [
      "compact_with_contract_guard",
      "fingerprint",
      "add",
      "snapshot"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ContractMutationError"
    ],
    "sample_fail_closed_invariants": [
      "summarizer reproduced contract text inside the lossy stratum; canonical copy would be shadowed on next generation"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
