{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-priority-inversion-eviction-from-silently-deleting-the-only-copy-of-an-uncheckpointed-tool-result-during-mid-turn-context-com",
  "title": "Which invariants prevent priority-inversion eviction from silently deleting the only copy of an uncheckpointed tool result during mid-turn context compaction",
  "date_of_record": "2026 November 27",
  "scope": "Applies to long-horizon agent sessions that perform in-turn context compaction (budget arbitration + priority-based eviction) while tool calls are in flight or between the emit and ingest of a tool result. Does not apply to stateless single-turn inference, to sessions where compaction only runs at turn boundaries with no pending tool futures, or to systems that externalize every tool result to durable storage before admission.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-priority-inversion-eviction-from-silently-deleting-the-only-copy-of-an-uncheckpointed-tool-result-during-mid-turn-context-com.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-priority-inversion-eviction-from-silently-deleting-the-only-copy-of-an-uncheckpointed-tool-result-during-mid-turn-context-com.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-priority-inversion-eviction-from-silently-deleting-the-only-copy-of-an-uncheckpointed-tool-result-during-mid-turn-context-com.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2635,
    "python_slice_tokens": 376,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct reasons a context segment can be evicted: **low value** (the segment is redundant, stale, or superseded) and **low cost to lose** (the segment is recoverable from an external source). Priority-based eviction policies collapse these into a single scalar: a segment gets a priority score, and the lowest-scoring segment is dropped first. T...",
    "what_was_observed": "A planner agent running a ~30-step investigation with a 128 K token budget and a compaction trigger at 85% utilization. The compaction routine, invoked mid-turn after a tool call returned, computed a priority per segment: with `w_ref = 3.0`, `w_recency = 1.0`, `w_size = 1.0`, `tau = 8`. The just-returned tool result had `reference_count = 0` (it had not yet been cited — the model had not seen it), `age_steps = 0` (ma...",
    "condition_of_validity": "Priority-based eviction is sound **iff** all three hold: 1. **Recoverability:** every candidate segment has a durable, addressable backing copy (external store, deterministic re-execution, or an idempotent cache) such that eviction is a *pointer swap*, not a *deletion*. 2. **Stability:** the priority score of a segment does not change as a function of *when*...",
    "decision_boundary": "The arbitration routine must branch on recoverability *before* it consults priority: - **If a segment has a durable backing pointer:** it is evictable. Rank by priority among evictable segments only. Eviction rewrites the segment in place to a pointer stub (`[ref: sha256:...]`) that the model can re-materialize via an explicit `recall` tool. - **If a segment...",
    "operational_effect": "With pinning + deferred compaction + lifecycle-stable priors in place, the same 128 K / 85% session completed the 30-step investigation in 22 steps with zero re-fetch loops. The tool results were externalized to a content-addressed store at admission (satisfying recoverability), pinned until first reference (satisfying stability), and evicted as pointer stub..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "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": "85d582d81363ef6f97fe230ad507d1efa241da0e8d6b4ccb83284adc5387ccf1",
    "verified_classes": [
      "UnrecoverableEvictionError",
      "Segment"
    ],
    "verified_functions": [
      "arbitrate",
      "__init__"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "UnrecoverableEvictionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
