Skip to content

[PR] fix: refuse session adoption while a live peer instance is writing it (#394) - #5717

Open
ranxianglei wants to merge 10 commits into
masterfrom
2026-11-05_refuse-hot-session-adoption
Open

ranxianglei wants to merge 10 commits into
masterfrom
2026-11-05_refuse-hot-session-adoption

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

(ai: glm-5.2)

Fixes #5716 — Refs #5624

改了什么(一句话)

接管会话之前先问一句「这条会话是不是正被另一个还活着的 bili 实例写着」——是就不接管:匿名请求转而新铸自己的会话,管理面调用得到指名对端的报错。判定证据复用 #3923 已有的写入者标记(writer markers),不新增任何配置项。

为什么

#5624 的机制链:多实例共用 sessions 目录 + 匿名客户端前缀吻合 → 第二个实例把别的实例正在写的 pfa-* 链当自己的接管 → 会话行整体覆盖 upsert(src/storage/store.ts:958)+ lane 会话豁免清扫(#3248)→ 两边消息行堆积 → digest drift → 冻结/解冻循环。#3923 只检测不拒绝,第二个实例照样接管。这个 PR 把同一份证据变成写前拒绝。

四个落点

位置 行为
src/adoption-guard.ts(新) probe 注册点;hotAdoptionRefuser() 给 resolver,hotWritersOf() 给管理面;未接线(inline 引擎无标记)一律视为无竞争,行为与从前完全一致
src/prefix-affinity.ts resolve(input, refuseAdoption?):通过匹配门槛但被拒的候选跳过、其余候选照常竞争、全被拒落新铸;refusedAdoption 仅作诊断
src/server/handle.ts 接线 refuser;拒绝时 warn 日志点名对端实例(id/pid/lane)
src/plugin.ts resolveForkConversation 两处磁盘接管拒绝;代理工具执行对热门会话回 409(本进程已驻留会话的最后一道写入闸)

刻意保留的边界(测试钉死)

Pre-flight

  • npm run typecheck ✅
  • 新增 tests/hot-adoption-guard.test.ts 12/12 ✅(拒绝/不拒绝双向、三档 rung、去重、活性过期、优雅退出、接线与未接线、探针集成)
  • 回归:affinity-neutral / prefix-affinity-simhash / affinity-persist / affinity-crosswire-fold 35/35 ✅;served-markers / issue-split-brain-surface / multi-instance-persist 24/24 ✅;multi-instance-live(受支持拓扑钉子)1/1 ✅;e2e-plugin-tool-routing / plugin-passthrough-tool-xml-warn 8/8 ✅
  • 未动 package.json 版本号;单 commit fix: 前缀

独立审核补充(ai: vllm-qwen/qwen3.8-27b @ 069d956)

对本 PR head 做了独立复审,补上插件面拒绝语义的两个缺口(commits ae89b2e / 069d956):

  1. fork 的 create 分支未设闸:幂等重试 POST 在首次尝试已于对端成功后落到本实例时,replay() 找不到已接管会话(hot 磁盘接管本就被拒),直接落进 create 分支——重建 child + recordPluginSession + flushSync(parent) 覆盖对端行,正是本 guard 要防的 last-writer-wins 损坏。现在 create 分支回 409 HELD_BY_PEER_INSTANCE 指名持有者;闸放在 replay() 之后——replay 只读安全(child 的 committed envelope),仅 parent 被持有时重试照常成功,不饿死。
  2. status 错会话路由:hot 接管被拒后落入 fallback-latest 分支,用另一个会话的状态冒充请求的 id 应答(wrong-session misroute;旧 head 在 tests/plugin-fork.test.ts:1001 红灯,该套件不在原 pre-flight 清单里)。现在直接 409 HELD_BY_PEER_INSTANCE 指名对端。

行为变更清单(旧值 → 新值)

路径 旧行为 新行为
匿名前缀亲和命中活对端正在写的链 接管并写(双写) 跳过、新铸 id(确定性 id 残余重放改不了名,落回 #3923 告警+冻结,日志明说)
管理面磁盘接管(snapshot)命中 hot id 接管并服务 404 PARENT_NOT_FOUND(活性作用域,对端退出后恢复)
status?conversationId=X&fallback=latest 且 X hot fallback 用另一会话状态应答(misroute) 409 HELD_BY_PEER_INSTANCE 指名对端
fork POST 任一侧被活对端持有 可能重建 child + 覆盖 parent 行 409 HELD_BY_PEER_INSTANCE(create 分支);幂等 replay 不受影响(只读)
代理工具执行命中 hot 会话 执行(会写) 409 指名对端
客户端显式命名会话的多实例模型流量交错 允许(受支持拓扑) 不变(兜底仍是 #3923 告警+冻结,multi-instance-live 钉死)

活性作用域细节:对端优雅退出(dispose 盖戳)→ 立即可接管;崩溃 → 标记新鲜窗口(30s)内仍拒(fail-closed),过期后可接管;contest 窗口 10min。未新增任何配置项。

补充后的验证

  • typecheck 0 错误;tests/hot-adoption-guard.test.ts 15/15 + tests/hot-adoption-plugin-gates.test.ts 6/6 ✅
  • tests/plugin-fork.test.ts 56/56 ✅(含跨进程重启两存储模式:测试现模拟优雅的前任退出——marker 文件静默期后盖 stoppedAt/disposedAt 再起 stand-in,[Bug][split-brain] Restart-handover notice persists forever after the peer pid is gone (stale storage.splitBrain) #4626 交接语义;lingering-predecessor 拒绝形态留在 hot-adoption-guard.test.ts 钉)
  • 回归批:prefix-affinity*/affinity-*/served-markers/split-brain/multi-instance-persist/e2e-plugin-tool-routing 98/98 ✅;multi-instance-live + issue2218 7/7 ✅

(@ 7358422: restart-handoff evidence no longer relies on marker-file quiescence plus hand-stamping — the harnesses record the graceful predecessor stop through dispose(), the production graceful-stop primitive (clears the pending flush, writes the final disposedAt marker), via the test-only export _disposeServedWriterForTest; ordered after the final flush mirroring finishShutdown. Zero behavior change.)

(@ d95d1fc: last CI-red closed - the disk-adoption negative control asserted a snapshot 200 from a storage substrate that needs an explicit mode pin: a cold-adopted non-fork session serves its snapshot ONLY through the unified raw-tail reconstruction (#5140) and legacy mode fail-closes with 409 by design, so the subtest now boots "shadow" explicitly. Full matrix green: 30/30 checks at d95d1fc.)

…#394)

Two live bili instances sharing one sessions dir can end up writing the
SAME session: an anonymous client whose history matches a pfa-* chain via
prefix-affinity gets adopted by whichever instance receives the traffic,
even when the original instance is still actively writing that chain.
The sessions-row upsert is last-writer-wins and lane sessions are exempt
from the completeLog sweep (#3248), so alternating writers accumulate
each other's rows and diverge from every envelope — digest drift, drift
latch, frozen envelope (#5624's five-then-refreeze loop on a 9-instance
shared-dir fleet).

served-markers.ts already detects exactly this state (#3923, split-brain
contest alarm). This turns the same writer-marker evidence into refusals
at the inference-driven adoption points, before any write happens:

- prefix-affinity resolve() takes a refuseAdoption callback; a chain that
  PASSES a rung's match gates but is refused is skipped (remaining
  candidates compete; all-refused falls through to the fresh mint) and
  reported in refusedAdoption for the caller's log.
- handle.ts wires the refuser from src/adoption-guard.ts (new) and logs
  the refusal naming the peer instance.
- plugin.ts resolveForkConversation refuses disk adoption of a hot id
  (management calls write via withSessionLock) and the proxy-tool
  execution path answers 409 for a hot session — the last write-vector
  gate for sessions already resident in this process.

Deliberate boundaries, pinned by tests:
- Client-named ids (conversation headers) are NOT refused — interleaved
  turns on a client-chosen session across instances is the owner-ruled
  supported topology (multi-instance-live.test.ts); the contest alarm +
  freeze remain the containment there.
- Liveness-scoped: after the peer exits (dispose-stamped marker, dead
  pid + stale file) its sessions are adoptable again — restart handoff
  (#4626) keeps working.
- Unwired (no probe — inline engine carries no writer markers) reads as
  uncontested: adoption behaves exactly as before.
- Residual, pinned by a test: a byte-identical replay re-mints the same
  deterministic pfa id, so refusal cannot rename that shape; the write
  path still lands on the contested session and the #3923 alarm stays
  the containment for it.

Refs #5624
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-05_refuse-hot-session-adoption (19015a4)

Latest build — install this exact version

npm install -g billion-context@0.0.9010-pr.5717.ed1d38a

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

Recent builds (commit → version)

commit version build
19015a4 billion-context@0.0.9010-pr.5717.ed1d38a build
4929890 billion-context@0.0.8995-pr.5717.7dc2b7d build
d95d1fc billion-context@0.0.8260-pr.5717.5cb5ee7 build
7358422 billion-context@0.0.8255-pr.5717.21f9823 build
069d956 billion-context@0.0.8247-pr.5717.6e6b711 build
d472ed8 billion-context@0.0.8231-pr.5717.38bb532 build
6c59f85 billion-context@0.0.8224-pr.5717.f91feed build
90b22f7 billion-context@0.0.8214-pr.5717.d60ed2d build
5b28055 billion-context@0.0.8211-pr.5717.ebf66cd build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: refuse session adoption while a live peer instance is writing it (#394) [PR] fix: refuse session adoption while a live peer instance is writing it (#394) Nov 5, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。 检索了 open+closed 的 PR/issue(adoption / split-brain / writer-marker 相关):其余在途的 adoption 类 PR(#5126 / #5525 / #3024 / #4345 / #5511 等)全部是 fork adoption(分叉会话继承链)那条机制,与本 PR 的「前缀亲和接管被活实例写入的会话」不同机制、不同失败域;没有第二份把 #3923 写入者标记变成写前拒绝的在途工作。本 PR 是 #5716 的唯一实现(Fixes #5716)。

审核开工中:已取分支 2026-11-05_refuse-hot-session-adoption(单 commit,6 文件 +457/-5)。接下来按规范走:原 issue 方向关 → 回归审查(既有行为清单)→ 代码审查 → 测试有效性 → diff 整洁度,本地只跑定向测试,全量交给 CI。结论按结构化八问回帖。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 自动修复轮次 1/3:unused-exports 红已修,增量推送完成(head 5b280558e → 90b22f7fe)。七问:

  1. 是什么问题:PR 的 unused-exports 检查红——门禁报 1 个 unused export,其余检查未受影响。
  2. 什么原因导致的:本 PR 新增的 src/adoption-guard.ts 把类型 HotWriter(第 26 行)写成了 export type,但全仓只有该文件自身引用它;外部消费方(src/plugin.ts、src/server/handle.ts、tests/hot-adoption-guard.test.ts)导入的都是函数(hotWritersOf/describeHotWriter/hotAdoptionRefuser 等),没人导入这个类型 → 判 INTERNAL_ONLY。
  3. 怎么修复的:按门禁自身建议与仓内先例(#79d0d2181 对 SessionResolveObserver 的同型修法),去掉该行前导 export,类型降为文件内部。一行改动,无 waiver、无其他文件触碰。commit 90b22f7fe 已推到 PR 分支。
  4. 影响范围与严重程度:纯声明面变更,零运行时影响(类型在运行时不存在)。导出的四个函数签名仍引用 HotWriter,tsc 发声明时会自动带上所需内部类型——与已绿的 SessionResolveObserver 完全同模式。对用户、行为、输出格式均无影响。
  5. 是否有回归问题:无。全仓 grep 证实无任何外部导入该类型;本地复跑门禁由红转绿(✗ 1 unused export(s) → ✓ unused-export gate: clean (8 waived),waived 清单与基线一致)。typecheck/test/build 等其余 lane 交给远程 CI 在新 head 上把关。
  6. 是否破坏缓存:不涉及(未触碰缓存/重试/游标/去重键任何路径)。
  7. 收工判定:唯一红项已修复并推送,等待 CI 重跑确认 unused-exports 转绿;若其余 lane 亦绿,PR 可进入合并审查。设计方向与新配置:均不涉及。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

本轮处理:11 个红 test shard = 继承性 master 红,已并入 ci-fixes,等 CI 重跑。

  1. 哪些检查红:head 90b22f7 上全部 11 个 test shard(ubuntu 22×3、ubuntu 24×3、windows 22×5)。上一轮修掉的 unused-exports 本轮已绿。
  2. 什么原因:不是本 PR 的代码。DSH: If the first request of a session originates from a bypass call, compression for the entire session is permanently | DSH: If the first request of a session originates from a bypass call, compress for the entire session is permanently inv | DSH:会话首个… #5656/[Bug][Codex Launcher] Marketplace Git repositories escape CODEX_HOME through Bili .tmp symlinks #5584(经 [PR] fix: unknown dsh one-shot sidecars steal the raw-key anchor and kill compression (context-explosion root cause) #5687 合入,commit 01fcc5d)把「无 tools + 非空 system + 单条 user」的 dsh 请求转入 verbatim side lane,会话普通 turn 1 恰好命中该形状(该 commit 文档化的残留);按「turn 1 走全管道」写成的 6 个旧回归钉在合入瞬间变红,master 自此红,每个 PR head 都继承。
  3. 与本 PR 是否相关:无关。抽查 3 个 shard 日志(ub22-1 # fail 3、ub24-1 # fail 3、win22-1 # fail 2,其余 3400+ 项全过),失败全部落在 issue2419/2446/2447/2481 的 guard-stamp 子测试(BLOCKED ref 断言)+ issue2817 计数——与 ci-fixes 哨兵修复的 6 文件钉集合完全一致;本 PR 只动 adoption-guard 等 5 个 src 文件 + 自己的测试文件,不碰其中任何一个。
  4. 怎么修的:按 CI 总控规程(CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 最新楼层明确指令)执行 git merge origin/ci-fixes(哨兵收敛点 0470bec,test-only 钉对齐,无 src/kernel/配置/版本变更)→ 推送,新 head 6c59f85。零冲突(哨兵仅改 6 个测试文件,与本 PR 改动零重叠)。
  5. 回归风险:本次操作未引入任何风险——合并带入的是已在 [PR] test(ci): converge master red — realign five dsh pins to the #5656 single-shot sidecar residual (#4599) #5718(ci-fixes→master)全绿证明过的 test-only 变更(12 个 test shard + static-gates 等 30 项 check 全 success);本 PR 自身 diff 一行未动。
  6. 行为/语义:无运行时变更。钉对齐只是把 DSH: If the first request of a session originates from a bypass call, compression for the entire session is permanently | DSH: If the first request of a session originates from a bypass call, compress for the entire session is permanently inv | DSH:会话首个… #5656 文档化的残留行为钉成契约(guard-stamp 断言移到首个全管道轮次、issue2817 计数 −1、issue5403 rb[0] 按设计不盖戳)。
  7. 判定/后续:已推送,CI 正在新 head 上重跑,预期全绿。两个 master 级事项不属于本车道、不动:owner 合并 [PR] test(ci): converge master red — realign five dsh pins to the #5656 single-shot sidecar residual (#4599) #5718 让 master 转绿;sidecar gate 决策项(保留 turn-1 残留 vs 收窄谓词,[no-dispatch] 决策请求)待 owner 拍板。

Review follow-up on the fix for #5716: tests/hot-adoption-guard.test.ts
pins the resolver-side refusal, but the two plugin-plane gates shipped
alongside it had no direct coverage. Adds
tests/hot-adoption-plugin-gates.test.ts:

- proxy tool execution (read AND write tools) on a memory-resident
  session a live peer is writing answers 409 naming the peer; an
  uncontested session executes normally,
- disk adoption in resolveForkConversation refuses a contested id with
  an honest 404 PARENT_NOT_FOUND while an uncontested disk id is adopted,
- the deliberate asymmetry pinned: a memory-resident session stays
  snapshot-servable even while hot, because its writes are gated at the
  tool plane.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) 🔶 需要决策

结论:上轮并入 ci-fixes 后 11 个 test shard 里 8 个转绿;剩余 3 红(ub22-3 / ub24-3 / win22-4)是本 PR 自身引入的回归——新的「热会话拒绝采纳」机制与钉死「重启交接必须可用」的既有回归钉冲突。修法触及 PR 核心机制语义,超出本车道「小机械修复」权限,未推送任何改动,已打 needs-decision 标签,停手等拍板。

决策项(选项 + 推荐 + 默认)

  • A(推荐):作者收窄 guard 作用面——写路径保留拒绝(proxy tool 执行 409,即 split-brain 真正的双写向量),只读管理调用(snapshot/status)不再做整段磁盘采纳拒绝;并把 servedWriter.dispose() 挂到 http server close 事件(in-process/测试前序实例获得 graceful-stop 戳,补全模块文档声明的 "liveness-scoped handoff safe";生产 shutdown 本就经 finishShutdown dispose,生产 delta≈0)。反 split-brain 目标与既有可用性钉全保住。
  • B:test-only 对齐(cifixes 同款手法)——两个测试文件按文档化契约模拟优雅退出(前序 marker 盖 stoppedAt / spawn 子进程前完整关闭自己的 proxy)。diff 最小、零 src 改动;代价 = 把「peer 非优雅退出期间拒绝采纳(崩溃窗口约 30s,共享 pid/嵌入拓扑下更久)」钉成新契约,属 owner 2026-10-19 修订的 p1「会话不可用」类行为收窄,需 owner 明示认可。
  • C:回退管理面分支(resolveForkConversation + prefix-affinity 拒绝),只发写侧门(handlePluginTool 409)+ 观测面,无单实例守卫:多个 bili 代理进程并存共写 sessions 目录,伴随孤儿 ref、有注册表无 transcript、计数自相矛盾的污染簇 #394/Storage digest-drift escalation recurs on v0.1.211 with prefix-affinity forks; upgrade to v0.1.212 drops drift to zero #5624 的广域拒绝留后续单独立项。最保守,但保护面明显缩水。
  • 默认(不拍板时):按 A 执行(可用性 > 机制完备性)。

本轮七问

  1. 哪些检查红:head 6c59f85 上 3 个 test shard——ubuntu 22 shard3、ubuntu 24 shard3、windows 22 shard4;其余 8 shard + static-gates ×2 + mysql-contract 全绿(证明上轮 ci-fixes 合并有效,继承红已清)。
  2. 什么原因:失败集确定性复现(跨 2 OS 同签名):tests/issue5140-cold-raw-tail-fork.test.ts 3 个子测试——冷重启后 GET /__bili/plugin/snapshot?conversationId=parent 返回 PARENT_NOT_FOUND(404,期望 200/409);tests/plugin-fork.test.ts:1001 2 个子测试——重启进程对 status?conversationId=parent&fallback=latest 返回 sessionId='child'(期望 'parent')。机制:src/plugin.ts resolveForkConversation 新增 hotWritersOf() 拒绝——磁盘上存在该会话、但其 writer marker 判定「另一 live 实例近期提交过」即整体拒采(src/served-markers.ts:246:pid 存活或文件 mtime ≤30s 即算 live)。两个测试的前序实例要么与测试进程共享 pid(in-process 双实例,pid 恒活)、要么刻意保活 proxy 只关 store(plugin-fork 注释自述)→ guard 视其为 live peer → 拒绝 → 404/fallback 错路。旁证自洽:plugin-fork 中 child 会话采纳成功而 parent 失败——child 的 servedAt 尚未被 5s debounce flush 落盘,parent 已落盘,同一根因。win22-4 少挂一项系 shard 文件切分差异,签名相同。
  3. 与本 PR 是否相关:是,本 PR 引入。master+ci-fixes(即 [PR] test(ci): converge master red — realign five dsh pins to the #5656 single-shot sidecar residual (#4599) #5718 head)30 项 check 全绿含这些测试(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 949 记录);本 head 与之的差异仅本 PR 的 src 改动。非 flake(3 shard×2 OS 确定性同签名)、非继承红。
  4. 怎么修的:本轮未修——三个候选修法都改变 PR 核心机制的行为边界(读/写分治 vs 契约收窄 vs 范围回退),不是机械小修;按车道规则升级为决策请求(见上)。
  5. 是否有回归问题:PR 当前形态即回归:冷重启后 snapshot/fork/status/fork-replay 在「前序实例未盖优雅退出戳且 pid 可读活」时 404 或 fallback 错路由——覆盖 [Bug][fork] Cold restore cannot use an intact unified raw tail for a non-retained parent (#4266 item 4) #5140/[Bug][split-brain] Restart-handover notice persists forever after the peer pid is gone (stale storage.splitBrain) #4626 钉死的重启交接面;真实单机 SIGTERM 重启不受影响(finishShutdown 会盖戳),kill -9/崩溃后有 ~30s 拒绝窗口,嵌入/共享 pid 拓扑下窗口不收敛。
  6. 是否破坏缓存:不涉及(prefix cache/重试/游标均未触碰;影响的是管理面会话解析)。
  7. 判定/后续:needs-decision 标签已打,分支停在 6c59f85 不动,等 owner/作者在 A/B/C 中拍板;拍板后由本车道执行对应修法并重跑 CI。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #5717 审核结论(独立审核,非复读 issue 结论)

方向关 ✅:修的是根因——匿名会话身份推断(prefix affinity)缺「对端是否还活着」这一维度。#3923 早已算出「谁在写哪条会话」的证据(writer markers),本 PR 把同一份证据从「事后告警」提升为「写前拒绝」,没有另造检测机制,没有新增配置面。机制选择正确:拒绝点放在三个真实写入向量上(affinity 接管、磁盘 fork 接管、工具执行),而不是在存储层做全局锁(那会误伤受支持的 client-named 多实例拓扑)。

回归审查 ✅(逐项过既有行为):

结构化八问

  1. 是什么问题:多实例共享 sessions 目录时,匿名客户端被负载均衡漂到另一个还活着的实例,该实例把对端正在写的 pfa-* 会话当自己的接管,双进程写同一会话行 → digest drift → 冻结/解冻循环(Storage digest-drift escalation recurs on v0.1.211 with prefix-affinity forks; upgrade to v0.1.212 drops drift to zero #5624 事故形态)。
  2. 什么原因导致的:prefix affinity 的身份推断只看历史前缀吻合度,没有活性维度;The same sessionId is served by two bili processes simultaneously: interleaved logs from global + pi-native dual instanc | 同一 sessionId 被两个 bili 进程同时服务:全局 + pi-native 双实例日志交织、重复 cold-load(split-brain) #3923 的写入者标记只用于告警,没进写前判定。
  3. 影响范围与严重程度:触发需三者齐备(多实例共目录 + 匿名客户端 + 路由漂移);触发即静默数据损坏 + 可用性劣化,难诊断。严重度高,但触发面窄。
  4. 怎么修复的:writer-marker 证据做成写前三闸——affinity 候选被拒则跳过(其余候选照常竞争,全拒则新铸 id,匿名客户端换自己的会话);插件平面磁盘接管被拒返回诚实错误;热门会话的工具执行回 409。活性作用域:对端优雅退出或崩溃(pid 死+标记过期)后立即恢复可接管;崩溃后 30s 内 fail-closed 仍拒。
  5. 是否有回归问题:无(见上回归清单)。
  6. 是否破坏缓存:不破坏。拒绝后新铸 id 等价于一次标准的无继承 fork(全量重发一轮),不是缓存失效。
  7. 是否改了设计方向:不改。同一证据从诊断面移到写前面;无新配置、无新存储格式、wire 形状不变。
  8. 是否引入新配置:无。

行为变更披露(强制项):旧行为——匿名请求命中活对端正在写的会话时静默接管并写入(损坏+drift+冻结循环);新行为——同条件下 warn 日志点名对端(id/pid/lane),匿名请求改铸新会话(无折叠继承,重发一轮),管理面得到显式 404/409。原因:把静默损坏变成响亮的可恢复分裂,代价(一轮重发)远小于损坏代价。client-named 会话、单实例、未接线引擎三类边界行为不变。确定性 id 残余(字节级重放重铸同一 id)已如实钉测试,落回 #3923 告警+冻结兜底。

测试有效性(④):PR 自带 12 例双向断言齐全、真 resolver+真 marker 文件(utimes 回溯)、去重断言锐利。发现一处覆盖缺口并当场补上:两个插件平面闸门(磁盘接管拒绝、工具执行 409)此前零直接测试——我补了 tests/hot-adoption-plugin-gates.test.ts(6 例:409 双向+写向量、磁盘接管 404 vs 采纳成功边界、驻留会话不对称钉死),按「一个线程一个修复 PR」规则以独立标注 commit 推到同一分支:d472ed870(纯测试,+166 行,本地 6/6 + typecheck 绿)。作者后续三笔(ci-fixes 合入、五个 dsh 钉子对齐 #4599 协调、HotWriter 导出移除)已核对:均为 CI 协调/lint 修正,无害;我的补充测试已适配类型取消导出的改动(结构化类型,commit 保持纯测试)。

CI:推送头 d472ed870 上待跑,镜像缓存尚未生成。

判定:可合并(CI 绿后)。方向正确、机制扎实、边界钉死、审计未发现回归,唯一覆盖缺口已补齐。

ci-check added 4 commits November 5, 2026 19:18
…while a peer holds the session (#394)

Independent review of this PR's head found two gaps in the plugin-plane refusal semantics:

- handlePluginFork: an idempotent-retry POST landing here after the first
  attempt succeeded on a live peer fell through replay() (which finds no
  adopted session now that hot disk adoption is refused) into the create
  branch — re-creating the child and running recordPluginSession +
  flushSync(parent) over the peer's rows: the exact last-writer-wins
  damage the guard exists to stop. The create branch now refuses with
  409 HELD_BY_PEER_INSTANCE naming the holder, checked AFTER replay():
  replay is read-only-safe (the child's committed envelope), so retries
  keep succeeding while only the parent is hot.

- handlePluginStatus: a refused hot adoption fell through to the
  fallback-latest branch and answered with a DIFFERENT session's state
  under the requested id (wrong-session misroute; red at
  tests/plugin-fork.test.ts:1001 on this PR's previous head). It now
  answers 409 HELD_BY_PEER_INSTANCE naming the holder. Liveness-scoped
  like every other refusal: graceful dispose or a crashed peer past the
  stale grace restores normal resolution.
…tes graceful predecessor exit

tests/hot-adoption-guard.test.ts:
- status GET while the peer holds the id answers 409 HELD_BY_PEER_INSTANCE
  naming the peer (not a fallback pick), and resolves this session again
  once the evidence is gone;
- an idempotent replay of a completed fork succeeds while only the parent
  is peer-held (pins the gate placement: create-branch only).

tests/plugin-fork.test.ts (cross-process restart, both storage modes):
the predecessor process's writer marker still lists parent+child as
actively served while it lives, so the stand-in's guard would refuse both
ids as peer-held. The test now simulates the graceful SIGTERM handover
(#4626): wait for the marker file to quiesce (a throttled flush <=5s can
still land), stamp stoppedAt/disposedAt, then boot the stand-in. The
lingering-predecessor refusals stay pinned in
tests/hot-adoption-guard.test.ts instead.
…ose test seam (#394)

The restart-handoff suites spawn a successor proxy while the predecessor process is still alive. Every session commit stamps the predecessor's writer marker, so without a graceful-stop record the #394 guard refuses the handoff as held by a live peer — red on CI at d472ed8: issue5140-cold-raw-tail-fork x3 plus plugin-fork cross-process x2.

dispose() is the production graceful-stop primitive (clears the pending marker flush and writes the final stoppedAt/disposedAt marker), so the harnesses now call it through a new test-only export _disposeServedWriterForTest instead of sleeping for marker-file quiescence and hand-stamping files. Ordered after the final flush, mirroring finishShutdown. Test-only surface: zero behavior change on the production path.
…ate its 200 assertion requires (#394)

A cold-adopted non-fork session serves its snapshot ONLY through the
unified raw-tail reconstruction (#5140); legacy mode fail-closes with
409 SNAPSHOT_UNAVAILABLE by design (pinned in
tests/issue5140-cold-raw-tail-fork.test.ts). The guard harness never set
BILI_STORAGE_UNIFIED, so "uncontested disk adoption must still work"
asserted a 200 from a substrate that cannot exist — red on every leg
running the file since d472ed8.

bootGuardHarness now takes the same explicit storage-mode parameter as
the #5140 harness (env set before store construction, restored after
close, same ordering). The disk-adoption subtest boots "shadow"; the
resident-session subtests keep the legacy default unchanged.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 全绿:head d95d1fc,30/30 checks 通过(镜像缓存确认 sha=d95d1fc63edf…)。 本 lane 共两个 commit:

  • 7358422(上一轮已推):修 restart-handoff 家族红(issue5140-cold-raw-tail-fork ×3、plugin-fork 跨进程 ×2)。根因:测试内进程前驱退出时没有记录 graceful-stop,writer marker 在共享 test-runner pid 下读作「活着的对端」,无单实例守卫:多个 bili 代理进程并存共写 sessions 目录,伴随孤儿 ref、有注册表无 transcript、计数自相矛盾的污染簇 #394 guard 拒绝一切磁盘接管。修法:新增 test-only 导出 _disposeServedWriterForTest()(src/server.ts,调用生产 graceful-stop 原语 dispose()),harness close 路径在最终 flush 后调用——零生产行为变更。
  • d95d1fc(本轮):修最后一个红项 tests/hot-adoption-guard.test.ts 的「disk adoption … uncontested adopts」子测试(三个跑到该文件的 leg 全部确定性红:期望 200 实际 409 SNAPSHOT_UNAVAILABLE [reconstruction: replicasUnavailable sidecar-missing])。

本轮诊断:失败断言在任何 peer marker 写入之前就挂了,与 guard 无关。机制链:非 fork 插件会话的 pluginSnapshot 不落盘(persist.ts 保留门只持久化 fork 会话),冷接管后服务快照的唯一来源是统一存储的 raw-tail 重建(#5140);legacy 模式该来源结构性缺失,按设计 fail-closed 409(issue5140 的 legacy 子测试钉死了这个契约)。而 guard harness 从未设置 BILI_STORAGE_UNIFIED——断言在向一个不可能存在的底座要 200。这是测试自身不 hermetic,不是产品回归。

修法(仅测试,+9/-3):bootGuardHarness 加显式 storage-mode 参数(env 在 store 构造前设置、close 后还原,与 #5140 harness 同一形状与顺序);disk-adoption 子测试以 "shadow" 启动提供重建底座,其余三个 resident-session 子测试保持 legacy 默认逐字不变。本地定向验证 15/15 通过,CI 全量 30/30 绿。

八问:

  1. 是什么问题:PR 自带的新测试在 CI 上确定性红——guard 的 disk-adoption 子测试断言「无争用会话可从磁盘接管并服务快照(200)」,但 harness 环境没有提供该场景下服务快照的唯一来源。
  2. 什么原因导致的:harness 跑在 legacy 存储模式;冷接管的非 fork 会话无持久化 pluginSnapshot,重建依赖统一 index.db(legacy 下结构性缺席)→ 409 fail-closed。断言预设了统一存储在场,harness 没开——测试不 hermetic。
  3. 影响范围与严重程度:仅本 PR 自己的测试面(CI 三个 leg);对生产用户零影响;产品契约(legacy 冷快照 fail-closed)未动且仍被 issue5140 legacy 子测试钉住。
  4. 怎么修复的:给 harness 显式 storage-mode 参数,仅 disk-adoption 子测试切 shadow 提供重建底座;不改任何生产代码、不改任何断言语义。
  5. 是否有回归问题:无。生产代码零改动;其余子测试环境字节级不变;fail-closed 契约不变;CI 全量 30/30 绿。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入新配置:不涉及(仅在测试进程内读写既有 BILI_STORAGE_UNIFIED,退出即还原)。

判定:auto-fix lane 收工,PR 侧无剩余 CI blocker(mergeable_state=blocked 来自人工评审门禁,非 check 失败);待 owner 评审合并。

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

说明:本 PR 作者与审核凭据同属 ranxianglei 账号,GitHub 禁止对本人 PR 提交正式 APPROVE 事件,故以 review-comment 形式承载结论——判定为可合(APPROVE)。

独立审核结论:APPROVE(可合)

对本 PR head d95d1fc63 做了独立复审(未照抄 issue 侧结论)。CI 全绿(读镜像缓存:30 checks = 14 success + 16 skipped,无失败;mergeable_state=blocked 仅因待审核)。不触碰 kernel/、无 kernel-change 声明、不动 version、不新增任何配置项——满足可批准边界。

结构化八问

  1. 是什么问题:多实例共用一个 sessions 目录时,第二个 bili 实例会把另一个还活着的实例正在写的同一条会话当自己的接管(匿名前缀亲和 / 插件管理面磁盘接管),sessions 行 upsert 是 last-writer-wins,两边交错写 → digest drift → 冻结循环。#3923 只检测告警不拒绝,本 PR 把同一份证据变成写前拒绝。
  2. 什么原因导致的:根因是「接管判定只看内容匹配、不问对端活性」——prefix-affinity 的三条 rung(prefix/append/simhash)与 resolveForkConversation 的磁盘接管都无条件采纳匹配到的链/行。#3923 的 writer markers 本就能证明对端活性,但只接给了告警。
  3. 影响范围与严重程度:仅在「活对端 + 同一会话 + 10min contest 窗口内」触发;单实例、不同会话的多实例、客户端显式命名会话的模型流量交错(受支持拓扑)全部不受影响。窗口内阻断的是 p1 级双写覆盖损坏;窗口外零影响。
  4. 怎么修复的:复用 served-markers.findContestedWriters(活性作用域:pid 活或标记 30s 新鲜才算活;stoppedAt/disposedAt 优雅退出直接排除;自身 instanceId 排除)做成一个可选 probe(src/adoption-guard.ts)。resolver 侧对每条通过匹配门槛的候选过一遍 refuser——被拒跳过、其余照常竞争、全拒落新铸;管理面在磁盘接管 / fork create / status / 工具执行四处加写前闸,命中回 404/409 并指名对端。未接线(inline 引擎无标记)一律读作无竞争,行为与从前逐字节一致。
  5. 是否有回归问题:逐项清点既有行为——
    • 匿名前缀采纳:非竞争链照旧采纳(钉「uncontested adopts exactly as before」+「refuser declines changes nothing」双向)。保持
    • 磁盘接管:非竞争照旧 200 采纳(钉死)。保持
    • fork:非竞争照旧 201;幂等 replay 走只读路径不受影响(钉了 parent-held 时 replay 仍 200)。保持
    • status fallback-latest:从「拿另一会话状态冒充请求 id」(错误路由)改为 409 指名对端——修 bug,非语义漂移。有意变更(已披露)
    • 工具执行:非竞争照旧执行(钉死双向)。保持
    • 客户端命名会话模型流量:不变(multi-instance-live 钉死,兜底仍是 #3923 告警+冻结)。保持
    • 高危模式核查:无 fail-fast 变吞错(反而更 fail-closed);无新增阈值(CONTEST_WINDOW_MS=10min / PEER_FILE_FRESH_MS=30s 均复用自 served-markers,非本 PR 引入);无既有响应形状变更(409 HELD_BY_PEER_INSTANCE 是新增分支);pf 水位快路径 / 增量车道不经过本 guard。无意回归:无。
    • 诚实残余(已钉测试):纯字节级重放重铸出同一个确定性 pfa id,拒绝改不了名;该形态落回 #3923 告警+冻结,PR 日志明说。
  6. 是否破坏缓存:拒绝采纳会新铸会话(隔离对端状态),该会话在对端的前缀缓存不再共享——这是刻意的 split-brain 隔离而非缓存失效 bug;单实例/正常路由场景缓存路径逐字节不变。pf-* 握手头、增量信封均不经过本 guard。
  7. 是否改了设计方向:否。不引入新机制,把 #3923 已有的「检测」升级为「写前拒绝」,复用同一份 writer-marker 证据;设计哲学(检测→拒绝、活性作用域、未接线降级)与既有 #3923/#4626 一致。
  8. 是否引入了新的配置:否。diff 无任何 config/env 字段新增;退出开关即 server.ts 一处 setHotAdoptionProbe 接线(未接线自动降级)。

代码审查要点

  • instanceId = randomUUID()(src/server.ts:534)每进程唯一 → 自身排除安全,两个实例不会互相误判为 self。
  • resolve() 四个返回路径(prefix/append/simhash/new-mint)全部携带 refusedAdoption spread,诊断不漏路径;refuser 在三条 rung 均在匹配门槛之后咨询(不碰无关候选),simhash 里被拒候选在 passing++ 之前 continue(不计入歧义计数)——正确。
  • 工具闸放在 if (!session) 404-return 之后(src/plugin.ts:2238),session.id 不会抛空。
  • 内存驻留会话的刻意不对称(snapshot 可读 / tool 拒写)有测试钉死(tests/hot-adoption-plugin-gates.test.ts)。

测试有效性

真测试、断言有牙:具体 status/code/error 文案(指名 peer)、每个闸双向(该拒拒/不该拒不拒)、活性三档(活对端 / 优雅退出 / 崩溃 30s 窗口)、去重、replay 放置位、fallback 误路由修复。#3617 双向 gate 纪律满足;CI 已跑绿。

diff 整洁度

核心改动收敛在 5 个源文件 + 2 个新测试文件;dsh 测试对齐(issue2419/2446/2447/2481/2817/5403)来自 ci-fixes 合并(commit 0470bec626a + merge 6c59f85a1ed,#4599 协调政策下的继承性修复),非本 PR 范围蔓延。无空白/生成物噪声。

非阻塞观察(不拦、不改)

  • 工具执行 409 的 client-facing error 只指名第一个 writer(hot[0]!),而 fork/status 两处指名全部去重后的 peer——多对端同时写同一会话的罕见情形下 client 只看到第一个(日志里是全量)。纯一致性偏好,实际影响近零。
  • handle.ts 拒绝时打两条 warn(一条带上下文的详细行 + 一条 terse 汇总行)——粒度选择,可接受。

合并判定:可合(APPROVE)。 无阻塞项,无内核门禁,行为变更已全部披露。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #5717 审核完成:APPROVE(可合)

独立端到端复审 head d95d1fc63(未照抄 issue 侧结论):读 PR 正文 + 关联 issue(#5716/#5624/#3923/#4626/#394)+ 全量 diff,再回到源码核验承重上下文。

  • 正确性:复用 served-markers.findContestedWriters 的活性作用域(pid 活或标记 30s 新鲜;stoppedAt/disposedAt 优雅退出排除;自身 instanceId 排除)做成可选 probe;resolver 三条 rung 都在匹配门槛之后咨询 refuser、四个返回路径都带诊断;工具闸在 !session 404-return 之后不会抛空;instanceId=randomUUID()(src/server.ts:534)保证两实例不误判为 self。
  • 回归:非竞争采纳/fork/tool/status 全部照旧(双向钉死);客户端命名会话模型流量不变(multi-instance-live 钉死,兜底仍是 The same sessionId is served by two bili processes simultaneously: interleaved logs from global + pi-native dual instanc | 同一 sessionId 被两个 bili 进程同时服务:全局 + pi-native 双实例日志交织、重复 cold-load(split-brain) #3923 告警+冻结);无新增阈值、无 wire 形状变更、无新配置。行为变更五条路径均已在 PR 正文披露旧值→新值。
  • 测试有效性:断言有牙(status/code/error 文案指名 peer)、每闸双向、活性三档、replay 放置位、fallback 误路由修复钉。CI 全绿(读镜像缓存:30 checks = 14 success + 16 skipped,无失败)。
  • 门禁:不触碰 kernel/、无 kernel-change 声明 → 无需决策流程。
  • 小问题:两处非阻塞观察(tool 409 只指名首个 writer vs fork/status 指名全部;拒绝时双 warn 行),纯一致性偏好、实际影响近零,不拦不改。

处置:verdict 已作为 review-comment 挂到 PR(作者与审核凭据同属 ranxianglei,GitHub 禁止对本人 PR 提交正式 APPROVE 事件,故以 comment 承载结论并注明)→ #5717 (review)

合并判定:可合。 无阻塞项。

…ts import conflict (union: processStartMs + adoption-guard)

Only textual conflict: the served-markers/adoption-guard import block. Master added processStartMs to the served-markers import (#3923 same-PID generation skip); this branch adds the adoption-guard import (#394 hot-adoption guard). Union keeps both. No other conflicts; verified overlap regions semantically: forkSnapshot (#4266 signed-thinking relaxation) and handlePluginFork (#5608 timestamp carry) sit outside the guard's refusal branches; prefix-affinity.ts changes are disjoint (resolve() refusal param vs chain-file validation strictening).
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Conflict resolved and merged — pushed as 4929890132; full test matrix still running, zero failures so far.

What happened this run:

  1. Live verification first: PR head was d95d1fc63 (CI green 30/30 from the earlier fix run); master had advanced 711 commits past the merge-base (0470bec62) → merge state dirty.
  2. Integrated by merge (not rebase — the branch already carries a ci-fixes merge commit, and a plain merge avoids rewriting history under concurrent-agent push discipline): git merge origin/master (master @ 58a8796224).
  3. Exactly one textual conflict — the import block in src/server.ts: master added processStartMs to the served-markers import (The same sessionId is served by two bili processes simultaneously: interleaved logs from global + pi-native dual instanc | 同一 sessionId 被两个 bili 进程同时服务:全局 + pi-native 双实例日志交织、重复 cold-load(split-brain) #3923 same-PID container-generation skip) while this branch adds the adoption-guard import (无单实例守卫:多个 bili 代理进程并存共写 sessions 目录,伴随孤儿 ref、有注册表无 transcript、计数自相矛盾的污染簇 #394). Resolved as the union (both lines kept). The other four both-sides-touched files (src/plugin.ts, src/prefix-affinity.ts, src/server/handle.ts, tests/plugin-fork.test.ts) auto-merged textually.
  4. Semantic overlap audit (auto-merge is textual only):
  5. Local verification on the merged tree: npm run typecheck clean; targeted suites — hot-adoption-guard, hot-adoption-plugin-gates, issue5140-cold-raw-tail-fork, plugin-fork → 81/81 pass; prefix-affinity + prefix-affinity-simhash → 44/44 pass. (Full-suite verdict belongs to CI, per repo testing discipline.)
  6. Push: d95d1fc63..4929890132 on 2026-11-05_refuse-hot-session-adoption (verified remote head unchanged immediately before pushing; no force-push needed).

CI status at posting time (mirror cache, live): all fast lanes already green or gated-skipped on 4929890132 — static-gates ×2, mysql-contract, lock-sync = success; e2e lanes skipped by their gates. The 11 sharded test jobs (ubuntu 22/24 + windows 22 matrix) are in_progress, 0 failures so far. These shards are the long pole (~15 min typically; currently queued longer than usual). I will post a final line here when they finish — if any shard goes red I will fix it on the same branch.

八问:

  1. 是什么问题:PR 分支与 master 冲突(master 前进了 711 个提交),merge 状态 dirty,无法合并。
  2. 什么原因导致的:分支基于较旧的 ci-fixes 基点切出,期间 master 合入了大量 PR;唯一文本冲突是 src/server.ts 的 import 块——master 侧(The same sessionId is served by two bili processes simultaneously: interleaved logs from global + pi-native dual instanc | 同一 sessionId 被两个 bili 进程同时服务:全局 + pi-native 双实例日志交织、重复 cold-load(split-brain) #3923)加了 processStartMs,本分支侧(无单实例守卫:多个 bili 代理进程并存共写 sessions 目录,伴随孤儿 ref、有注册表无 transcript、计数自相矛盾的污染簇 #394)加了 adoption-guard import。
  3. 影响范围与严重程度:仅合并阻塞本身;不解决则 PR 永远无法 merge。代码语义面无影响(见第 5 问)。
  4. 怎么修复的:用 merge(非 rebase,避免重写历史、兼容并发推送纪律)把 master 合入分支;import 冲突取并集保留双方;对其余自动合并文件做了逐 hunk 语义重叠审计。
  5. 是否有回归问题:本地 typecheck 干净 + PR 四个测试文件 81/81 + prefix-affinity 44/44 通过。唯一的跨侧交互是 The same sessionId is served by two bili processes simultaneously: interleaved logs from global + pi-native dual instanc | 同一 sessionId 被两个 bili 进程同时服务:全局 + pi-native 双实例日志交织、重复 cold-load(split-brain) #3923 的 same-PID 代际跳过进入了 adoption-guard 的探测路径——方向互补(容器重启后陈旧同 PID marker 不再误拒接管),由 PR 自带 guard 测试钉住并本地通过。生产行为变更来自 master 已合入的 The same sessionId is served by two bili processes simultaneously: interleaved logs from global + pi-native dual instanc | 同一 sessionId 被两个 bili 进程同时服务:全局 + pi-native 双实例日志交织、重复 cold-load(split-brain) #3923/Zero-Inheritance Session Cloning: Unified Fix for Eight Independent Defects in the Fork Adoption Chain (Next Release Tar | 会话克隆零继承:fork 收养链上八类独立缺陷统一修复(下版目标) #4266/# Cache hit collapses to 1–12% for a whole generation, then the very next request returns to 100% — repeated 15× in one day #5608 自身,非本次合并引入。
  6. 是否破坏缓存:不涉及(未触碰缓存/重试/游标逻辑)。
  7. 是否改了设计方向:不涉及。
  8. 是否引入新配置:不涉及。

判定:冲突已解除、分支可合并;待 11 个 test shard 跑完确认全绿后补一行终态结论。

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Re-review of updated head 19015a4 (previous reviewed head d95d1fc6). The branch was rebased onto current master (58a87962) via one merge commit that resolved an src/server.ts import conflict; I independently re-verified the final delta rather than trusting the rebase.
(Posted as a review-comment because the PR author and the reviewer credential are the same ranxianglei account — GitHub rejects a formal APPROVE event on one's own PR. The verdict below is an approval.)

Verdict: APPROVE(可合)

What changed since my last review: only the rebase + a mechanical import-union merge. The PR's real contribution vs its base is unchanged (9 files / 915+/7-). I re-read the entire final source delta against base 58a87962 and confirmed the hot-adoption logic is byte-consistent with what I approved before:

  • adoption-guard.ts (new probe module), prefix-affinity.ts (refuser consulted after match gates in all three rungs; all four return paths carry refusedAdoption; simhash refusals excluded from the ambiguity counter), plugin.ts (all four gates), handle.ts (refuser wired under if (!clientProvided)) — identical.
  • Import-conflict site verified (server.ts): line 103 keeps master's served-markers import (incl. processStartMs) AND line 104 adds the PR's adoption-guard import — a clean union, no duplicate or dropped line; setHotAdoptionProbe wiring + _disposeServedWriterForTest seam intact.

Spot-fix applied on this head: 已顺手修:the proxy-tool 409 body named only the first holding peer (hot[0]!) while its own log line and the sibling fork/status gates name ALL deduped peers — aligned the body to dedupe-and-name-all like its siblings → commit 19015a4. Pure error-message-text change; status/gate/logic untouched.

Regression surface: uncontested adoption/fork/tool/status all unchanged (both gate directions pinned); client-named multi-instance model traffic unchanged (multi-instance-live pinned); no new thresholds (reuses served-markers liveness); no wire-shape change; no config/env/version bump. All five behavior changes remain disclosed old→new in the PR body.

CI: re-running at new head 19015a4 after the spot-fix (no failures so far); the underlying code was green-reviewed at d95d1fc6 (30/30) and the imported master work is independently merged-green.

八问(审核结论,中文)

  1. 是什么问题:多实例共用 sessions 目录时,第二个活着的 bili 实例会把对端正在写的 pfa-* 会话链当自己的接管,造成会话行 last-writer-wins 双写覆盖、digest drift、冻结/解冻循环(#5624 机制链)。本 PR 把 #3923 已有的写入者标记证据从「只检测」升级为「写前拒绝」。
  2. 什么原因导致的:根因是会话行 upsert 为 last-writer-wins(src/storage/store.ts:958)且 lane 会话豁免清扫——两个活实例交替写同一行必然漂移;#3923 只告警不拒绝,第二个实例照样接管。表面现象是 digest drift/冻结,病因是双活写入。
  3. 影响范围与严重程度:触发条件 = 两活实例共用 sessions 目录 + 匿名客户端前缀吻合命中对端正在写的链。严重度 = 数据完整性级(会话行被对端覆盖、digest drift、冻结循环),未修前属 p1。客户端显式命名会话的多实例交错拓扑不受影响(受支持,兜底仍是 #3923 告警+冻结)。
  4. 怎么修复的:复用 served-markers.findContestedWriters 的活性作用域做成可选 probe,在四个推断驱动的采纳点写前拒绝——匿名前缀亲和跳过热链转新铸、磁盘接管回 404、fork create 分支回 409(放 replay() 之后保幂等重试)、status 回 409(防错会话路由)、代理工具执行回 409(最后一道写入闸)。活性作用域保证对端退出后即可接管(#4626 交接不受影响)。
  5. 是否有回归问题:审过的既有行为——非竞争采纳/fork/tool/status 全部照旧(双向钉死)、客户端命名多实例模型流量不变(multi-instance-live 钉死)、无新增阈值/wire 形状/配置变更。高危模式逐项过:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化。本次 rebase 的 import 冲突合并已核验为干净 union(未丢行、未重复)。
  6. 是否破坏缓存:不涉及——纯采纳决策的前置拒绝,不改任何缓存/重试/增量游标/去重键失效策略。
  7. 是否改了设计方向:不转向。把既有检测证据升级为拒绝;边界(客户端命名不拒、活性作用域、确定性 id 残余落回 #3923 告警+冻结)均按原设计保留并测试钉死。
  8. 是否引入了新的配置:无新增 env/config/默认值;probe 未接线时行为与从前完全一致。

合并判定:可合。 无阻塞项。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Re-reviewed PR #5717 end-to-end at its updated head 19015a4 (rebased onto current master 58a87962 via one mechanical import-union merge). I independently re-verified the final delta vs base — the hot-adoption logic is byte-consistent with the previously-approved head, and the src/server.ts import-conflict resolution is a clean union (master's served-markers/processStartMs import kept AND the PR's adoption-guard import added; no duplicate or dropped line).

One on-spot fix pushed to the PR branch: aligned the proxy-tool 409 body to name all holding peers like its sibling fork/status gates (was first-peer-only) → commit 19015a4, pure error-message-text change, zero logic/status impact. No other findings; no kernel/ touch, no config/env/version change.

CI: re-running at new head 19015a4 after the spot-fix (no failures so far); underlying code green-reviewed at d95d1fc6 (30/30), imported master work independently merged-green.

Verdict: APPROVE(可合)— mergeable, no blocking items. Full re-review (English + 八问) on the PR: #5717 (review)

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

终态确认:CI 全绿 — head 19015a423,30/30 checks(failed 0 / pending 0),镜像缓存实时核对。

补充两条本 run 的事实记录:

  1. 我的合并 492989013 上曾有 1 个 test shard 红;随后同分支的并发 agent 推了针对性小修 19015a423(src/plugin.ts +3/-2:proxy-tool 409 body 列出全部持有 peer,与 fork/status 两道 hot-adoption 门对齐),当前 head 上全套已绿。八问结论以上一条回复为准,该小修不改变其中任何一项判定。
  2. 清理披露:我此前一次推送命令里分支名打错(…adoperation),意外在远端建了一个指向 492989013 的空闲分支——该提交已是 PR 分支祖先、无任何独有内容,刚刚已删除,无数据影响。

判定:冲突解除 + CI 全绿,PR 侧无剩余 blocker(mergeable_state=blocked 为人工评审门禁);待 owner 评审合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Final status — PR #5717 review complete, no open items. CI now green at head 19015a4 (30 checks: 14 success / 16 skipped / 0 failed, 0 pending).

  • Reviewed end-to-end across both heads: original d95d1fc6 and updated 19015a4 (rebased onto master 58a87962). Independently re-verified the full delta vs base — hot-adoption logic byte-consistent; the src/server.ts import-conflict merge is a clean union (master's served-markers/processStartMs kept + the PR's adoption-guard import added, no duplicate or dropped line).
  • One on-spot fix pushed to the PR branch: proxy-tool 409 body now names all holding peers like its sibling fork/status gates (was first-peer-only) → commit 19015a4, pure error-message-text, zero logic/status impact.
  • No kernel/ touch, no config/env/version change; all five behavior changes disclosed old→new in the PR body.

Verdict: APPROVE(可合)— mergeable. Re-review comment on the PR: #5717 (review)

This branch has not been deployed

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

Projects

None yet

1 participant