{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-of-prefix-cache-reuse-silently-degrade-when-compaction-runs-concurrently-with-a-cache-miss-storm",
  "title": "Why does an instance of prefix-cache reuse silently degrade when compaction runs concurrently with a cache miss storm",
  "date_of_record": "2026 November 11",
  "scope": "Applies to inference serving stacks that combine (a) a KV/prefix cache keyed on token prefixes, (b) a retrieval layer that injects variable-length context, and (c) a background compaction scheduler that rewrites or truncates stored context. Does not apply to stateless single-shot completion endpoints with no cross-request cache and no persistent context store.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-of-prefix-cache-reuse-silently-degrade-when-compaction-runs-concurrently-with-a-cache-miss-storm.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-of-prefix-cache-reuse-silently-degrade-when-compaction-runs-concurrently-with-a-cache-miss-storm.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-of-prefix-cache-reuse-silently-degrade-when-compaction-runs-concurrently-with-a-cache-miss-storm.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1448,
    "python_slice_tokens": 229,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two different notions of \"cache hit rate\" that operators routinely conflate: the *token-weighted* hit rate (fraction of prompt tokens served from cache) and the *request-weighted* hit rate (fraction of requests with any reusable prefix). Prefix reuse economics are governed by the token-weighted rate, because cost scales with cached-token discount a...",
    "what_was_observed": "In a serving cluster with a radix-tree prefix cache, retrieval-augmented requests sharing a ~6k-token system+document prefix, and a compaction job that rewrites context every N requests: - Steady state: token-weighted cache hit rate ~0.71, request-weighted ~0.94, amortized input cost per request ~0.34× uncached. - Under a burst of heterogeneous short queries (distinct retrievals, minimal shared suffix), request-weigh...",
    "condition_of_validity": "The observation holds when all of the following are true: 1. The prefix cache is keyed on exact token prefixes (radix or block-hash), so any rewrite above a shared node invalidates descendants. 2. Compaction rewrites, reorders, or truncates content that lies *within* a commonly shared prefix, rather than only in the per-request suffix. 3. Request arrival is ...",
    "decision_boundary": "The operational rule: **never schedule compaction on a request-count or request-hit-rate trigger; schedule it on a token-weighted-reuse trigger with a hysteresis band, and gate it on cache-warmth.** Concretely: - Compute token-weighted reuse `R_t = cached_tokens / total_prompt_tokens` over a sliding window. - Compute request-weighted reuse `R_r` over the sam...",
    "operational_effect": "Applying the token-weighted trigger with warmth gating: - Token-weighted hit rate held above 0.55 through the heterogeneous burst (vs. 0.03 collapse under request-count scheduling). - Amortized input cost per request returned to ~0.38× uncached within one window instead of two full compaction cycles. - Compaction throughput dropped ~20% (fewer, better-timed ..."
  },
  "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": "2dbb00dafb7e18c90e51ff4215339ec2915bbf585c2db9db86ab13880a20c57c",
    "verified_classes": [
      "CompactionCacheContentionError",
      "ReuseWindow"
    ],
    "verified_functions": [
      "schedule_compaction",
      "token_weighted",
      "request_weighted",
      "divergence"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "CompactionCacheContentionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
