Repository navigation
[PR] fix: exclude host-generated thinkingTokens from cache-seam client-origin evidence (#4043) - #4053
ranxianglei wants to merge 2 commits into
Conversation
…evidence projectThinkingMass (#1320) stamps CoreMessage.thinkingTokens onto Prepared.originalMessages before noteInboundMessages fingerprints the list, and re-derives the value every turn from the previous usage report — so a byte-stable client list showed positional fingerprint divergence at every signature-only reasoning message, and detectSeam's #3023 client arm booked a bili-owned miss as host churn (prov:"client" / clientInserts). Fingerprints are now computed over origin evidence: the message minus the host-generated metering fields (GENERATED_METERING_FIELDS, currently thinkingTokens). Signatures, raw payloads, tool ids and unknown semantic fields stay full evidence; miss accounting is untouched — the unexplained miss remains recorded and falls to the seam-suspect bucket instead of being attributed to the client or a provider without evidence. Messages without any generated field stringify byte-identically to before, so unaffected sessions keep their legacy fingerprints. Regression tests pin both directions (#3617 gate discipline): metering drift alone does not trigger the client arm; a genuine signature or text rewrite still does.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4840-pr.4053.9a386d3This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4053.tgz
npm install -g packageInstall instructions are refreshed on each push. |
|
(ai: vllm-qwen/qwen3.8-27b) Union coverage 补入:重复 PR #4055/#4056 里的 capture 侧直接 pin(指纹对 |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复——本线程即 #4043 的修复载体;与 #4055/#4056 的重复面已在 floor 3 处置(capture 侧 pin 并入 commit 7343c0f)。 CI 已跑完(head 1) 五个红 test 分片——全部红在 #3769 家族测试,与 master 自身红逐字同签名:
2) static-gates (ubuntu-latest, 24)——步骤 1–8 全绿(typecheck / kernel / pi-subagents / build 均过),仅第 9 步 八问(对本 PR 整体):
判定:PR 内容就绪(CI 内 typecheck/build/kernel/组件套件全绿,本地定向 21/21 绿);红的归属 = #4049 家族(master 既有,#4058 修复在途)+ 一例疑似瞬时的 static-gates 抖动。建议 #4058 合入后对本 PR rerun-failed-jobs 取全绿信号,然后由你合并。 |
What / why
projectThinkingMass(#1320) stampsCoreMessage.thinkingTokensontoPrepared.originalMessagesbeforenoteInboundMessagesfingerprints the list (src/server/prepare-anthropic.ts:201/212,src/server/budget.ts:175), and re-derives the value every turn from the previous usage report. The inbound fingerprint is a whole-messageJSON.stringify(src/cache-ledger.ts), so a byte-stable client list showed positional fingerprint divergence at every signature-only reasoning message — anddetectSeam's #3023 client arm booked a bili-owned unexplained miss asprov:"client"/clientInserts++("host churn") whenever the separate outbound-break + miss conditions held.Fix at the evidence boundary: fingerprints are now computed over origin evidence — the message minus host-generated metering fields (
GENERATED_METERING_FIELDS = ["thinkingTokens"]). Signatures, raw payloads, tool ids and unknown semantic fields stay full evidence. Miss accounting is untouched: the unexplained miss remains recorded and falls to the seam-suspect bucket — it is NOT erased and NOT assigned to a provider without evidence.Behavior change (old → new)
Anthropic-lane sessions with signature-only thinking blocks + measured usage: when the client's resent list is otherwise byte-stable but only the proxy-projected
thinkingTokensdrifted between turns, an unexplained mid-history break now booksline.seam=1/seamSuspectsinstead ofprov:"client"/clientInserts. Genuine client rewrites (signature change, text edit, insert/delete) still book the client bucket exactly as before. All other lanes/sessions are byte-identical: messages without any generated field stringify identically on the fast path, so legacy fingerprints are unchanged.InboundSlotlives undersession.transient(not persisted) — no storage format or cross-restart impact.Tests
tests/issue4043-metering-origin-evidence.test.ts— both directions pinned (#3617 gate discipline):tr > 8192),clientInserts === 0, no provider attribution (failed pre-fix, passes post-fix);clientInserts === 1,prov "client"(detection power retained);Targeted suites green locally on the rebased head (new file +
cache-seam-client-insert+issue1891-seam-nobaseline+issue1320-thinking-mass+issue3769-orphan-sweep-ledger: 29/29); typecheck + build clean; full suite via CI.Auto-merge gate (§7.4): single-module fix, regression test reproduces the original bug, pure fix:, no config/wire/kernel/persistence changes, clean diff.
Closes #4043