Skip to content

[PR] fix: clear stale membership and reject null billing prices - #5042

Merged
ranxianglei merged 3 commits into
ranxianglei:masterfrom
kuviki:2026-10-28_three-review-findings
Oct 29, 2026
Merged

ranxianglei merged 3 commits into
ranxianglei:masterfrom
kuviki:2026-10-28_three-review-findings

Conversation

@kuviki

@kuviki kuviki commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5040
Fixes #5041

Summary

Follow-up to supplemental review of #4982. Two independent fixes, split into two commits:

  • Clear a stale request-membership verdict when the current request has no evidence IDs. Abstention no longer retains a previous foreign/member verdict; the remembered needle stays intact and subsequent foreign requests remain rejected.
  • Reject billing.prices: null through the existing invalid-configuration path instead of throwing from Object.entries. Startup warns and ignores it; both WebUI save routes return 400 without changing stored configuration or active overrides.

The kernel interval lookup optimization (review item 2) is explicitly deferred. This PR contains no kernel changes and does not contain the separate fork-persistence patch.

Reproduction and validation

Before the fix, the real HTTP sequence main(100000) → foreign(5000) → no-ID main(200000) retained the 100000-token anchor; after the fix it reaches 200000. The regression also covers member→no-ID and verifies later foreign usage still cannot rewrite the anchor. All 10 requests use a real proxy and loopback fake upstream; no model API calls.

Null billing prices reproduced TypeError in parser, config load, and WebUI tests before the fix. Regression coverage checks warning/fallback, stale override removal, and byte-preserving rejection for structured and raw-file saves.

  • Four affected test suites: 29 passed, 0 failed/skipped; independently rerun with the same result.
  • Billing and adjacent side-lane suites: 44 passed, 0 failed/skipped (overlapping coverage, not an additional total).
  • npm run typecheck: passed.
  • npm run build: passed, including dist import/external checks.
  • Test import graph, unused-export gate, git diff --check: passed.
  • Full host-suite verdict remains remote CI on the pushed head, not a local full-suite claim.

Boundaries

The membership fix establishes sequential-request correctness. Concurrent requests still share the existing session-level verdict; request-local concurrent attribution is not redesigned here. No new config fields, schema changes, persistence changes, wire-shape changes, kernel changes, or release/version changes. Human review requested; do not auto-merge.

Remote CI on 87f64d2

CI run completed with one failing job: Windows Node 22 shard 1. Its two failures are in the unchanged issue4982-draining-twin-ladder.test.ts: a graceful-shutdown marker timeout after child.kill("SIGTERM"), and an uncaught socket ECONNRESET. Source inspection and Windows signal semantics point to existing platform-specific test issues; a Windows base-only reproduction has not been run. No unrelated tests were changed. All other executed test shards, static gates and associated workflows passed. Windows Node 24 checks are outside this run’s CORE matrix; their Expected state is not a queued job. This PR is not fully CI-green.

@kuviki kuviki changed the title fix: clear stale membership and reject null billing prices [PR] fix: clear stale membership and reject null billing prices Oct 28, 2026
@kuviki
kuviki marked this pull request as ready for review October 28, 2026 12:56
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

查重:不重复 —— #5042 本身就是 #5040(无 ID 请求沿用旧 membership 判定)与 #5041(billing.prices null 抛异常)的修复 PR,两 issue 均为此 PR 而开,无并行重复工作。

