Repository navigation
Description
摘要(Summary)
测试套件在 Windows 上不绿(Node v24.16.0、PowerShell、git 2.53)。在全新克隆上复现了两个相互独立的平台假设缺陷:
- tests/extensions/shared/setup-config.test.ts —— 「a reused PID does not impersonate the dead lock owner」必然超时(5 秒锁等待超时),因为死锁回收在 win32 上永远无法把 owner 判定为「已死」。
- tests/extensions/capabilities/index.test.ts —— 两个用例失败,因为一条正则断言硬编码了正斜杠路径,而 Windows 返回的是反斜杠。
CI 只跑 ubuntu-latest(.github/workflows/ci.yml:18),所以这两个缺陷在上游从未被观察到。OpenPI 在 package.json 声明 Node >=22.19.0 且没有平台限制——这是典型的「声明支持、但从未在 Windows 验证」。
环境(Environment)
- 操作系统:Windows(PowerShell / Git Bash)
- Node:v24.16.0
- 仓库:tt-a1i/openpi @ main(0b6f686),bun install --frozen-lockfile 成功(216 包,约 18s)
- bun run check 在干净克隆上通过(归一化行尾之后;见「相关 Fix npm install startup failure without ioredis #3」)
复现步骤(Reproduction)
node --test --experimental-strip-types tests/extensions/shared/setup-config.test.ts
node --test --experimental-strip-types tests/extensions/capabilities/index.test.ts
观察到的失败(Observed failures)
- setup-config ——「a reused PID does not impersonate the dead lock owner」(Windows 上必然超时)
测试位于 tests/extensions/shared/setup-config.test.ts:351:构造一个伪造的锁 owner,
pid: process.pid、processStartedAt: 1(processStartedAtVerified: true),期望
updateSetupConfig 回收这把死锁。Linux 上可以工作,因为 processLiveness 能证明启动时间不匹配;
Windows 上则必然超时:
✖ a reused PID does not impersonate the dead lock owner (5019.0915ms)
Error: Timed out waiting for another Pi process to finish updating <tmp>\my-pi-setup.json.
at lockTimeoutError (extensions/shared/setup-config.ts:745)
根因 —— extensions/shared/setup-config.ts:642-647:
const queryProcessStartedAt = (pid: number) =>
new Promise<number | undefined>((resolve) => {
if (process.platform === "win32") {
resolve(undefined); // ← Windows 上从不查询
return;
}
// ... 只有 POSIX 走 ps -o lstart=
});
processLiveness(setup-config.ts:730-737)随后对任何「启动时间未经验证」的 owner 返回
"unknown",于是 win32 上的死锁回收永远不会触发。后果:
- PID 复用防护(这个测试的全部意义所在)在 Windows 上从未被验证。
- 回收路径在 Windows 上实际是死代码——这是真实的功能缺口,不只是测试外观问题。
- capabilities —— 两个失败:正则硬编码正斜杠
tests/extensions/capabilities/index.test.ts:241:
assert.match(JSON.stringify(results), /skills\/subagents\/SKILL\.md/);
Windows 上的指引路径是 D:\works\openpi-analysis\skills\subagents\SKILL.md ——
断言里的 /skills/subagents/SKILL.md/ 永远匹配不到反斜杠:
AssertionError: The input did not match the regular expression /skills\/subagents\/SKILL\.md/
Input: '...D:\\works\\openpi-analysis\\skills\\subagents\\SKILL.md...'
同文件其余 8 个用例通过;功能本身没问题——是断言不具备路径可移植性。
根因(Root cause,共同)
两个缺陷都是 CI 从未覆盖的平台假设。.github/workflows/ci.yml:18 只跑 ubuntu-latest,
matrix 只换 Node 版本、不换操作系统。
影响(Impact)
- Windows 用户无法信任本地的 bun run test:失败不是他们的错,也不反映他们的改动。
- 死锁回收 / PID 复用防护在 Windows 上静默不工作(比显式 skip 更糟——崩溃进程遗留的锁可能永远不会被回收)。
- 任何 Windows 贡献者的 PR 都会被无关的红测试挡住,给首次贡献者增加摩擦。
修复方案(Proposed fixes)
方案 1(推荐):实现 win32 进程启动时间查询,保留判据
把 win32 的短路分支换成真实查询,例如 PowerShell
Get-Process -Id | Select-Object -ExpandProperty StartTime(用 execFile/spawn
调用并带超时,对齐 POSIX 分支的形态)。这样 Windows 上 processStartedAtVerified 为 true,
现有的存活判定与回收逻辑无需改动即可工作。补一个 mock 该查询路径的小单测。
代价:锁路径上多一个 PowerShell 依赖。setup-config 本来就会调用平台工具,可接受;但值得 review
失败模式(PowerShell 不存在 / 被策略限制)→ 回退为 undefined,保持现有的保守 "unknown" 兜底。
方案 2(替代):显式 skip 并在 win32 上注明缺口
接受「Windows 上以现有原语无法判定 PID 复用」,在 process.platform === "win32" 时 skip
该测试并加注释,同时在文档里记录该缺口(锁 token 是随机 UUID——叠加 PID 复用后残余风险很低)。
这是诚实的做法(显式 skip 好过必然超时),但回收路径仍未验证。
方案 3:归一化 capabilities 断言中的路径
在 capabilities/index.test.ts 里,从真实路径构造期望模式(pathToFileURL / 归一化分隔符),
而不是硬编码 / 分隔的正则。小而机械,与方案 1/2 相互独立。
验收标准(Acceptance criteria)
- Windows(Node ≥ 22.19)上:node --test --experimental-strip-types tests/extensions/shared/setup-config.test.ts 全绿,或 PID 复用用例在 win32 上显式 skip 并链接到本 issue。
- Windows 上:node --test --experimental-strip-types tests/extensions/capabilities/index.test.ts 全绿(不再有依赖反斜杠的断言)。
- 若选方案 1:win32 查询有测试覆盖(mock),且查询不可用时仍走保守的 unknown 兜底。
- (可选,价值更高)CI 增加 windows-latest 测试任务,让这类缺陷不再回归。
相关(Related,另开 issue,不阻塞)
- 缺少 .gitattributes → 在 core.autocrlf=true 的 Windows 环境下,bun run format:check 会在每个文件上失败。在仓库根加 .gitattributes(* text=auto eol=lf)即可修复首次贡献者的第一天体验。
- 全量套件时长:bun run test 本地 15+ 分钟(锁用例每个约 5-6s 是设计使然;Linux CI 预算 20 分钟)。建议在文档里给出按目录跑测试的方式,供本地循环使用。
补充背景(Additional context)
复现基于全新克隆;同一台机器上 bun run check 全绿(LF 归一化之后)——这些失败只属于测试套件,不属于环境。
Activity
qwertvgty commentedon Aug 28, 2026
I can take this one.
I’ll start with the Windows-specific fixes described here:
win32process start-time query for the setup config lock liveness check, while preserving thecurrent conservative
unknownfallback when the query fails or times out;/;I’ll keep the lock protocol unchanged and avoid widening the scope beyond these Windows portability failures. After
that I’ll run the two reproduction commands plus the normal check/test commands where practical.
Please let me know if anyone is already working on it.
liwen-aaa commentedon Aug 28, 2026
Thanks for picking this up — the plan looks right to me. I'm the reporter and not working on it myself, so it's yours (assignment is up to the maintainers).
Keeping the lock protocol unchanged and failing closed when the query errors or times out is the key constraint; the rest of your scoping looks good.
I'm on Windows x64 and hit both failures there, so ping me when you have a branch and I'll verify it on real hardware.