Repository navigation
docs(llm): record P1.2 shadow-price + KV-cache audit — explicit defer - #144
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
/v1/messageshandler already honorscache_control:anthropic_routes.py:198_extract_prefix_cache_boundaryextracts prefix boundary from system blocks'cache_control. Upstream issues refactor(repl): extract haiku title extraction to helper (audit §1.1.1 slice #26) #196 / Web surface gap: 111 slash commands, only 5 UI pages #241 / chore: release v0.8.9 #289 / chore: release v0.8.46 #386 all CLOSED.memory_cache.py:721= auto prefix match (exact + prefix + supersequence + longest-common-prefix) → KV reuse happens automatically without explicit breakpoint.createFusionMlxFetch(fusion-mlx-adapter.ts:1373) intercepts/v1/messages→ translates to/v1/chat/completions, droppingcache_control(system array collapsed to single string). Fixing = route MLX direct to/v1/messages= large adapter refactor (1500+ lines, deliberately OpenAI-compatible per adapter:7), no concrete failure (auto-match covers it). Defer.Step 1+2 — shadow-price pruning: net-new, touches live compaction path.
shadowPrice/tool-result-pruner= 0 matches (net-new).hardCompact.ts:42truncateString(s, headChars=200, tailChars=100)= fixed head/tail per-string truncation, not cost-model based.sessionMemoryCompact.ts:153getToolResultIds/adjustIndexToPreserveAPIInvariants= tool_use/tool_result orphan correctness guard (binary existence), not frequency count.selectFreshToReplace(toolResultStorage.ts:804) = size-desc sort, not shadow-price.Step 4 —
surfaceOp:replace: blocked by P0.2 defer (PR #143). Depends onSessionEvent/surfaceOpprojection which is explicitly deferred.Cross-repo boundary
fusion-mlx KV API (
cache_controlhonor + 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]