{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-lossy-auto-compaction-from-silently-orphaning-retrieval-fallback-anchors-in-long-horizon-agent-context",
  "title": "Which invariants prevent lossy auto-compaction from silently orphaning retrieval fallback anchors in long-horizon agent context",
  "date_of_record": "2026 November 20",
  "scope": "Applies to agents that auto-compact their context window via lossy summarization while retaining an external retrieval index as a fallback for evicted content. Does not apply to pure append-only context with no summarization, nor to compaction that preserves verbatim pointers to every evicted span.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-auto-compaction-from-silently-orphaning-retrieval-fallback-anchors-in-long-horizon-agent-context.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-auto-compaction-from-silently-orphaning-retrieval-fallback-anchors-in-long-horizon-agent-context.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-lossy-auto-compaction-from-silently-orphaning-retrieval-fallback-anchors-in-long-horizon-agent-context.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1561,
    "python_slice_tokens": 284,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The dangerous case is not \"the summary lost detail.\" Summaries always lose detail; that is their job. The dangerous case is **summary/retrieval anchor divergence**: the compaction step rewrites the working memory into prose that no longer shares identifiers with the retrieval index it depends on for fallback. When the agent later needs a fact it summarized a...",
    "what_was_observed": "A long-horizon task agent (multi-hour, ~40 tool calls, context pressure forcing two compaction cycles) maintained an episodic log and an embedding+BM25 hybrid retrieval index over evicted spans. Compaction at turn 22 summarized a tool result that had recorded a specific resource identifier, `proj-7f3a-queue-eu-west`, as \"the EU queue for the project.\" At turn 31 the agent needed to re-read that queue's depth. It issu...",
    "condition_of_validity": "The orphaning failure requires three conditions simultaneously: 1. **Lossy summarization that mutates keys.** The summarizer is permitted to paraphrase, rename, or round. If compaction is constrained to preserve verbatim identifiers (a \"key-preserving\" summarizer), the failure cannot occur because summary tokens still hit the index. 2. **Fallback keyed on su...",
    "decision_boundary": "The operational decision is where to place the boundary between \"summarize freely\" and \"must preserve.\" The correct boundary is drawn per-token-class, not per-span: - **Free to paraphrase:** narrative reasoning, rationale, conversational filler, already-distilled conclusions. - **Must preserve verbatim (anchor class):** resource identifiers, exact numeric va...",
    "operational_effect": "With the anchor invariant enforced, the fallback path becomes *provably reachable*: a retrieval query built from preserved anchors deterministically hits the original span (exact-match on identifier, exact-match on numeric), so the agent can always recover the verbatim detail the summary elided. The cost is a modest increase in summary size (anchors are chea..."
  },
  "matched_failure_symptoms": [
    "HTTP_502_503_504_CASCADE",
    "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": "4c6342577f12b8d44fa5d3de516f291c0cdbfda07ba010f5044397327774ec73",
    "verified_classes": [
      "AnchorOrphaningError",
      "CompactionResult"
    ],
    "verified_functions": [
      "extract_anchors",
      "validate_compaction",
      "build_fallback_query",
      "compact_and_commit"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "AnchorOrphaningError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
