Skip to content

test(sandbox): 真实进程握手等内容完整再读,消除 credential/strict-env 两处 CI flake - #1934

Merged
deepcoldy merged 3 commits into
masterfrom
fix/proc-handshake-flake
Oct 15, 2026
Merged

deepcoldy merged 3 commits into
masterfrom
fix/proc-handshake-flake

Conversation

@deepcoldy

Copy link
Copy Markdown
Owner

改了什么 / 为什么

#1926 合入后的 master push CI 又暴露两处真实进程握手 flake(不同用例,但与 #1926 同族)。均为纯测试竞态、零生产码:被测子进程用 shell 重定向 / fs.writeFileSync(truncate-write,非 rename 原子)发布结果——先建空文件、字节稍后落地,测试侧轮询到文件「存在」就立刻消费内容,CI 高负载读到建文件与写入之间的空窗。

  1. test/credential-only-send-authority.test.ts(vitest 分片实红)
    waitForFile 一存在即 readFileSync 返回:expected '' to be 'unset'(outbox 路径那处同理)。改为等到内容非空再返回;调用方对具体值的 toBe 不变,错值/泄漏照旧确定性红,只越过空窗。

  2. test/strict-env-process.test.ts(bun-test 分片实红)
    report 先 vi.waitFor(existsSync)、再在 waitFor 外 JSON.parse(readFileSync),空文件 → SyntaxError: Unexpected EOF。把 parse 纳入 waitFor 谓词,等报告可解析再断言;key === false 仍可解析,由逐键断言精确捕获,不会把真隔离问题拖成超时。

其余文件里的 existsSync 等待只用于 ready/go 等信号文件、不读内容,不是本类 flake 源,未改动。

测试验证(真实 tmux/bwrap/bun 进程)

变异(把生产者放大成「建空文件 → sleep 0.5s → 再写内容」):

  • credential:还原旧 helper + 宽窗口 → 确定性复现 expected '' to be 'unset';保留新 helper + 宽窗口 → 绿;
  • strict:还原旧 report + 宽窗口 → bun 下 4 个 report 用例全 Unexpected EOF(含 CI 红的 zmx 用例);保留新 report + 宽窗口 → 7/7 绿。
  • 自然态两文件 vitest 连跑 10/10、bun 下 strict 7/7、credential 14/14 全绿;bun run build 通过;改动行无新增 tsc 错误(该测试文件 master 上既有一条 unused-import,与本 PR 无关,未顺带改)。

非回归:两处文件在 #1926 父提交(不含其改动)上行为一致;#1926 只动另外两个测试文件(vitest/bun 按文件独立运行时隔离)。

影响面:仅 2 个 linux 真实进程测试文件,不改生产代码,其它 CLI/后端/平台不受影响。

🤖 Generated with Claude Code

与 #1926 同族:被测子进程用 shell 重定向/truncate-write 发布结果,
先建空文件、字节稍后落地;测试侧轮询到文件「存在」即立刻消费内容,
CI 高负载读到建文件与写入之间的空窗。

- credential-only-send-authority: waitForFile 改为等到内容非空再返回
  (调用方仍对具体值 toBe,错值/泄漏照旧确定性红,只越过空窗);
  修 CI flake: expected 'unset'/outbox 路径,实得 ''。
- strict-env-process: report 把 JSON.parse 纳入 waitFor 谓词,等报告
  可解析再断言(key=false 可解析,仍由逐键断言精确捕获);
  修 bun-test flake: JSON.parse Unexpected EOF。

纯测试、零生产码。

Co-Authored-By: Claude Code <[email protected]>
@deepcoldy
deepcoldy merged commit 7cfa759 into master Oct 15, 2026
13 checks passed
@github-actions

Copy link
Copy Markdown

🚀 Released in v3.45.0

deepcoldy pushed a commit that referenced this pull request Nov 5, 2026
复审 P3:条目原写「新建 helper」会催生第三份逐字拷贝——strict-env-worker.integration.test.ts:30 与 session-env-worker.integration.test.ts:26 已有相同的 waitForJsonReport(注释引 #1934/#2386),credential-only-send-authority.test.ts:336 有纯文本变体 waitForFile;改为要求抽公共件时收编这三处并统一超时语义(null 返回 vs undefined/抛错)。补入同形竞态的 CI 咬红史对照(config-dir 注释、#1934、#2386)。校准三处行号:kimi 注释 46-51、worker-tmux-pane-launch 注释 71、kimi 竞态注释 16-17;补记已闭合的 codex-actor-launcher 85-86。仅文档。

Co-Authored-By: Claude Code <[email protected]>
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.

1 participant