Repository navigation
[PR] cache-seam: attribute prefix breaks caused by a tools-array change (#5466) - #5476
ranxianglei wants to merge 10 commits into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10979-pr.5476.1cd17a2This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5476.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 本 PR 是 #5466(诊断归属缺口)的修复 PR,与 #5459(根因发现源)、#3023(client 归属臂)相关但机制不同:#5466 修的是 seam 指纹只看 messages、看不见 tools 数组变更这一盲区,现有 issue/PR 均未覆盖该修复本身。 标签: bug / pi / scope/ui / p3 —— 缺陷类(诊断误归属);触发案例来自 pi-native(#5459),但机制跨车道;改动面是 /acp-cache 监控/报告面;纯诊断信号修正,无可用性影响。 审核进行中。先行报告一个已确认的事实:head |
(ai: vllm-qwen/qwen3.8-27b) Review 结论:APPROVE(建议合入)。 核心修复正确、测试有牙、无回归、无 kernel 改动,CI 绿。同一账号无法对本人 PR 走 GitHub 正式 approve(API 返回 422「不能 approve 自己的 PR」),正式 approve / merge 由 owner 执行;本条是专职 reviewer 的完整审核结论。审完发现一处非阻塞小缺口(web 报告没接新桶),已在 PR 分支顺手修掉。 结构化八问
已顺手修(非阻塞,已在 PR 分支修掉)已顺手修:web 报告硬编码 miss 归因桶,新增 收工本 review lane 完成:核心修复 + 一处非阻塞 web 展示缺口已在 PR 分支收敛(head 现为 |
(ai: vllm-qwen/qwen3.8-27b) 审核结论:代码侧 ready,唯一阻塞是继承自 master 的红(存储 golden 族,已报到 #4599)。 这是 agent 提交的 PR,我没有重做,而是拉分支核码 + 修掉一处真缺陷 + 把分支同步到最新 master/ci-fixes。 结构化八问
我在这条 PR 上做的
判定:PR 本身可合;等存储 golden 族在 #4599 收敛、CI 转绿后即可由 owner 合入。我不关单不合并。 |
6e22c7b to
2288220
Compare
(ai: vllm-qwen/qwen3.8-27b) Merge-conflict fix complete — PR #5476 rebased onto current master and force-pushed: 七问 summary:
|
(ai: vllm-qwen/qwen3.8-27b) Red CI fixed — pushed 七问 summary:
|
(ai: vllm-qwen/qwen3.8-27b) Closing note for this lane (my full 七问 summary is already posted above): work here is done and verified. Final state, live-checked in this run:
No open items from the CI lane: the PR awaits normal review/approval and owner merge. Nothing further needed from me unless a new blocker appears. |
c157dd6 to
b43b71e
Compare
(ai: vllm-qwen/qwen3.8-27b) Re-review at head Re-reviewed after the branch was rebased onto a newer master. I diffed the PR-only patch (the 4 PR commits) between the previously-reviewed head What changed since my last review:
Verification at this head:
Verdict: APPROVE (recommended). The core fix is correct, regression-guarded, and purely diagnostic; the rebase is clean and the golden regen is minimal and correct. (Formal GitHub approve is owner-only and blocked for a self-authored PR, so this is the reviewer's recommendation for your final approve + merge.) 中文八问
收工:head |
(ai: vllm-qwen/qwen3.8-27b) Merge-conflict fix complete — PR rebased onto current master and force-pushed: 七问 summary:
|
#5466) The cache-seam monitor fingerprinted only the message list, but on the Anthropic wire the prompt prefix is system + tools + messages. A mid-session change to the request's tools array invalidates the cached span without touching any message, so detectSeam blamed the first incidental divergence -- the client (#3023) or an unexplained seam -- while the real cause sat hidden. Capture per-entry tool fingerprints at the two send chokepoints via a new toolsArrayFps() helper (name + canonical-json hash, order-sensitive). When the prev/cur tool tables differ, detectSeam books the residual into a dedicated prov:"tools" bucket ahead of the message-shape arms (tools precede messages in the prefix), naming which entries appeared/disappeared/were redefined/reordered. Stable tools, a missing capture on either side, and no-tools lanes keep the legacy arms untouched (fail soft, like the message ladder). Behavior change: misses induced by a mid-session tools-array change were previously mis-booked as prov:"client" / seam-suspect / provider-side; they now book into the new prov:"tools" bucket (+ report.seam.tools). Purely diagnostic -- no change to closure math, compression, billing, or caching behavior. Closes #5466
…ts export as unreferenced outside cache-ledger.ts
The #5466 fix adds prov:"tools" to the diagnostic ledger and the /acp-cache text report, but the web UI hardcodes its miss-attribution buckets, so a mid-session tools break was left out of every bucket: the unexplained residual did not subtract seam.tools.missed and no TOOLS chip or legend swatch rendered. Wire the new bucket through the detailSeam normalizer, the active-check, the legend, the chip list and the residual math, and add det.attr_tools / det.attr_tools_tip / det.leg_tools to both locales. Diagnostic display only - no billing, caching or compression change.
…toolSeamMissed ledger counters The #5466 tools-array seam bucket persists two new zero-initialized counters (toolSeams/toolSeamMissed) in session.metadata.cacheLedger. The storage-render goldens pin the sha256 of session.metadata, so all four wires' metadata section digest moves even though wire bodies, state, block contents, stats and every state-key digest stay byte-identical (section digests confirm: only 'metadata' and the derived full stateDigest changed). Sanctioned regen via scripts/update-storage-render-goldens.ts; reviewed diff — no drift beyond the two new counter fields.
b43b71e to
b6d19f1
Compare
Master 301e1a5 is red on the same 3 test shards (ubuntu 22/24 shard 3, windows 22 shard 4). The #2929 fold-probe test (tests/issue2929-codex-fold-double-miss.test.ts) is schedule-dependent and flaky; ci-fixes makes it deterministic (schedule-independent + hermetic wire shape). Also brings the architecture module-map fix (#6922). Per CI-failure coordination policy (#4599), merge ci-fixes into the PR branch to clear the inherited red.
[bot] 🏷 CI fix for PR #5476 (cache-seam tools attribution) — inherited red cleared. Diagnosis. The 3 failing checks — Fix. Per the CI-failure coordination policy (#4599), I merged Verification. Ran the targeted test locally after the merge: Push. 八问:
判定:继承红已清,等 CI 全绿即可合并;本 PR 的 cache-seam 功能改动未动。 Note: I attempted to post the one-line note to the #4599 CI-coordination thread per policy, but the mirror search did not surface that thread's internal number from this lane; the diagnosis + fix + sha are recorded here for the 总控. |
[bot] 🏷 Update: CI is now fully green on the new head |
(ai: vllm-qwen/qwen3.8-27b) Re-review at head The new head is a ci-fixes merge ("Merge ci-fixes into PR #5476 branch (clear inherited red)") on top of a rebase onto newer master. I verified the PR's actual contribution vs current master: the core feature is unchanged and correct. What the net diff (PR head vs current master) actually contains:
Disambiguation worth noting: Verification:
Verdict: APPROVE (recommended). The core fix is correct, regression-guarded, and purely diagnostic; the only additions are sanctioned ci-fixes convergence plus master's own rebase context. (Formal GitHub approve is owner-only and blocked for a self-authored PR, so this is the reviewer's recommendation for your final approve + merge.) 中文八问
收工:head |
[bot] 🏷 Conflict-resolution check for PR #5476 — no action needed (claim was stale) This run was triggered by a system forward claiming "The PR conflicts with its base branch (merge state: dirty): rebase (or merge) the target branch into your branch, resolve ALL conflicts, force-push (rebase) or push (merge)." I re-verified the live state before acting: Live state (GitHub API, this run):
Conclusion: The "merge state: dirty" claim is stale/incorrect. The PR is NOT conflicting with master. No rebase, no merge, no push needed. The branch is already up to date with master. Note on git remote: The 八问:
判定: 无需操作。PR 分支已包含当前 master,无冲突,CI 已绿。等待 owner 合并。 |
…ead 77fe0b1) [ework:ci-held]
…mbined PR+master code state)
[bot] 🏷 Conflict resolved — PR #5476 rebased onto new master head This run re-verified the live state: master had moved forward since the last check (was What was done:
Commits added this run:
八问:
判定: 冲突已解决,CI 已触发(head |
(ai: vllm-qwen/qwen3.8-27b) Re-review at head Another rebase onto newer master. The PR's net contribution vs current master is the clean 10-file tools feature, byte-identical to what I approved at
Disambiguation (master's own changes rebased in, NOT PR work): the branch-to-previous-head diff shows a Verification:
Verdict: APPROVE (recommended). Core fix correct, regression-guarded, purely diagnostic; the only additions are master's own rebase context. (Formal GitHub approve is owner-only and blocked for a self-authored PR — this is the reviewer's recommendation for your final approve + merge.) 中文八问
收工:head |
(ai: vllm-qwen/qwen3.8-27b) No change since my re-review above — the head is still |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Round complete for head
Awaiting owner approve + merge. (Formal GitHub approve is owner-only and blocked for a self-authored PR — this is the reviewer's recommendation.) |
[bot] 🏷 Conflict resolved again — PR #5476 merged onto new master head Re-verified live state: master had advanced again (was What was done:
Commits added this run:
八问:
判定: 冲突已解决,CI 已触发(head |
[bot] 🏷 Re-verification run (attempt 1/6) — conflict already resolved, no new action needed. This run was triggered by the "merge state: dirty" forward. I re-verified the live state before acting and found the conflict was already resolved and pushed by the prior run (floor 49, Nov 18): master Live state (verified this run):
Nothing left to push. Awaiting CI completion + owner approve/merge (merge is human-only). 八问:
判定: 无需操作。PR 分支已包含当前 master( |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-review at head The branch was merged with the new master head ( Net diff vs current master = the clean 10-file tools feature — the 5 source files + the 7-case test are unchanged from what I approved; the 4 storage-render goldens are regenerated against the new master base (the new
Verification:
Verdict: APPROVE (recommended). Core fix correct, regression-guarded, purely diagnostic; the only additions since 中文八问
收工:head |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Master moved again ( 七问:
判定:冲突已解决,PR head 现为 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-verified live first: the reported check 七问:
判定:CI 已全绿(镜像缓存 30/30,0 failed / 0 pending;GitHub run attempt 2 conclusion success)。本次无代码改动(故无 ci-held 中间提交)。该时序测试在重载分片上仍可能偶发 flake,属独立子系统(非本 PR 范围),本车道不擅自改其断言;PR 仍等人工 review 合并。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-verified live: the reported check |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-review at head Master advanced ( Net diff vs current master = the clean 10-file tools feature, unchanged from what I approved:
Verification:
Verdict: APPROVE (recommended). Core fix correct, regression-guarded, purely diagnostic; the only addition since 中文八问
收工:head |
(ai: vllm-qwen/qwen3.8-27b)
Problem
The cache-seam monitor attributes a provider prefix break by fingerprinting only the message list. But on the Anthropic wire the prompt prefix is
system + tools + messages, so a mid-session change to the request'stoolsarray invalidates the cached span without touching any message. The monitor then reported the first incidental message-level divergence — blaming the client (#3023) or an unexplained seam — while the real cause sat hidden behind the wrong attribution. This is exactly what masked the root cause in #5459 (pi-native first round missing bili's tools): the seam line pointed atmessage[1]while the true break was thetoolsarray gaining 6 entries.Fix
toolsArrayFps()helper captures a per-entry tool fingerprint (name + canonical-json hash, order-sensitive) from the fully-parsed request body at both send chokepoints (src/server/relay.ts,src/loop/core.ts), mirroring howgenerationParamFpalready rides the full parse.detectSeamgains a dedicated arm that runs ahead of the message-shape arms (tools precede messages in the prefix, so it's the earliest break). When the prev/cur tool tables differ it books the residual into a newprov:"tools"bucket and names which entries appeared/disappeared/were redefined/reordered./acp-cachetext and the web report as a distinct "TOOLS-ARRAY CHANGE" section (report.seam.tools).Behavior change (diagnostic only)
Misses induced by a mid-session tools-array change were previously mis-booked as
prov:"client"/ seam-suspect / provider-side; they now book into the newprov:"tools"bucket. No change to closure math, compression, billing, or actual caching behavior —detectSeamis purely diagnostic. Frequency is low (only when the tool set changes mid-session: late plugin registration, dynamic tool enable/disable).Tests
New
tests/cache-seam-tools-change.test.ts(7 cases): the fix, the #5459 shape (tools gained + turn appended → still attributed to tools, not provider-side/client), plus no-regression guards (stable tools keep client/seam attribution) and fail-soft boundaries (no tools / one-sided capture). Re-ran the existing seam suites (cache-seam-detector, client-insert, orphan-sweep, nobaseline, capped-body, suspect-vs-client, context-view, cache-ledger, capture-pairing) — all green. Typecheck + build green on the rebased head.Closes #5466