进度汇报:会话曾因一次网络 git fetch 挂起被重启。已确认 PR head 87f64d2b5、base b0b0e66ff(已含 ci-fixes #5017),diff 共 6 文件 +174/-2(src/billing.ts、src/request-membership.ts + 4 个测试文件)。正在逐行审代码与回归面,完整八问结论随后补上。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

查重:不重复(重申首条)—— #5042 就是 #5040 + #5041 的修复 PR,两 issue 专为本 PR 而开,无并行重复工作。
标签:bug / scope/kernel / p2(缺陷修复 PR;主变更在 src 侧压缩决策面 request-membership;影响需特定触发、非全 fleet 停摆记 p2——billing 那条含启动崩溃面,owner 若认为该面够严重可升 p1)。

审核独立性:以下结论是我独立读 diff(base b0b0e66ff → head 87f64d2b5,6 文件 +174/-2)+ 追全部调用链得出,未照抄 issue 表述。

结构化八问

1. 是什么问题 —— 一个 PR 两个独立 commit:

2. 什么原因导致的

3. 影响范围与严重程度

4. 怎么修复的(机制层)

5. 是否有回归问题(逐路径清点既有行为)
读了改动前代码 + 追完调用链:

  • probeRequestMembership 唯一消费方是 src/cache-ledger.ts:1822 的 settle 锚点门。改动唯一新增副作用=无 ID 请求删 t.requestMembership;needle/needlePayloadUpper 不动;fork 继承(plugin.ts:1553 拷 latestKnownMsgId/needlePayloadUpper)不受影响;无 transient 时行为不变(仍 return null、无副作用)。
  • 唯一语义让步:旧代码「foreign(有ID)→无ID请求」靠残留 foreign 判定歪打正着地继续拦;新代码无 ID 请求清判定、放行锚点写入。理论上「一条无 ID 的 foreign payload」能改写锚点——但这与威胁模型矛盾(foreign persona 的 payload 带 tool-call id,会被独立判 member=false 拦住),且损害仅限锚点记账(压缩/缓存校准)、非数据完整性。净效果=用一个罕见理论弱化换一个常见真实 bug,合理且已在 PR 边界声明。
  • billing parser:纯增量——原能解析的输入行为完全不变,仅把原本必炸的 prices:null 从「抛异常」变「返回 undefined」。无既有合法输入被新拒。
  • config load(config.ts:1472):billing.prices:null 从「启动崩溃」变「warn+忽略+清 stale override」。这是行为变更(旧:崩溃→新:告警继续),PR 已披露("Startup warns and ignores it")。
  • WebUI 两条保存路径:均在任何写盘 / setBillingOverrides 之前 return 400,故「不改存储配置、不动 active overrides」成立(已核对 api.ts:241 结构化 / api.ts:348-349 整文件的判空顺序)。

6. 是否破坏缓存
不涉及缓存失效策略/重试/增量游标/去重键。锚点 lastInputTokens 是压缩校准的输入,不是 prefix-cache 的前缀字节;prefix cache 稳定由消息身份/快照渲染那套保证,本 PR 不碰。membership 门只决定「这条 usage 报不报到锚点」,不改出站 wire 字节。

7. 是否改了设计方向
没有。#4805 的 id-membership 门设计不变(仍只拒 clearly-foreign、弃权放行);本 PR 只是把「弃权」真正实现成「不留残留判定」,是让既有设计自洽,非转向。billing 仍是 loud-reject(#155 纪律),没引入新配置形态。

8. 是否引入了新的配置
没有。无新 env / 新 config 字段 / 新默认值。billing schema 一字未动,只是让一个本就非法的值(null)正确落进既有拒绝路径。

测试有效性(④)

四套件断言都核过,是真测试非恒真:

  • issue4805-anchor-pollution.test.ts T3e:参数化覆盖 foreign→无ID 与 member→无ID 两种前置,钉死「无ID清空判定+锚点到 200_000+needle 不动+后续 foreign 仍拦」,直接复现 [Bug] ID-less requests inherit the stale membership check, preventing the usage anchor from updating | [Bug] 无 ID 请求沿用旧 membership 判定,导致 usage 锚点无法更新 #5040,回归抓得住。
  • request-membership-http.test.ts(新 116 行):真 proxy + loopback fake upstream 跑 10 条真实 HTTP,端到端复现同款序列,assert.equal(forwarded,10) 确认真过了 proxy,非 mock 恒真。
  • billing-prices.test.ts:补 parseBillingSettings({prices:null})===undefined,parser 级回归钉死。
  • billing-web.test.ts:config load(warn+清 stale override+文件字节不变)与 WebUI 双路径(400+错误文案+文件字节不变+active override 保留);断言有牙(resolveBillingPrice 回退 source、readFileSync 字节比对)。

diff 整洁度(⑤)

6 文件 +174/-2 全部与目的相关:2 个 src 各改 1-3 行核心逻辑 + 4 个测试。无跑题文件、无生成物/锁文件连带、无大段空白重排。干净。

CI Windows Node 22 shard 1 失败

失败的 issue4982-draining-twin-ladder.test.ts 不在本 PR diff 内(diffstat 已核),且该文件是 base b0b0e66ff 经 #5016/#5017 才进来的——失败来自 base/master 侧既有的 Windows 信号处理问题(SIGTERM 优雅停机 marker 超时 + socket ECONNRESET),不是本 PR 两个 fix(billing/membership,与该进程派生测试无交集)引入的。按 CI 协调政策:属继承性失败,应对照 #4599(CI 总控) 确认 master 同 job 是否也红;若红则 merge 最新 ci-fixes 收敛,不在本 PR 内重复修 master 级失败。其余 shard / 静态门禁 / 关联 workflow 均绿,4 个受影响套件在 CI 已绿(不在那个红文件里)。

合并判定

两处修复都打到根因(非堵症状)、范围收得紧、测试有牙、无意外回归、无新配置。代码层面可合。唯一待办是 CI 那个 Windows 红 job——非本 PR 之过,建议对照 #4599 确认后 merge ci-fixes 重跑转绿,再走人工合并(PR 自身要求 human review、不 auto-merge,符合 §7.4:动了 membership/session 绑定逻辑,本就该人工合)。

@ranxianglei ranxianglei added bug Something isn't working p2 scope/kernel labels Oct 28, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

重启进度汇报(进程卡死 35min 被强杀后重启。卡死原因:早期一次无超时的网络 git fetch 挂起;本轮所有网络调用已加 ≤20s 硬超时,不再长轮询)。

已完成(阶段性成果)

本 PR 审核已完整做完并 posted(见上楼层 10 的八问全文):两处修复(#5040 无 ID 请求清空残留 membership 判定 / #5041 billing.prices:null 落进既有无效配置路径)都打到根因、非堵症状;测试有牙(真 proxy + loopback fake upstream 端到端复现序列);无意外回归、无新配置。代码层面可合;因触碰 session 绑定逻辑,按 §7.4 本就属人工合并面(与 PR 自身声明一致)。

重启后核实的当前状态

  1. PR head 未动:仍为 87f64d2,作者自审核后无新提交。
  2. CI 现状:该 head 上的全部 run 已于 19:28Z 被取消,此后无新 run。最后一次实质判定的唯一红腿 = test (windows-latest, 22, 1),失败在 tests/issue4982-draining-twin-ladder.test.ts(portReleasedAt 等待超时 + teardown 后 socket ECONNRESET)。
  3. 该红不是本 PR 引入:失败文件不在 diff 内;同签名已在该 Windows×node22 分片三次在档复发([PR] fix(served-markers): ignore prior container generations with same PID on restart (#3923) #5028/[PR] fix: derived-parent decompress honors toFile and spills oversized restores (#5013) #5038/[PR] fix: clear stale membership and reject null billing prices #5042),rerun-failed-jobs(19:14Z)也逐字复发——属 master 侧既有的平台性 flake,与本 PR 两个 fix(billing/membership)零交集。
  4. 处置位置在 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599(CI 总控):按协调政策,此类 master 级失败修复收敛到 ci-fixes、由哨兵统一维护——未在本 PR 内重复修,也未开新 issue。现状:ci-fixes tip c24c30341 已是 master b0b0e66ff 祖先,无可 merge 内容;测试硬化方向(portReleasedAt 预算参照 wire-exit-matrix 口径放宽 + 子进程 socket 补 error 处理器消除 ECONNRESET uncaughtException,[PR] fix(#4977): exit twin-collision before persistence init when the port holder is a silent same-build twin #5004 da25207 同型修法)已记录在 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 floor 425/426。哨兵已达 24h 接单上限暂停(CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 floor 429),窗口过期自动恢复或由 owner 决策接管。

需要 owner 拍板的一件事

代码就绪、人工合并即可;唯一挡路的是那个与本 PR 无关的 master 级 Windows flake。二选一:① 不等它,直接合本 PR(flake 归哨兵/ci-fixes 后续收敛);② 等 ci-fixes 把该 spawn 套件硬化后再合。选①的话请自行合并 #5042 ;我不代合。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

CI 自动修复完成(ci-worker-r1,attempt 1/2):已把 master 合入 PR 分支并推送,新 head 2ba301f8f 全量 CI 绿。查重:不重复(floor 7 已答)。

修复方式:此红是继承性失败,不是 PR 代码问题。PR 分支 base(b0b0e66ff)早于 master 上已合入的 tests/issue4982-draining-twin-ladder.test.ts 两个修复(#5050):

  1. Windows 上 Node 的 kill("SIGTERM") 是 TerminateProcess,信号送不达 → graceful shutdown 不执行 → portReleasedAt 永不落戳 → waitUntil 超时;windows-latest CI will always be red: the drain e2e in #4982 uses POSIX-only kill(SIGTERM) to trigger graceful shutdow | windows-latest CI 必红:#4982 的 drain e2e 用 POSIX 专属的 kill(SIGTERM) 触发优雅退出,Node 在 Windows 上是直接硬杀 #5050 把 e2e 改为经 POST /__bili/shutdown 驱动(SIGTERM/SIGBREAK/HTTP 收敛到同一个 shutdown(),跨平台 seam);
  2. 被杀 prober 在探测中途 RST squatter socket,无 error listener 时测试结束后冒 uncaughtException;windows-latest CI will always be red: the drain e2e in #4982 uses POSIX-only kill(SIGTERM) to trigger graceful shutdow | windows-latest CI 必红:#4982 的 drain e2e 用 POSIX 专属的 kill(SIGTERM) 触发优雅退出,Node 在 Windows 上是直接硬杀 #5050 补了 sock.on("error", ...)。
    ci-fixes 哨兵为空(tip c24c30341 已是 master 祖先),故直接把 origin/master 合入 PR head 分支(fast-forward 推送,无 force、无冲突、与 PR 自身 6 个文件零重叠,贡献者 commits/diff/authorship 原样保留)。

八问:

  1. 是什么问题:PR 的 test (windows-latest, 22, 1) 持续红——不是 PR 代码缺陷,是分支 base 落后于 master 对 [PR] release v0.1.209 #4982 e2e 套件的 Windows 定向修复。
  2. 什么原因导致:Windows 上 SIGTERM 不以信号送达(TerminateProcess),旧 e2e「kill -TERM → graceful shutdown」的前提不成立;外加 squatter socket 缺 error handler。两处根因在 master 已由 windows-latest CI will always be red: the drain e2e in #4982 uses POSIX-only kill(SIGTERM) to trigger graceful shutdow | windows-latest CI 必红:#4982 的 drain e2e 用 POSIX 专属的 kill(SIGTERM) 触发优雅退出,Node 在 Windows 上是直接硬杀 #5050 修掉,PR 分支还没带上。
  3. 影响范围与严重程度:仅影响本 PR 的 CI 状态(红);用户面、运行时行为均不受影响。同类的继承红也影响其他基于 pre-windows-latest CI will always be red: the drain e2e in #4982 uses POSIX-only kill(SIGTERM) to trigger graceful shutdow | windows-latest CI 必红:#4982 的 drain e2e 用 POSIX 专属的 kill(SIGTERM) 触发优雅退出,Node 在 Windows 上是直接硬杀 #5050 的分支([PR] fix: derived-parent decompress honors toFile and spills oversized restores (#5013) #5038 等,见 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 floor 414–430)。
  4. 怎么修复的:把 origin/master 合入 PR head 分支(87f64d2b5..2ba301f8f),让分支带上 master 已有修复;未新增任何自己的代码。
  5. 是否有回归问题:逐项审过既有行为:merge 只带入 master 侧变更(release v0.1.209、[PR] fix: initialize fork ledgers atomically before publication #5044 fork-ledger 修复、windows-latest CI will always be red: the drain e2e in #4982 uses POSIX-only kill(SIGTERM) to trigger graceful shutdow | windows-latest CI 必红:#4982 的 drain e2e 用 POSIX 专属的 kill(SIGTERM) 触发优雅退出,Node 在 Windows 上是直接硬杀 #5050 Windows e2e 修复、[PR] ci: 恢复紧急快速发布入口(fast 模式加双信号防误触门) #5054 ci fast-dispatch),与 PR 6 文件零重叠;本地 typecheck clean + billing/membership 相关 28/28 + request-membership-http 1/1(真实 HTTP 10 请求)+ issue4982 套件 6/6(Linux)全绿;CI 全矩阵(11 个 test shard 实跑 5–8 分钟,含此前红的 windows-22 s1,job id 123201774575)+ 4 条 e2e lane 全绿。无回归。
  6. 是否破坏缓存:不涉及——未触碰任何缓存/重试/游标逻辑。
  7. 是否改了设计方向:不涉及——纯分支同步。
  8. 是否引入新配置:不涉及。行为变更披露:本次推送不改变 PR 本身任何运行时行为;唯一差异是分支追平 master,其中 package.json 版本 0.1.208 → 0.1.209 来自 master 自身的 release commit,不是本修复的 bump。

结论:CI 绿,自动修复合拢;PR 继续等待人工 review + owner 合并(代码层面审核结论不变:可合)。

@ranxianglei
ranxianglei merged commit 47f15f8 into ranxianglei:master Oct 29, 2026
47 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.909-master.47f15f8 (rolling master tag).

npm install -g billion-context@0.0.909-master.47f15f8  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment