Skip to content

fix(test): hermetic zone base + pin #2877 attach-policy flip in pinned-port e2e (#3212) - #3215

Closed
ranxianglei wants to merge 4 commits into
masterfrom
2026-10-14_ci-port-zone-red-storm
Closed

ranxianglei wants to merge 4 commits into
masterfrom
2026-10-14_ci-port-zone-red-storm

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #3212

查重: 无(按失败签名检索 open+closed:EADDRINUSE / 18787 / port-zone-live / hook e2e pinned port / lifecycle-less / upgrade-replacement,均无既有条目)

Scope: tests only — no src/, no ci.yml, no config-surface change

Sub-defect A — port-zone-live EADDRINUSE red storm (tests/port-zone-live.test.ts)

Root cause: the live zone tests squatted the machine-global FIXED zone base (18787) directly. Two mechanisms:

Fix: each test reserves its own stable port run through the EXISTING BILI_ZONE_PORT knob (scan a stable region above the zone default, below the ephemeral floor; claim the head with a real listener as the arbiter; release + wait for the socket to free before the scenario). Verified: full live file 9/9 green while an external dummy holds 18787.

Sub-defect B — claude-native pinned-port e2e "lifecycle-less" refusal (tests/claude-native.test.ts)

Root cause: NOT environment — a deterministic regression from #2877 (merged 2026-10-14). The LANEd-hook default attachPolicy flipped to own-lane, so a lane-less manual daemon on the pinned port is now refused (fail fast + remedy) instead of ridden. The e2e still asserted the pre-#2877 attach behavior → red on every leg. Reproduced locally with the exact CI message.

Fix: the e2e now pins the documented restore path (native.attachPolicy: "global-fallback"), keeping #1660's user-zone attach coverage; a NEW sibling test pins the new default (fail fast, actionable remedy, exit 0, daemon untouched, no port-hop). Both pass locally (full file 59/59).

Behavior changes

Config surface

None new. Reuses the existing BILI_ZONE_PORT env var (src/config.ts resolveZonePortBase), set inside the test process only.

Verification

  • Targeted local runs (ACP_TEST_CLAUDE_NATIVE=1): tests/port-zone-live.test.ts 9/9 (with an external occupant holding 18787), tests/claude-native.test.ts 59/59.
  • npm run typecheck clean. Full-suite verdict = remote CI on this head.

awork added 2 commits October 15, 2026 04:30
The live zone tests squatted the machine-global fixed zone base
(18787) directly, so any concurrent leg or leaked daemon on the same
runner turned them red with EADDRINUSE (#3044 tests on master since
2026-10-14). Each test now reserves its own stable port run through the
existing BILI_ZONE_PORT knob (scan above the zone default, below the
ephemeral floor), claims the head with a real listener as the arbiter,
and releases it (waiting for the socket to free) before the scenario —
no new config surface, no ci.yml change.
…3212)

#2877 flipped the LANEd-hook default to own-lane, so a lane-less manual
daemon on the pinned port is refused (fail fast + remedy) instead of
ridden; the pre-existing e2e still asserted the old attach behavior and
went deterministically red on every leg. The e2e now pins the documented
restore path (native.attachPolicy=global-fallback), and a sibling test
pins the new default: fail fast, actionable remedy, exit 0, daemon
untouched, no port-hop.
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-14_ci-port-zone-red-storm (fad1925)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3692-pr.3215.1ec382a

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-pr3215.tgz
npm install -g package

Install instructions are refreshed on each push.

awork added 2 commits October 15, 2026 05:01
This head went red on three windows lanes with two pre-existing failure
signatures that PR #3197 already fixes on its branch:

- auto-restart "survives SIGTERM" stub: POSIX-only scenario — Windows
  terminates on SIGTERM uncatchably, so the stub can never model a
  SIGTERM-surviving replacement (w22-2 + w24-2 reds). Skip on win32.
- claude-native "occupied stable port": the accepted probe socket's
  ECONNRESET was unhandled and crashed the test process (w24-3 red).
  Destroy connections eagerly.

Both hunks are verbatim mirrors of #3197's fixes so the branches stay
trivially reconcilable when the owner consolidates them.
… review)

