Skip to content

docs(llm): record P1.2 shadow-price + KV-cache audit — explicit defer - #144

Merged
dahai80 merged 1 commit into
mainfrom
docs/p12-shadow-price-kv-cache-defer
Aug 26, 2026
Merged

dahai80 merged 1 commit into
mainfrom
docs/p12-shadow-price-kv-cache-defer

Conversation

@dahai80

@dahai80 dahai80 commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Context

Defer-list Item 8 (last item) = "P1.2 影子价压缩 + KV-cache 前缀边界协商" (architecture/fusion-code-enhance-0819.md:528). Audit the spec's 5 landing steps against current code, record explicit defer decision. Doc-only — no code change.

This completes the 8-item defer list (Items 1–7 resolved in prior PRs #140–#143).

Audit findings (3 steps)

Step 3 — KV-cache prefix boundary negotiation: server DELIVERED, client explicit breakpoint redundant.

Step 1+2 — shadow-price pruning: net-new, touches live compaction path.

  • shadowPrice / tool-result-pruner = 0 matches (net-new).
  • Current hardCompact.ts:42 truncateString(s, headChars=200, tailChars=100) = fixed head/tail per-string truncation, not cost-model based.
  • Reference-frequency signal partially exists but binary not frequency: sessionMemoryCompact.ts:153 getToolResultIds / adjustIndexToPreserveAPIInvariants = tool_use/tool_result orphan correctness guard (binary existence), not frequency count.
  • Microcompact alternate path selectFreshToReplace (toolResultStorage.ts:804) = size-desc sort, not shadow-price.
  • New cost model + live compaction path change, no concrete failure driving. Defer.

Step 4 — surfaceOp:replace: blocked by P0.2 defer (PR #143). Depends on SessionEvent/surfaceOp projection which is explicitly deferred.

Cross-repo boundary

fusion-mlx KV API (cache_control honor + auto prefix match) fully delivered — no upstream issue needed (upstream has no gap). This defer is a pure fusion-code client-side decision.

Gates

Doc-only (+19 lines, docs/model-providers.md). No typecheck/build/lint/test impact.

Co-Authored-By: Claude Fable 5 [email protected]

Audit P1.2 (enhance-0819.md:528) across 3 steps, defer as explicit decision:

Step 3 (KV-cache prefix boundary negotiation): fusion-mlx /v1/messages
ALREADY honors cache_control (anthropic_routes.py:198
_extract_prefix_cache_boundary; issues #196/#241/#289/#386 all CLOSED).
memory_cache.py:721 = auto prefix match (exact+prefix+supersequence+LCP)
-> KV reuse happens without explicit breakpoint. fusion-code MLX path
createFusionMlxFetch translates /v1/messages -> /v1/chat/completions,
dropping cache_control. Fixing = route MLX direct to /v1/messages =
large adapter refactor (1500+ lines, deliberately OpenAI-compatible),
no concrete failure (auto-match covers). Defer.

Step 1+2 (shadow-price pruning): net-new (shadowPrice/tool-result-pruner
0 matches). hardCompact.ts:42 truncateString = fixed head/tail, not
cost-model. Reference-frequency signal partially exists but binary not
frequency: sessionMemoryCompact.ts:153 getToolResultIds/
adjustIndexToPreserveAPIInvariants = orphan correctness guard, not
count. New cost model + live compaction path change, no failure driving.
Defer.

Step 4 (surfaceOp:replace): blocked by P0.2 defer (PR #143).

Cross-repo boundary: fusion-mlx KV API fully delivered, no upstream
issue needed.

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 4bcc8ca into main Aug 26, 2026
1 check passed
@dahai80
dahai80 deleted the docs/p12-shadow-price-kv-cache-defer branch August 26, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant