{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-silent-fact-loss-during-automatic-context-compaction-in-long-horizon-agents",
  "title": "Which invariants prevent silent fact-loss during automatic context compaction in long-horizon agents",
  "date_of_record": "2026 November 24",
  "scope": "Applies to any agent that executes a long-horizon task by periodically compacting its own context window (summarize-and-evict, rolling checkpoint, or hierarchical memory tiering) while continuing to act on the surviving summary. Does not apply to agents whose entire working set provably fits in one context window, or to stateless single-shot inference where no compaction ever fires.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-fact-loss-during-automatic-context-compaction-in-long-horizon-agents.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-fact-loss-during-automatic-context-compaction-in-long-horizon-agents.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-fact-loss-during-automatic-context-compaction-in-long-horizon-agents.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2253,
    "python_slice_tokens": 351,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the summary is low quality.\" Summaries are always lossy; that is expected and tolerable. The failure is **loss of a fact whose truth value the agent later needs to make a decision, combined with the agent's continued confidence that its summary is complete.** A compaction that drops \"the user's account is flagged read-only until billing c...",
    "what_was_observed": "A file-organization agent ran for roughly four hours across a corpus of ~1,200 documents, compacting every time the context crossed 80% utilization. Early in the run, a tool call returned: `PermissionError: /srv/archive is mounted read-only (mode=ro); writes will fail with EROFS`. The summarizer, at the next compaction, folded this into: \"Some archive paths may be restricted; proceed carefully with write operations.\"...",
    "condition_of_validity": "The invariant \"constraints survive compaction with binding force intact\" holds only under a specific architectural condition, and it is worth being precise about what that condition is because most compaction implementations quietly violate it: **A compaction is valid only if every evicted span is either (a) provably irrelevant to all reachable future branch...",
    "decision_boundary": "The operational decision is: **when a compaction would evict a span, is that span load-bearing?** The agent cannot answer this by reading the span — load-bearingness is a property of future branches, not of the text. So the decision must be made by a *classifier with a conservative bias*, applied at write time, not at compaction time. The boundary condition ...",
    "operational_effect": "With ingestion-time pinning and an immutable pinned region, the failure trace above becomes impossible by construction: the `EROFS` string, the path, and the error code live in the pinned store, are re-injected into every post-compaction context verbatim, and the agent's error classifier still matches on `EROFS`. The summary may still say \"archive operations..."
  },
  "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": "b5093e12a859b17d70985fa2730dcd2f3904188db58577ff16ebf193a9d61369",
    "verified_classes": [
      "CompactionInvariantViolation",
      "Span",
      "Context"
    ],
    "verified_functions": [
      "is_load_bearing",
      "ingest",
      "summarize",
      "compact",
      "run_compaction_cycle"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "CompactionInvariantViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
