Skip to content

[PR] fix(#4977): exit twin-collision before persistence init when the port holder is a silent same-build twin - #5004

Merged
ranxianglei merged 10 commits into
masterfrom
2026-10-28_4977-present-twin-persist-gate
Oct 31, 2026
Merged

ranxianglei merged 10 commits into
masterfrom
2026-10-28_4977-present-twin-persist-gate

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #4977

What this fixes

The residual defect from #4977's incident chain (the main availability chain was already fixed in #4825/#4904, both post-v0.1.208): when the port is held by a same-build, same-lane twin whose health probe is silent while its socket still accepts connections (dying or event-loop-wedged — #3654's alive-but-unserviceable), a substitute child proceeded into persistence initialization and opened index.db under the zombie before its own listen failed EADDRINUSE. Every recovery-storm round produced a real two-process window on one store (#3923/#3959) plus the misleading [storage] another process … is already writing report — on rounds that end in the twin-collision exit anyway.

How

  • findPresentUnverifiedSameLaneTwin (src/instance.ts) — the recovery-window complement to findVerifiedSameLaneTwin. Per registry entry, in order: same-lane twin classification → socket accepts (decisive negative: no live listener means a stale marker, fall through to the bind) → health probe silent (an answered probe falls through to the verified/mismatch path).
  • startServer (src/server.ts) — after the existing verified-adopt gate and before createEngineContext, a present-but-silent twin exits via the shared exitBeforePersistence tail with the identical code 3 (eaddrinuseExitCode("twin-collision")) the late EADDRINUSE path would have produced: the late policy classifies exactly this registry evidence (classifySameLanePeer → twinHolds fail-fast), so the outcome is unchanged, only decided earlier — without touching the store. The spawner reads code 3 as an adopt signal and retries once the zombie frees the port (dsh lane: BUSY-drop → EADDRINUSE detour → adopt-twin race is silently lost ~half the time, and a one-shot bootstrap failure then becomes permanent #4811 self-heal).
  • Positive-evidence-only discipline (Pi duplicate startup writes index.db before twin adoption and disables unified storage #4341) preserved: free port ⇒ bind proceeds (a stale marker cannot kill a normal start); answered probe ⇒ this gate never refuses.

Behavior change disclosure

  • Boot-time only; both compression modes unaffected. A start that previously opened index.db (+ lockfile overwrite) and then exited code 3 now exits code 3 without opening the store. No change to any outcome that reaches serve state.
  • New log-line variant on that exit (still held by a same-build bili instance … health probe is silent); spawn-port log format unchanged.

Config surface

None added — reuses existing knobs only (probeOwnerInfo / tcpConnectable defaults).

Tests

  • Unit truth table for the new predicate (socket × probe × shape/fingerprint/pid/port/lane dimensions; socket-first ordering asserted with zero probe calls spent on a dead port).
  • Real-CLI rows (registered in scripts/live-files.mjs): silent zombie holding the port ⇒ exit code 3, output carries both hints, and no index.db exists under BILI_SESSIONS_DIR (the regression pin); live marker over an unlistened port ⇒ normal boot, unified FULL mode enabled, index.db present.
  • Sibling suite tests/issue4341-early-twin-adoption.test.ts re-run green locally (guards the refactored boot block).

@ranxianglei ranxianglei changed the title fix(#4977): exit twin-collision before persistence init when the port holder is a silent same-build twin [PR] fix(#4977): exit twin-collision before persistence init when the port holder is a silent same-build twin Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-28_4977-present-twin-persist-gate (d928ff1)

Latest build — install this exact version

npm install -g billion-context@0.0.7429-pr.5004.3619bb7

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
d928ff1 billion-context@0.0.7429-pr.5004.3619bb7 build
216f3a5 billion-context@0.0.6591-pr.5004.6b423a6 build
ec5321c billion-context@0.0.6579-pr.5004.f217352 build
d3db126 billion-context@0.0.6572-pr.5004.bfad055 build
231f77a billion-context@0.0.6566-pr.5004.8fdb1cb build
da25207 billion-context@0.0.6559-pr.5004.b67c385 build
c820c8b billion-context@0.0.6545-pr.5004.8cc7394 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复。 检索 open+closed 的 issue/PR,无其他在途工作修同一残留缺陷。相邻条目机制各自独立且各有归宿:主链(并发重拉全体放弃)已由 #4825 合入、直连窗口守卫由 #4904 合入(均晚于报障版本 v0.1.208),DIGEST DRIFT 处置由 #4986 单独跟踪——本 PR 只针对「替补子进程在僵尸底下先开 index.db」这一个残留点,与它们无重叠。

标签: bug + dsh + scope/wiring + p1(保留原 pr)。理由:缺陷类修复;故障域是 dsh 车道恢复风暴;改动落在启动期监听裁决管线;同库双写者窗口属数据损坏风险类,按 2026-10-19 口径定 p1。

以下结论是我对本 PR 分支(c820c8b,单提交、直接落在当前 master 9b6ec23 上)独立重审的结果,不是转述 #4977 侧的分析:

一、方向关(审原 issue):#4977 的可执行项里,master 上真正剩下的就是这一处——子进程的前置裁决只认「探针有应答且身份匹配」的孪生(#4341 verified-adopt),占据者是「socket 还通、探针沉默」的将死态时判定不命中,进程就一路走到持久化初始化才在 listen 处撞 EADDRINUSE。本 PR 修的正是这个点,没有扩大也没有缩小范围。issue 建议里的其余各项(spawner 重试仲裁、BUSY 判定接入 respawn、直发窗口守卫)分别由 #4811/#4825、#4894/#4904 承接,DIGEST DRIFT 归 #4986——分工干净。

二、八问

  1. 是什么问题:恢复风暴里,替补子进程发现「端口被将死孪生占着」这件事发生得太晚——它先打开 index.db,然后自己的 listen 才失败。每一轮都造出一次真实的双写者窗口和一条误导性的 [storage] another process … is already writing 报告。
  2. 什么原因导致的:裁决点位于持久化初始化之后。verified-adopt 门对沉默探针正确地拒绝收编,但拒绝之后没有出口,只能继续往下走到开库。
  3. 影响范围与严重程度:触发条件窄(同构建同车道同端口 + 占据者恰处于将死态的恢复轮次),但后果是存储卫生级风险:两个进程同写一个 SQLite 的窗口 + 误导日志;实际数据损坏(fold 丢失/DIGEST DRIFT)主要是僵尸自己写一半造成的,归 Unified-store ingest verification reports DIGEST DRIFT and re-ingests the full tail for sessions whose in-memory ref order diverges from stored row order #4986。报障时的核心链路停摆属版本滞后,已随 [PR] fix: dsh lane — keep saturated proxies attachable instead of spawning into EADDRINUSE; self-heal one-shot bootstrap failures (#4811) #4825/[PR] fix(#4894): arm the direct-fallback oversize guard on dsh not-ready sends #4904 修复。
  4. 怎么修复的:把同一个决策前移。新增 findPresentUnverifiedSameLaneTwin(src/instance.ts)作为 verified 门的补集:registry 记录分类为孪生 → TCP 还通(决定性负证据:不通就是 stale marker,放行去 bind)→ 探针沉默,三者齐备才在 createEngineContext 之前以 code 3(twin-collision)退出。退出码、日志前缀、spawn-port 行格式与旧路径完全一致,spawner 侧(src/launcher.ts:5270 读 TWIN_ADOPT_EXIT_CODE)零改动,照旧走 adopt→rediscovery→dsh lane: BUSY-drop → EADDRINUSE detour → adopt-twin race is silently lost ~half the time, and a one-shot bootstrap failure then becomes permanent #4811 自愈重试。
  5. 是否有回归问题:我逐项核过既有行为——
    • 「结果不变」的声明成立:late EADDRINUSE 处理器的 classifySameLanePeer 纯按 registry 证据分类(不做存活检查),decideEaddrinuse 里 twinHolds 优先级最高(src/listen-policy.ts:63),僵尸占端口 ⇒ bind 必失败 ⇒ 旧路径迟早也是同一个 code 3。新门只是提前决定、不再碰库。
    • verified-adopt 路径:仅抽出公共尾部函数 exitBeforePersistence,hint 文本逐字节未动;兄弟套件 tests/issue4341-early-twin-adoption.test.ts 本地重跑 7/7 绿。
    • 正证据纪律保持:stale marker(端口没人听)⇒ 放行;探针有应答(无论匹配与否)⇒ 放行交还既有路径——漂移形状/外构建指纹/死 pid/错端口/错车道/缺 lane 各维度都有负向测试行钉住。
    • 启动时延:仅在存在「分类为孪生且探针沉默」的条目时多一次 TCP 预检(2s 上限),无此类条目时零开销。
    • 无阈值/时序/输出格式漂移;两种压缩模式均不受影响(纯启动期路径)。
  6. 是否破坏缓存:不涉及。
  7. 是否改设计方向:没有。同一协议内把一个已有决策点前移,未引入新机制。
  8. 是否引入新配置:没有。复用既有 probeOwnerInfo/tcpConnectable 默认参数。

三、测试有效性:真测试。两行真实 CLI 子进程的断言有牙且互为对照——僵尸占端口行断言 exit 3 + 两条 hint + $BILI_SESSIONS_DIR/index.db 不存在(回归钉);ghost marker 占空闲端口行断言正常启动 + FULL 模式开库 + index.db 存在(同时证明数据库确实落在这个路径,让前一行的负向断言不是空转)。若门回归,子进程会走 late 路径以旧 hint 退出并留下 index.db,两条断言都会抓住。端口全部 listen(0),无固定端口假设;live-files.mjs 注册到位(SPAWN_RE tripwire)。

四、本地定向验证:node --import tsx --test tests/issue4977-present-twin-persist-gate.test.ts tests/issue4341-early-twin-adoption.test.ts → 13/13 全绿(17.6s)。全量回归以 CI 为准。

五、CI 状态:截至我查看时(fetched 19:15Z)各 test 分片 in_progress/queued,尚无失败;mergeable_state=blocked 仅因检查未完成。

合并判定:代码与行为审查通过,无拦截项;等 CI 全绿即可由 owner 合入(合并动作本身我只提示、不代劳)。

@ranxianglei ranxianglei added bug Something isn't working dsh p1 scope/wiring labels Oct 27, 2026
ci-check added 2 commits October 28, 2026 04:29
The silent-twin zombie server accepted TCP connections without an error
handler on the sockets. On Windows the child's abrupt process.exit
resets the half-open probed connection; the RST reaches the
zombie-side socket after the test has already completed and surfaces
as an uncaughtException (read ECONNRESET) failing the shard although
every assertion passed (CI run 40567102989, test (windows-latest, 22, 2),
not ok 852). Matches the established pattern in the fix-806 /
auto-restart / port-zone-live suites.
Unblocks PR #5004's test (windows-latest, 22, 2) red on head da25207:
three abort cells (proxy-openai-sse / proxy-responses-sse / proxy-json)
asserted closed=0 after exhausting the flat 3s (30x100ms) poll on a
loaded Windows runner -- the same signature already recorded under #4599
for #4982/#4774/#4683 (rerun green / in-branch budget bump). Sibling
cell abort x proxy-anthropic-sse passed in 176ms on the same shard and
every other windows/ubuntu shard ran this file green on the same head,
so this is runner load, not a code regression; the PR's diff touches
none of these paths.

Labeled CI-unblock commit; duplicates #4683's pending identical change --
drop this commit when rebasing if #4683 lands first.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) CI 续报(新 head da2520741,run 40578666116)

当前判定:产品代码自 c820c8bbd 未变(上条八问结论全部维持);da2520741 仅测试 harness 一行。等 rerun 转绿即可由 owner 合入;若同 flake 签名在干净 runner 复发再升档处理。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI auto-fix attempt 2/2 收工:根因已定位、修复已推送,等重跑

查重:无重复 issue/PR——但此红属于 #4599 在档的已知 flake 家族(floors 350/352/358:#4982/#4774/#4683 今日同签名命中);修法与 #4683 分支上未合入的预算加倍相同(#4683 先合则 rebase 时丢弃本 commit),不另开 issue。

八问

  1. 是什么问题:head da2520741 上仅 test (windows-latest, 22, 2) 红(run 40578666116)。tests/wire-exit-matrix.test.ts 三个 abort cell(proxy-openai-sse / proxy-responses-sse / proxy-json)断言 closed=0:客户端中止后,测试轮询窗口内没观测到代理销毁上游 socket。该分片其余 2496 个测试全过(2484 pass / 3 fail / 12 skip)。
  2. 什么原因导致的:测试原本最多等 3s(30×100ms)让 abort 传播到上游 socket teardown;Windows runner 负载下传播超过 3s,断言先到。不是代码回归,证据链:① 同 shard 的兄弟 cell abort x proxy-anthropic-sse 176ms 通过;② 同 head 下其余 4 个 windows 分片(w22s1/s3/s4/s5)与全部 ubuntu 分片跑同一文件全绿;③ 同一 closed=0 签名今日已在三个 PR 命中([PR] release v0.1.209 #4982/[PR] fix: split header-less claude code subagents onto their own session lane (#4352) #4774/[PR] fix(window): size a child conversation from its parent's runtime-info #4683,[PR] fix: split header-less claude code subagents onto their own session lane (#4352) #4774 rerun 即绿);④ 本 PR diff 只动启动路径 twin-collision 判定(src/server.ts、src/instance.ts、新增 real-CLI 测试),与 abort/teardown 路径零交集。上一 attempt(da25207)修的 ECONNRESET 僵尸 socket 已确认消失(本轮无该报错)。
  3. 影响范围与严重程度:仅 CI 测试信号可靠性(慢 Windows runner 上的测试误报),用户/产品行为零影响。
  4. 怎么修复的:把该测试族的 abort→teardown 轮询预算从 3s 加倍到 6s——抽一个具名常量 ABORT_TEARDOWN_BUDGET_MS + 共享 helper awaitUpstreamTeardown,替换四处重复循环(顺带消了重复);零产品代码改动。本地定向验证 7/7 绿 + typecheck 干净,新 head 231f77a1d,CI 已在跑。
  5. 是否有回归问题:无。改动仅限该测试文件;断言语义不变(提前退出逻辑保留,只放宽等待上限);不触碰 src/ 任何产品路径、配置面、wire、kernel。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:没有。
  8. 是否引入新配置:没有。

行为变更披露(仅测试):四个 abort cell 的断言等待上限 3s→6s——只影响慢 runner 上失败出现的时点,不放松任何断言(预算耗尽仍立即失败,不会吞掉真回归)。

结论:等 231f77a1d 的 CI 结果;若同一签名在干净 runner 再复发,按在档口径升档(届时应排查产品侧是否存在真实 teardown 延迟路径,而不是继续加宽预算)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) CI 收口:全绿 ✅(最终 head 231f77a1d)

时间线(全部已逐份读日志核实,非转述):

  1. 原 head c820c8bbd:26/27 job 绿,唯一红腿 w22s2 = 本 PR 新测试的僵尸 socket 缺 error 处理器(断言本身全过,Windows RST 时序竞态)→ 我修了一行(da2520741,对齐 fix-806/auto-restart/port-zone-live 既有模式);
  2. da2520741:本 PR 测试文件 6/6 绿,ECONNRESET 消失;该 shard 另红 3 例 = 在档 wire-exit-matrix abort-teardown flake 家族(慢 runner,closed=0 ×3 cell,第 4 个兄弟 cell 176ms 绿);
  3. ci-check 车道随后在分支上补了 231f77a1d(abort teardown 轮询预算 3s→6s,抽公共 helper,断言未动,标注了与 [PR] fix(window): size a child conversation from its parent's runtime-info #4683 在途同改的重复关系——rebase 时若 [PR] fix(window): size a child conversation from its parent's runtime-info #4683 先合可丢此 commit);
  4. 最终 head 231f77a1d 检查:39 success / 16 skipped(skip-scoped labeled run)/ 0 fail / 0 cancelled。

最终判定:产品代码自 c820c8bbd 零变化,首条回复的八问结论全部维持(方向正确、零回归、零缓存影响、无新配置、仅启动路径行为变更且已披露);分支上两个后续 commit 均为测试侧修复(harness 一行 + flake 预算),不改变任何产品行为。CI 已全绿,可由 owner 合入;合并时若 #4683 已在途/已合,按 231f77a1d 的提交说明处理重复即可。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] (ai: vllm-qwen/qwen3.8-27b) 结果:master 再次前进(b08fbf361,#5016 draining-twin 修复)后合入本分支——文本冲突仅 import 块(已按两 PR 符号并集解决),但发现语义冲突需要设计决策,未猜测:已升级至 **https://github.com/ranxianglei/billion-context/issues/5018**(p1,标签 bug/scope/wiring/p1),分支停在本地已解析的 merge commit(2095f4303),未推送。

八问:

  1. 是什么问题:[PR] fix(#4977): exit twin-collision before persistence init when the port holder is a silent same-build twin #5004(本 PR)与 [PR] fix: draining proxy no longer claims its freed port — same-lane newcomer ladders instead of dying twin-collision (#4982) #5016(master)对同一启动证据模式(注册表标记认领端口 P、同车道同构建同形状、pid 存活、无 portReleasedAt 戳、socket 可连接、健康探针静默)策略矛盾——本 PR 的持久化前 twin-collision 退出 vs [PR] fix: draining proxy no longer claims its freed port — same-lane newcomer ladders instead of dying twin-collision (#4982) #5016「未验证认领永不判 twin-collision,应 ladder」。
  2. 什么原因导致的:两个机制针对不同事故独立编写([Bug][dsh] Recovery race: after a stuck twin dies, concurrent re-pull causes the substitute child process to self-termin | [Bug][dsh] 恢复竞态:卡死孪生死后并发重拉,替补子进程在端口仍被僵尸占据时按 twin-collision 自杀(code 3)→ 全体客户端同时放弃、裸历史直连撞上游 1M token 上限;并触发 index.db 双写者互斥(DIGEST DRI… #4977 僵尸双写窗口 / [PR] release v0.1.209 #4982 陈旧标记误判),而该证据模式在 bind 之前观察上不可区分——静默探针不携带身份信息,且 verifyEntryOwnsPort 对静默响应者按设计返回 false(inconclusive),无法拿来给早路径做门控而不把早路径整个废掉。
  3. 影响范围与严重程度:本地确定性复现——合并树上 tests/issue4982-draining-twin-ladder.test.ts test 6 失败(5/6 过,含主 stamped-drain 场景 e2e)。后果:本 PR 现状推不上绿;若强行选边,要么重开 [PR] release v0.1.209 #4982「新实例被静默占位者永久卡死」角落,要么重开 [Bug][dsh] Recovery race: after a stuck twin dies, concurrent re-pull causes the substitute child process to self-termin | [Bug][dsh] 恢复竞态:卡死孪生死后并发重拉,替补子进程在端口仍被僵尸占据时按 twin-collision 自杀(code 3)→ 全体客户端同时放弃、裸历史直连撞上游 1M token 上限;并触发 index.db 双写者互斥(DIGEST DRI… #4977 的 index.db 双写窗口。
  4. 怎么修复的:文本冲突按并集解决并验证(typecheck 干净;issue4977+wire-exit-matrix 13/13 绿;issue4982 5/6,test 6 即上述矛盾);语义冲突带三个选项+代价+推荐立为 decision request: silent-twin port evidence — pre-persistence adopt-exit (#5004) vs ladder-off (#5016) contradict; pick the winner #5018(A 早路径胜出→改 [PR] fix: draining proxy no longer claims its freed port — same-lane newcomer ladders instead of dying twin-collision (#4982) #5016 test 6 预期;B 晚路径胜出→移除早路径,不推荐;C 真·socket 归属校验作为根治跟进)。推荐 A 先解封。
  5. 是否有回归问题:本地合并树未引入新回归——唯一失败是两 PR 既有行为互相矛盾本身,非合并操作造成;分支未推送,CI 状态不变(head 216f3a5c8 全绿:39 success / 16 skipped / 0 failed)。
  6. 是否破坏缓存:不涉及(启动/端口所有权域,未触碰缓存/重试/游标面)。
  7. 是否改了设计方向:未改——等 owner 对「该证据模式听谁的」拍板(decision request: silent-twin port evidence — pre-persistence adopt-exit (#5004) vs ladder-off (#5016) contradict; pick the winner #5018 A/B/C)。
  8. 是否引入新配置:无。

收工判定:停手等 #5018 裁决;裁决后在本 PR 内落对应修正再推送。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] (ai: vllm-qwen/qwen3.8-27b) 冲突处置状态(一行):与 master(b08fbf361)的文本冲突已在本地解决(import 块并集,merge commit 2095f4303,typecheck 干净);因存在需设计决策的语义冲突(#5004↔#5016 对同一静默孪生证据的策略矛盾),按流程未推送,等待决策请求 #5018 (p1)裁决——详见上一条八问评论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] (ai: vllm-qwen/qwen3.8-27b) 状态无变化:master 仍为 b08fbf361(已含于本地 merge commit 2095f4303),语义冲突裁决仍在等 #5018 —— 按「需设计决策不猜」流程继续停手,不推送已知会红的合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

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

Merge-guard outcome: textual conflict resolved locally and verified — but the merge exposes a design contradiction with already-merged #5016, so nothing is pushed until #5018 is decided.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Merge-guard 处理完毕:冲突已在本地解决并验证,但合并暴露了与已合并 #5016 的设计矛盾——按规则不猜,停手等拍板。

做了什么

  • origin/master(b08fbf3)合入分支,唯一文本冲突 = src/server.ts 的 instance.js import 行(取两侧符号并集);本地合并 commit 2095f4303,无冲突标记残留。
  • 合并树上验证:typecheck 干净;定向套件 issue4977 6/6、auto-restart 16/16、wire-exit-matrix 7/7 全绿;issue4982 5/6——唯一红是 test 6,确定性失败(非时序)。
  • 新发现:test 6 失败路径的清理代码在 throw 之后(:435-436),squatter listener 泄漏 → 套件挂死不退出,合并树上 CI 会烧满 job timeout 而非快速红。修法建议已写入决策 issue。

八问(压缩版)

  1. 问题:dirty(conflict);文本冲突仅一处,真问题是 [PR] fix(#4977): exit twin-collision before persistence init when the port holder is a silent same-build twin #5004 与 [PR] fix: draining proxy no longer claims its freed port — same-lane newcomer ladders instead of dying twin-collision (#4982) #5016 对同一启动证据(marker 声称端口 + socket 可连但探针沉默)钉死相反结果(adopt-exit vs ladder)。
  2. 原因:共享证据集在 bind 前观察上无法区分「属主半死」和「socket 易手他人」;[PR] fix(#4977): exit twin-collision before persistence init when the port holder is a silent same-build twin #5004 的「晚策略本会给出相同判决」前提被 [PR] fix: draining proxy no longer claims its freed port — same-lane newcomer ladders instead of dying twin-collision (#4982) #5016 恰好改掉。结构性证据不足,非合并错误。
  3. 影响:PR 无法以任何方式推绿(推上去必红 [PR] fix: draining proxy no longer claims its freed port — same-lane newcomer ladders instead of dying twin-collision (#4982) #5016 自家套件);该证据模式下的启动行为须二选一,两侧各有残留风险(分选项分析见 decision request: silent-twin port evidence — pre-persistence adopt-exit (#5004) vs ladder-off (#5016) contradict; pick the winner #5018)。
  4. 修复:本轮不改代码(设计决策不许猜)。决策请求 decision request: silent-twin port evidence — pre-persistence adopt-exit (#5004) vs ladder-off (#5016) contradict; pick the winner #5018(p1,选项 A/B/C,推荐 C:早路径加 socket 实际属主 pid 精确匹配门)已存在,本轮补入两点新证据;本地合并保留,拍板后恢复 = 一次 push。
  5. 回归:verified-twin 早退出 / stamped-drain / 跨车道 / answered-probe 路径逐项过,均不变;唯一行为差即待拍板角;未发现额外高危模式实例。
  6. 缓存:不涉及(启动期判决在 engine context 创建之前)。
  7. 设计方向:本轮未改;C 若中选会把 Pi duplicate startup writes index.db before twin adoption and disables unified storage #4341 正向证据纪律扩展到 silent 路径(decision request: silent-twin port evidence — pre-persistence adopt-exit (#5004) vs ladder-off (#5016) contradict; pick the winner #5018 第 7 问有分析)。
  8. 新配置:无。

判定:PR 保持 open/dirty 不动,等 owner 在 #5018 拍板 A/B/C;细节见本 PR 上一条 merge-guard 结果评论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

本条是上游同步回显——平台把我此前在 PR 上发的 merge-guard 结果评论(带 upstream-sync 标记)当作新评论转发回来了,不是新的用户输入,无新内容需要处理。状态不变:分支本地合并已就绪(2095f4303,未推送),等 #5018 拍板 A/B/C 后一次 push 恢复。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Merge-guard round 5 — 重新同步 master,状态不变,仍等 #5018 拍板。

做了什么:master 又前进(dcf7607 → 44067a5,+14 提交)。已把当前 master 合进本分支——零冲突,本地新合并头 5aebf230b(10 ahead / 0 behind,工作树干净)。

这 14 个提交全部落在存储/旁路/快照域(#5188 sidecar 可恢复打开、#5140 sqlite 竞争不锁死 sidecar、docs/config 登记 sessions.hardMaxBytes),与本 PR 触碰的文件(src/server.ts 启动/twin-block、src/instance.ts、src/port-owner.ts、src/listen-policy.ts、tests/issue4977*、tests/issue4982*)零重叠。

八问(本轮为再同步轮,多数项「不变」):

  1. 是什么问题:PR 处于 dirty(behind master)需守卫同步;真正的阻塞不是同步本身,而是与已合并 [PR] fix: draining proxy no longer claims its freed port — same-lane newcomer ladders instead of dying twin-collision (#4982) #5016 的设计矛盾——对同一份「同车道同构建存活 marker + socket 可连但探针沉默」证据,本 PR 早路径判 adopt-exit、[PR] fix: draining proxy no longer claims its freed port — same-lane newcomer ladders instead of dying twin-collision (#4982) #5016 晚路径判降级 ladder,钉死相反判决。
  2. 什么原因导致的:结构性证据不足——bind 之前无法区分「属主半死」和「socket 已易手他人」,两个修复各自选边。非本轮引入,master 也没动相关代码。
  3. 影响范围与严重程度:本 PR 现状推不上绿(推上去必红 [PR] fix: draining proxy no longer claims its freed port — same-lane newcomer ladders instead of dying twin-collision (#4982) #5016 自家套件);该证据模式下的启动行为须 A/B/C 二选一,两侧各自的残留风险见 decision request: silent-twin port evidence — pre-persistence adopt-exit (#5004) vs ladder-off (#5016) contradict; pick the winner #5018 选项对比表。
  4. 怎么修复的:本轮不改代码(设计决策不许猜)。本地合并保持就绪,拍板后一次 push。
  5. 是否有回归问题:合并树上逐项验证——typecheck 干净;issue4977 6/6 绿(本 PR 自己的回归钉成立);issue4982 6/7,唯一红 = unverified-twin e2e 行,即与 [PR] fix: draining proxy no longer claims its freed port — same-lane newcomer ladders instead of dying twin-collision (#4982) #5016 的碰撞,确定性复现且与上轮一致(master 未触碰相关文件,碰撞面未变)。verified-twin 早退出 / stamped-drain / 跨车道 / answered-probe 路径均不变。
  6. 是否破坏缓存:不涉及(启动期判决发生在 engine context 创建之前)。
  7. 是否改了设计方向:未改,等 decision request: silent-twin port evidence — pre-persistence adopt-exit (#5004) vs ladder-off (#5016) contradict; pick the winner #5018 拍板 A/B/C。
  8. 是否引入新配置:无。

收工判定:停手等 #5018 裁决(A/B/C,已挂起约两天,决策面自 round-4 起无变化,本轮这 14 个提交也不涉及决策域)。拍板后恢复动作 = 一次 push 5aebf230b(若选 C:先在本分支实现 socket 属主门再推)。在拍板前,后续 guard 触发预计仍是同类再同步/no-op。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Merge-guard round 6 — no-op:master 未动,决策仍未定,无需 rebase/merge。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Round 7 — 仍是 no-op;顺带说明刚才那次「卡住被强制重启」。

先澄清:刚才「进程卡住 31 分钟被强制重启」不是真挂起——round 6 我已把能做的做完(核对 master、确认无需合并、贴状态),之后会话在等你对 #5018 拍板,daemon 把这段空闲误判成卡死回收了。不是需要规避的故障。

本轮核对(与 round 6 完全一致):

一句话:在你对 #5018 拍板(A 早路径胜 / B 晚路径胜 / C socket 属主门)之前,这个 PR 无法推进,每次 guard 触发都会是同类 no-op。拍板后恢复动作不变 = 一次 push 5aebf230b(选 C 则先在本分支实现属主门再推)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Round 8 no-op:master 仍 44067a5bc(零新提交);分支本地头 5aebf230b 已含全部 master(0 behind、零冲突)→ 无可 rebase/merge。#5018 决策仍无拍板(最新一条仍是我 round-4 注记)。未推送。待你 A/B/C 后一次 push 5aebf230b 即收口(选 C 先实现 socket 属主门)。在拍板前后续 guard 触发预计仍是同类 no-op。

# Conflicts:
#	scripts/live-files.mjs
#	src/server.ts
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

1 similar comment
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

…rsistence adopt-exit (option A)

Ruling (owner-approved 2026-10-31): for an unverified unstamped same-lane
claim the early pre-persistence gate (#4977) wins over #5016's late ladder.
The second row of tests/issue4982-draining-twin-ladder.test.ts now asserts
the code-3 twin-collision adopt-exit BEFORE index.db is opened instead of
ladder-off; the draining (portReleasedAt-stamped) row keeps asserting the
ladder. Fixture cleanup hygiene was already finally-wrapped upstream, nothing
to add.

Refs #5018 #5004 #4982 #5016
@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: sglang-gpu0/qwen3.8-27b)

Branch updated per the #5018 ruling — option A (owner-approved 2026-10-31) — plus a rebase onto current master.

What changed on this head:

  1. Merge with master e5e210865 ([PR] fix(storage): a live second writer no longer blocks startup — sharing a local-disk index.db is a supported topology (rev | fix(storage): 活着的第二写者不再阻止启动——共享一个本地盘 index.db 是受支持拓扑(撤回 #5213 的拒绝策略) #5294 second-writer policy + [PR] Four-lane shared startup lifecycle Step 3: opencode lane migration (#5241 Phase 1 / PR-1c, pure move) | 四车道共享启动生命周期第三步:opencode 车道迁入(#5241 阶段 1 / PR-1c,纯搬运) #5247 watchdog + Decision request: PR #5255 has an unresolvable conflict — "Second Long-Resident Writer Demotion (B)" was retracted by th | decision request: PR #5255 冲突解不开——「第二长驻写者降级(B)」被报告人撤回但你随后签核过,且与已合入的 #5091 相抵,请裁决 B 是否仍执行 #5269 adopt-retry all landed since this branch's base). One semantic conflict in src/server.ts where [PR] fix(storage): a live second writer no longer blocks startup — sharing a local-disk index.db is a supported topology (rev | fix(storage): 活着的第二写者不再阻止启动——共享一个本地盘 index.db 是受支持拓扑(撤回 #5213 的拒绝策略) #5294's late ladder meets our pre-persistence gate — resolved by union: both gates stay, sharing one exit tail. The [PR] Four-lane shared startup lifecycle Step 3: opencode lane migration (#5241 Phase 1 / PR-1c, pure move) | 四车道共享启动生命周期第三步:opencode 车道迁入(#5241 阶段 1 / PR-1c,纯搬运) #5247 event-loop-watchdog arm moved to the top of startServer, which now also covers our pre-persistence exit path.
  2. Retargeted the conflicting test expectation (tests/issue4982-draining-twin-ladder.test.ts, second e2e row): for an unverified unstamped same-lane claim, the early pre-persistence gate now wins over [PR] fix: draining proxy no longer claims its freed port — same-lane newcomer ladders instead of dying twin-collision (#4982) #5016's late ladder. P2 must exit with code 3 (TWIN_ADOPT_EXIT_CODE) before opening index.db — that window is exactly what 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/SQLite unified storage degraded to legacy-only (bili v0.1.202, node v24.21.0, darwin-x64) index.db corrupted | SQLite unified storage degraded to legacy-only (bili v0.1.202, node v24.21.0, darwin-x64) index.db损坏 #3959 close. New assertions: adopt-signal exit code, the "still held by a same-build bili instance … health probe is silent" verdict on stderr, the verified-only "already served by" marker absent from the log tail, and no index.db exists under the zombie afterwards. The draining row (stamped claim → ladder) passes unchanged; cross-lane squatters stay ladder-off as before.

Local targets green on this head: issue4982 suite 7/7, issue4977-present-twin + wire-exit-matrix + auto-restart 29/29, typecheck clean. Full-suite verdict below from CI.

The fixture cleanup hygiene flagged during triage was already finally-wrapped upstream in this file — no extra commit needed.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: sglang-gpu0/qwen3.8-27b)

Conflict with #5303 (upward adoption, merged to master as fb5b916 while this PR was in flight) resolved: the only clash was the instance.js import line in src/server.ts — kept both symbol sets minus entryScriptFingerprint (superseded by resolveOwnFingerprint per #4125). The two new-holder policies coexist by design: our early gate handles SAME-build twins (verified→adopt-exit, unverified-silent→pre-persistence exit), #5303 handles strictly NEWER builds (positive registry+health proof → adoption at bind time).

Local on this head: typecheck clean; issue4982 / issue4977 / wire-exit-matrix / auto-restart / issue4125-giveup-reason / issue4125-two-install-deadlock = 51/51 pass. Full gate via CI below.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

@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.

审查完成(本地分支 @980f7aa7,已核对 src 全量 diff + 门控/e2e 套件 + tsc)。结论:代码通过,无阻塞项;CI 全绿即可人工合并。

逐项核验:

  1. gate 位置与互补性(src/server.ts startServer):插在既有 verified-adopt gate 之后、createEngineContext(持久化初始化)之前,与 body 声明逐字一致。verified gate 只收「probe 有回应且匹配」的 twin;本 PR 的 present gate 只收「probe 静默但 socket accept」的 twin——两者互斥覆盖 #4977 的两个窗口,无重叠判定、无遗漏。✓
  2. 正向证据纪律未被破坏:findPresentUnverifiedSameLaneTwin 的顺序是 classify(kind!=="twin" 跳过) → socketAlive 先行做 decisive negative(无活监听 = stale marker,继续 bind,#4341 原则原样保留)→ probe 静默才返回。stale registry entry + 空闲端口 = 正常启动不受影响(有测试钉)。✓
  3. 结果等价性:若两次 probe 之间 twin 复活并应答,gate 落空 → 走旧 late-EADDRINUSE 策略,拿到的 registry 证据与旧路径相同 ⇒ 同 code 3(eaddrinuseExitCode("twin-collision")),spawner 侧 #4811 self-heal adopt 语义不变。最坏情况=旧行为,无新增伤害。exitBeforePersistence 共享尾部两路复用同一 tail(configureLogger→error→spawn-port-log→drain closeLogger→process.exit),launchToken 分支也一致。✓
  4. #4982 e2e retarget 正确(125c3bc5):按 #5018 owner ruling(option A)把 unverified-twin 行从「drain 阶梯」改锚到 pre-persistence adopt-exit,断言链完整:exit code=TWIN_ADOPT_EXIT_CODE、stderr 含 "still held by a same-build bili instance (pid \d+, lane pi) whose health probe is silent"、bili.log doesNotMatch 旧 verified 文案、sessions/index.db 不存在(#3923/#3959 双写窗回归钉)。本地实跑通过。顺带说明:这一行正是当前 master 上一直红的 "#4982 draining same-lane predecessor + squatter" e2e——本 PR 合入会直接消除 master 那条已知红(此前多个 PR 的 CI 分诊都把它归为 master 既有失败)。
  5. auto-restart 变更(216f3a5c):makeReadyStub 的 EACCES/EPERM 并入 OS-bind-refusal 类(Windows dynamic exclusion ranges,#3182 族)与 misplacement-stub 重试语义对齐,属必要配套而非夹带。✓
  6. wire-exit-matrix(231f77a1/da252074):ABORT_TEARDOWN_BUDGET_MS 3s→6s(loaded Windows runner flake)+ issue4977 real-CLI 行吞 zombie-socket 错误,均为有据的稳定性加固。✓

非阻塞备注(无需改动也可合并):

  • CHANGELOG:近期合入(如 #5236/#4521 merge bcl87837)都带条目,本 PR 没有 CHANGELOG.md 行。看 maintainer 是否要求补一句「silent same-lane twin now exits before persistence (closes #4977)」。
  • body 里 "second-writer / cross-lane squatter" 边界声明与实现一致:classifySameLanePeer kind!=="twin" 直接跳过,跨 lane 占用完全不进本 gate。

本地验证(正式全量留给远程 CI,head 轮刚入队 pending,不盯):

  • 定向批全绿:issue4977-present-twin-persist-gate 23/23 + 其余 7 文件 61/61(issue4982-draining-twin-ladder、wire-exit-matrix、auto-restart、issue4341-early-twin-adoption、issue3654-health-probe-three-state、listen-policy、issue4125-two-install-deadlock),0 fail 0 skip
  • tsc --noEmit exit 0
  • 无 kernel 改动 ⇒ 不触发 kernel-guard、无需版本 bump ✓

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Option A 已落地并同步到最新 master——本轮做了独立验证 + 守卫同步 + 推送。

背景:#5018 已由你拍板 option A(2026-10-31),实现会话据此把冲突测试行改钉为持久化前 adopt-exit(commit 125c3bc5b),并把分支合到当时 master(fb5b91611)推上 980f7aa74。之后 master 又前进 8 个提交,分支因此落后。

本轮(merge-guard)做了什么:

  1. 取真实状态:PR head 980f7aa74 落后 master 8 提交(fb5b916 → 71d2494);这 8 个全是 loop/压缩回执域([PR] fix(loop): a failed compress must not kill the task — feed the model a recovery receipt instead of ending the turn #5231/fix(loop): a failed compress must not end the user's task — feed the model a recovery receipt instead of breaking with "length" #5220/Claude Code stops mid-task when bili ends a turn early: the Anthropic adapter sends stop_reason "length" #5179/[Bug][fork] Cold restore cannot use an intact unified raw tail for a non-retained parent (#4266 item 4) #5140 测试钉),与本 PR 文件零重叠。
  2. 把当前 master 71d249416 干净合并进分支(不 rebase,保留实现会话的 commit 作祖先)→ 新头 d928ff167,现 0 behind。
  3. 在 d928ff167 上独立验证:typecheck 干净;issue4982 7/7(test 7 已重钉为「unverified unstamped twin → 持久化前 adopt-exit(decision request: silent-twin port evidence — pre-persistence adopt-exit (#5004) vs ladder-off (#5016) contradict; pick the winner #5018 option A)」且通过;test 6 draining+squatter→ladder 亦通过);issue4977 6/6。
  4. 已推送 d928ff167 到 PR 分支 2026-10-28_4977-present-twin-persist-gate,CI 将在该 head 上跑。

八问:

  1. 是什么问题:option-A 改动落地后,分支因 master 继续前进而落后(守卫需再同步)。
  2. 什么原因导致:fast-moving master——head 基于 fb5b916,期间 master 合入 8 个 loop/receipt 提交,与本 PR 无文件交集。
  3. 影响范围与严重程度:纯同步性(分支落后),非功能回归;零重叠 → 合并干净、可编译、定向套件全绿。
  4. 怎么修复的:干净合并当前 master 进分支(保留实现会话 commit),验证后推送;未改任何产品逻辑——option-A 判决由实现会话按你的拍板落地,我只做同步 + 独立验证 + 推送。
  5. 是否有回归问题:typecheck 干净;issue4982 7/7(含 option-A 新钉行 + draining→ladder 行);issue4977 6/6;并入的 8 个 loop 提交与本 PR 启动/twin 判定路径无交集。
  6. 是否破坏缓存:不涉及(启动期端口所有权域)。
  7. 是否改设计方向:否——option A 是你已拍板的既定方向,本轮只同步+验证+推送。
  8. 是否引入新配置:无。

收工判定:分支已同步到最新 master 并推送(d928ff167),本地验证全绿;此前「停手等 #5018 拍板」的阻塞随 option A 落地而解除,待 CI 在新 head 上确认后即可由你合入。

@ranxianglei
ranxianglei merged commit 7528deb into master Oct 31, 2026
24 of 25 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.944-master.7528deb (rolling master tag).

npm install -g billion-context@0.0.944-master.7528deb  # 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