claim is always bound when release() runs (the bind is the arbiter);
net.Server.close() on a listening server does not throw synchronously,
so the try/catch swallowed nothing. Review nit per code-cleanliness
rules (no empty catch).
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重结论:同家族相关,不关闭——本 PR 的「查重: 无」漏掉了 open 的 PR #3197。
#3197(fix/3182-zone-slot-bands,建于 2026-10-14T15:57Z,早于 #3212 立案的 19:10Z)修的是同一场红风暴(#3182/#3184/#3188 家族),且改的是同样两个测试文件。按「同症状→一个 issue、红风暴防线一个根因一个修复 PR」的政策,两者不能按现状都合并(两文件文本冲突)。两个都保持打开、互相链接,合并载体由 owner 拍板(对比与建议见文末「协调请求」)。

审核动作:两个文件的完整 diff 已逐行读毕,关键断言对照源码验证过(fail-fast 文案 src/launcher.ts:3986-3998 与两套正则全部吻合;own-lane 过滤在 src/launcher.ts:3630,lane-less 发起方保留通配 attach,#2877 前后可完全解释 e2e 翻转)。CI 三条红 lane 全部做了日志取证。已在 PR 分支推了 2 个标注小修 commit(见第 5 问),新 head fad1925ce 的 CI 重跑中。

八问

  1. 是什么问题:master 自 2026-10-14 起红风暴——port-zone-live 实弹测 EADDRINUSE(18787)+ claude-native 钉端口 e2e 撞上 [Bug] attach gate: 手动 bili start 的 user-zone daemon 无视 BILI_NATIVE_ATTACH_EXTERNAL=0(文档称连 user-zone 一起关);并请求按 lane 控制 attach #2877 默认翻转后的 lifecycle-less 拒绝。本 PR:A 用每测试私有 zone base 做 hermetic,B 把 [Bug] attach gate: 手动 bili start 的 user-zone daemon 无视 BILI_NATIVE_ATTACH_EXTERNAL=0(文档称连 user-zone 一起关);并请求按 lane 控制 attach #2877 行为翻转的两边都钉进 e2e。
  2. 什么原因导致的:A = 机器全局固定 zone base 18787 被并发 CI leg + cancel 泄漏的 daemon 占用,叠加 SIGKILL 后 socket 拆除延迟,ci已经运行超过20分钟了 检查为什么并作优化 #3143 分片把腿数放大成风暴;B = 确定性回归而非环境问题——[Bug] attach gate: 手动 bili start 的 user-zone daemon 无视 BILI_NATIVE_ATTACH_EXTERNAL=0(文档称连 user-zone 一起关);并请求按 lane 控制 attach #2877 把默认 attachPolicy 翻到 own-lane,lane-less 手动 daemon 现在在 claude-native hooks must not attach to a lifecycle-less proxy — attach gate + self-managed fallback #1335 gate 之前就被过滤掉 → strictPort 路径抛 refusal,而 e2e 仍断言 [Bug] attach gate: 手动 bili start 的 user-zone daemon 无视 BILI_NATIVE_ATTACH_EXTERNAL=0(文档称连 user-zone 一起关);并请求按 lane 控制 attach #2877 之前的 ride 行为(本地可复现,与日志一致)。
  3. 影响范围与严重程度:仅测试,零运行时影响;严重度 = 红着的时候所有 PR 的合并全被挡(各 lane 共用同一套件)。
  4. 怎么修复的:A = 每个测试经现有 BILI_ZONE_PORT 旋钮预留私有 20 端口连续区(扫 18800..30000 步长 25,真 bind 作仲裁者防并发撞车,场景前 release + waitPortFree);步长 25 > run 20 保证并发预留互不重叠,区间低于 Linux ephemeral floor 32768,listen(0) 永不撞入。B = ride 测试钉住文档化恢复路径 native.attachPolicy: "global-fallback"(保住了 [Design] 定死端口 lane(claude 48787 / zcode 48789)端口被占时的 0 配置解法 #1660 的用户区 ride 覆盖,这一点比 ci: per-file zone-port bands for live suites + bounded TOCTOU retries (#3182/#3184/#3188) #3197 强——它直接删掉了该覆盖),新增 sibling 测试钉住新默认(exit 0、响亮 remedy、daemon 不动、无 port-hop)。
  5. 是否有回归问题:运行时零变更。审过的既有行为:mocked 套件仍钉 18787 默认(tests/port-zone.test.ts 未动)✓;[Design] 定死端口 lane(claude 48787 / zcode 48789)端口被占时的 0 配置解法 #1660 ride 覆盖保留 ✓;autoRestartOnUpdate + occupied target port -> orphan process leak: new instance silently hops to the next port, old instance never exits #3044/[bug] claude native proxy outlives all sessions despite README lifecycle contract — watcher-based shutdown did not fire #1322/claude-native hooks must not attach to a lifecycle-less proxy — attach gate + self-managed fallback #1335 断言形状不变(只跟随预留 base)✓。残留风险:waitPortFree 返回到 daemon bind 之间有一个极小再被抢窗口(ladder 能吸收,exact-port 断言理论上仍可 flake——比原来窄得多)。另:本 head 自己在 3 条 windows lane 上红了,取证结果全是 CI flake storm: concurrent fixed-port e2e files (port-zone-live / claude-native / auto-restart) collide on the 18787 zone under --test-concurrency 4 #3182 家族既有 flake,与本 diff 无关(live 套件在 Windows 整体 skip,日志证实两条新测试 # SKIP):① auto-restart「survives SIGTERM」stub 是 POSIX-only 场景——Windows 上 SIGTERM 不可捕获,stub 永远演不了「扛住 SIGTERM」(w22-2 + w24-2 两条 lane,auto-restart.test.ts:688);② claude-native「occupied stable port」被接受 socket 的 ECONNRESET 未处理崩掉测试进程(w24-3)。已按「CI 红类几行级小修在当前 PR 顺手修」推了两个标注 commit:win32 skip + squatter 连接即销毁,两处均逐字镜像 ci: per-file zone-port bands for live suites + bounded TOCTOU retries (#3182/#3184/#3188) #3197 的对应修法,保证将来合并时 hunk 完全一致;另删了一处死代码空 catch(reserveZoneBase release,§⑤b 整洁标准)。
  6. 是否破坏缓存:不涉及(未触碰缓存/重试/游标/去重逻辑)。
  7. 是否改了设计方向:没有(src/ 零改动)。PR 里悬着的 product question(pinned 端口上的用户区占位者是否应豁免 own-lane 过滤)明确留给 owner;若要恢复 ride-by-default,是独立的 src/launcher.ts PR。
  8. 是否引入新配置:没有(复用既有 BILI_ZONE_PORT 与 native.attachPolicy)。

协调请求(owner 拍板项)

#3197 与 #3215 同为这场红风暴的修复,改同一对文件,不能按现状双双合并。对比:

建议二选一:(a) 先落 #3197(rebase + 剥 pages revert),#3215 的 B 侧双钉作为 follow-up 折入;(b)** 把 #3215 的增量折进 #3197、关掉 #3215(superseded-with-deltas-folded)**。无论哪种,最终只留一个交付载体。

顺带发现(不动手,等 product question 一起定):README quickstart 里「a deliberate bili start daemon is attached by default」(#1660 写入,#2877 后未更新)与新默认矛盾——一行级文档漂移,建议随上面的定论一并修。

判定:HOLD。 等 (a) owner 对 #3197/#3215 载体的决定,(b) 新 head fad1925ce 的 CI 转绿。两者齐了即可合。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 跟进:新 head fad1925ce 上 39/39 check-runs 全绿(12 test leg = ubuntu/windows × node22/24 × shard1/2/3 + static-gates ×4 + kernel-guard / pi-subagents-guard / registry e2e / docs-sync / config-surface-guard / version-guard / build-artifact / real-client lanes)。此前红的 3 条 windows leg(win22-2、win24-2 = auto-restart SIGTERM stub;win24-3 = claude-native ECONNRESET)在镜像 #3197 的两处修复后全部转绿——印证了「三处红均为 #3182 家族既有 flake、与本 PR diff 无关」的判定。

判定维持不变:机制成立,待你拍板合并载体(#3197 vs #3215,见上条八问的协调请求)+ 确认后合入。两个分支现在都是绿的,无论选哪个载体,另一侧的增量都合并不冲突(#3215 已逐字镜像 #3197 的两处 flake 修复,收敛成本最小)。

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI 固定端口/生命周期测试在共享 runner 上互相打架,test 分片随机变红(master 与所有 PR 均受影响)

1 participant