Skip to content

[PR] Stop bili's own thinking-mass projection from faking client-side cache-break attribution - #4055

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-10-21_cache-meter-client-attribution
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-10-21_cache-meter-client-attribution

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #4054 (来源 #4042 附带 fixture bundle 中的独立 RED 用例;与 #4042 主缺陷不同机制,已拆分立项)

是什么 / 为什么

noteInboundMessages 对每条入站 core message 取完整 JSON 做 sha256-16 指纹——其中包含 thinkingTokens,而该字段全仓库唯一的生产者是 bili 自己的 #1320 投影(projectThinkingMass 在 relay 捕获前原地改写 prepared.originalMessages)。计量值在两轮请求之间波动 → 中间位置指纹翻转 → detectSeam 的 #3023 client arm 把一次独立的 outbound 断点记成「client-side mid-history rewrite」(prov=client,clientInserts+1)。客户端什么都没改,锅却扣给了宿主。

修法(机制层)

指纹化前剥离顶层 thinkingTokens(该字段永不可能作为 client-origin 证据)。真实的内容变更(签名/文本/工具参数)仍会翻转指纹——#3023 arm 对真 client churn 的检出能力不变(对照用例钉死)。单模块(src/cache-ledger.ts),不触碰 kernel/wire/config/persistence。

行为变更披露(诊断面)

仅入站差异为投影计量值的样本:旧值 prov=client → 新值回落 legacy seam 桶。方向 = 假阳性减少;计费总额(miss/tr 记录)、压缩决策、其他归因臂(ttl/side/rewind/orphan-sweep/foldSeq)全部不变。

验证

  • 回归测试收编 OpenAI wire: folded text that gains an opaque content part can lose that part #4042 bundle 的三个合成用例原样(cache-metering.test.ts:RED case + identical-outbound control + changed-signature control),另加两条捕获侧直钉(指纹对计量波动免疫 / 真实签名变化仍翻转);
  • 无修复时新文件 2 fail / 3 pass,修复后 5/5 绿(stash 对照实测);
  • 定向测试集 87/87 绿(cache-seam-client-insert / cache-seam-detector / issue1891 / issue2131-seam-capped / issue3769 / issue2929 / cache-ledger);typecheck 干净;
  • 全量回归以 pushed head 的 CI test lanes 为准。

… seam attribution (#4054)

noteInboundMessages fingerprinted each inbound core message from its full
JSON — including the projected thinking mass, whose single producer is
bili's own #1320 projection (projectThinkingMass mutates
prepared.originalMessages before the relay capture). A meter delta between
requests therefore flipped the fingerprint at a mid-list index and the
#3023 arm booked an independent outbound break as a client-side
mid-history rewrite (prov=client, clientInserts+1).

Strip the top-level field before fingerprinting; real client-origin
changes (signature/text/tool args) still flip the fingerprint. Regression
tests: the three synthetic cases shipped in the #4042 report bundle (RED
on bc4a3f8) plus two direct capture-side pins.

Behavior change (diagnostic surface only): samples whose ONLY inbound
delta is the projected thinking mass now fall back to the legacy seam
bucket instead of prov=client — fewer false client accusations; billing
totals and compression decisions are untouched.
@ranxianglei ranxianglei changed the title Stop bili's own thinking-mass projection from faking client-side cache-break attribution [PR] Stop bili's own thinking-mass projection from faking client-side cache-break attribution Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-21_cache-meter-client-attribution (4c808a1)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4837-pr.4055.092d724

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr4055.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: vllm-qwen/qwen3.8-27b)

作为 PR #4053 的重复关闭——同症状 + 同机制 + 同根因:

本 PR 的独特增量(capture 侧直接 pin:计量波动 → fps 不变)已并入 #4053 分支,标注 commit 7343c0f2f(union coverage;另一条「签名变化 → fps 翻转」pin 已被 #4053 e2e case 3 的更强性质覆盖)。后续进度看 #4053。

@ranxianglei ranxianglei added the duplicate This issue or pull request already exists label Oct 20, 2026
z0d0dOr pushed a commit to z0d0dOr/billion-context that referenced this pull request Oct 24, 2026
…ojected meter fluctuation (union coverage from dup PRs ranxianglei#4055/ranxianglei#4056)

(cherry picked from commit 7343c0f)
@github-actions github-actions Bot mentioned this pull request Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache report blames the client for a cache break when the only inbound change is bili's own projected thinking-token meter

1 participant