Repository navigation
test(credential-only-relay): daemon 重启用例在轮询判定式里取样,不再在轮询外二次读 pid marker - #2141
Merged
Merged
Conversation
in-flight chat-scope 用例在 vi.waitFor 确认 turn 身份之后,又在轮询外同步读了一次 sendTurnIdentity()。ordinary 分支要求 .botmux-cli-pids/ 目录条目数恰好为 1, worker 改写 marker 时旁边会短暂出现 <pid>.lock 和原子写的 tmp,这次无重试的读取 落进窗口就得到 'absent'(bun-test 偶发红在 :244)。 - during / afterRestore 直接取 waitFor 判定式里通过的那次采样,不再追加读取 - ordinary 分支只把纯数字(pid)命名的条目当 marker,与生产按 pid 精确查找一致; 否则首个 marker 落盘前只有 lock 文件时,会把 lock 读成「无 turn 的 marker」 Closes #2138 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 22, 2026 05:12
Owner
Author
|
已合并 →
follow-up(不阻断,留作后续):
未做:发版、部署。 |
This was referenced Oct 22, 2026
Merged
|
🚀 Released in v3.50.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改了什么
test/credential-only-relay-lifecycle.integration.test.ts的用例「in-flight chat-scope turn across a daemon restart」,只改测试,不动src/。during/afterRestore直接取vi.waitFor判定式里通过的那一次采样(vi.waitFor返回回调的返回值,vitest 与test/bun-test-shim.ts一致),不再在waitFor通过后追加一次没有重试的同步读取。<pid>.lock和原子写的<pid>.<pid>.<hex>.tmp。生产侧(src/core/session-marker.ts)本来就是按join(markersDir, String(pid))精确查找。为什么
issue #2138:bun-test 偶发红在
:244(expect(ordinary.during).toBe('om_turn_live'),实际是"absent")。waitFor确认身份正确之后,又在轮询外读了一次lab.sendTurnIdentity()。.botmux-cli-pids/条目数恰好为 1。worker 每次改写 marker(writeCliPidMarker→withFileLockSync+atomicWriteFileSync)时,旁边都会短暂出现<pid>.lock和 tmp 文件,条目数变成 2 或 3。这次读取落进这个窗口,就会返回absent,跟 turn 还在不在无关。第 2 点是改第 1 点时一起发现的:把
afterRestore改成取「第一次非 absent 的采样」之后,successor 首次写 marker 前目录里只有<pid>.lock,条目数正好为 1,lock 的 JSON 内容会被当成「没有 turn 的 marker」读出null。现在的期望值恰好也是null,所以不会变红,但观测对象不对。只认 pid 命名的条目后,这个窗口读出来是absent,会继续轮询。两处都是等确定条件,没有加固定 sleep。
影响面
验证
本地(
TMPDIR=/var/tmp/bmxt,bun 1.4.2,只跑改到的文件;全量交给 CI):vitest run test/credential-only-relay-lifecycle.integration.test.ts test/test-hygiene.test.ts:2 files / 29 tests passedbun test test/credential-only-relay-lifecycle.integration.test.ts:3 pass / 0 failbun test … -t "in-flight",8 路并发 × 3 轮,24/24 通过复现与变异证据:注入用的测试副本和
src/worker.ts变异都在本地临时生效,跑完已还原,没有提交。vitest 和 bun 各跑一次,两边结果一致。:244(行号因注入偏移为 246):Expected "om_turn_live",Received "absent",与 CI 一致absent,waitFor 超时publishSandboxRelayCapability写出的 outbox capability 去掉turnIdduringwaitFor 超时,Received nullwriteCliPidMarker写turnId: nullduringwaitFor 超时,Received nullturnId: capability.turnId ?? 'om_stale'credentialOnly.afterRestore与 ordinary 不一致(Expected null,Received "om_stale")Closes #2138
🤖 Generated with Claude Code