Repository navigation
[PR] fix: classify marker-migrated tail appends as append, not mid-history rewrite (#4133) - #4139
ranxianglei wants to merge 1 commit into
Conversation
… rewrite (#4133) Client-managed rolling cache_control breakpoints (dsh / Claude Code style) move the ephemeral mark onto the newest message every turn, mutating the previous last message's bytes on every pure tail append. Raw byte LCP stops inside that message, before its array close bracket, so both diagnostic surfaces misread the pair as a mid-history rewrite: - the per-call body-stability ladder classes it "mid" (247/287 requests in the #4128 session); - detectSeam's #2059 tail-append arm sees msgIndex == prevMsgs-1 instead of prevMsgs and books a seam suspect on top of a big unexplained miss. Both surfaces now judge survival modulo cache_control migration: the ladder gains a gated would-be-"mid" rescue (shared message prefix compared with cache_control keys ignored at any depth) and seamLcp reports a cc-blind twin index (msgIndexCc) that the #2059 arm uses. Real content rewrites keep their flags (negative-control tests pin both directions).
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4929-pr.4139.e1cdda8This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4139.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 按失败签名(bodyClass="mid" / seam suspect / cache_control 迁移 / tail-append 误判)检索 open+closed PR:无并行修复。相关但不同机制:#3479(同一分类阶梯上的「in-unit growth」问题,#3476)、#2061(已合入的 #2059 provider-side 臂——本 PR 扩展的正是这条臂)。#4133 接单时已查重无立项。 开始独立审核(diff 已拉取:单 commit |
(ai: vllm-qwen/qwen3.8-27b) 标签: bug / dsh / scope/ui / p2(诊断分类缺陷,dsh profile web 滚动断点场景,仅观察面,与 #4133 定级一致) Review 结论(head
|
Closes #4133
What was wrong
Client-managed rolling
cache_controlbreakpoints (dsh profile web / Claude Code style: the ephemeral mark moves onto the newest message every turn) mutate the PREVIOUS last message's bytes on every pure tail append — the mark leaves it. Raw byte LCP therefore stops inside that message, before its array close bracket, and both diagnostic surfaces misread the pair as a mid-history rewrite:settleUsageReport,src/cache-ledger.ts) classes itbodyClass="mid"— 247/287 requests in the [Bug] anthropic lane: cache-hit % halved when the upstream relays an OpenAI-semantics backend (billing_usage.semantic=openai, input_tokens inclusive) #4128 session;detectSeam's [obs] detectSeam: tail-append turns are misattributed as local prefix breaks (msgIndex == prevMsgs is already computed but unused) #2059 tail-append arm seesmsgIndex == prevMsgs-1instead ofprevMsgsand books a seam suspect ("suspected mid-history prefix break") on top of any big unexplained miss.The upstream wire is stable (isolation experiments in #4133: pure append / stripped markers / migrated markers all hold ~99.7% hit rate). This is an observation/classification defect only — no wire change, no cache impact. bili's own cumulative marking (#1637) never produces this; only client-managed rolling marks do.
How it is fixed
Both surfaces now judge survival modulo
cache_controlmigration:eqModCacheControl: deep element equality ignoringcache_controlkeys at any depth (key order stays significant, parity with the existing JSON.stringify comparators);append, notmid. Healthy pairs never pay for the parse;seamLcpreports a cc-blind twin indexmsgIndexCc(extra pass bounded by the trailing cc-only-differing elements; zero work when strict equality held), and the [obs] detectSeam: tail-append turns are misattributed as local prefix breaks (msgIndex == prevMsgs is already computed but unused) #2059 arm uses it.Real content rewrites keep their flags — a content change at any shared index fails the cc-blind comparison exactly as before (negative-control tests pin both directions).
Behavior changes (disclosed)
/acp-cache+ reportstability.mid/ linebsbs="append")detectSeamattributionmsgIndexonlymsgIndexCcfield (strict vs cc-blind divergence index)No change to: wire bytes, compression behavior, fold/switch/restart/rewind/client attribution arms, thresholds (±64 / 1 KiB / arrClose), or any other class's reach into pairs that were already classified correctly — the rescue only runs where the old code said "mid".
Tests
New
tests/issue4133-cache-seam-cc-marker.test.ts(5 tests): rolling-mark append → append (was mid); marker reshuffle without growth → append; REAL mid rewrite ± marker migration → still mid/still seam-suspect (negative controls); detectSeam provider-side vs seam-suspect split. Negative control verified against pre-fix code: 4/5 fail there (the 5th is the over-correction guard).Local targeted suites green: new file +
cache-seam-detector,cache-seam-client-insert,cache-ledger,issue2868-byte-lcp-utf8,issue2131-seam-capped-body-attribution,compress-observability,issue1547-nonstream-cache-ledger,cache-ledger-{effort,key,prompt,projection}-switch— 137 pass / 0 fail. Typecheck + build clean. Full-suite verdict: CI on this head.