Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

test(maker-core): 等 PI 子进程落盘 pid 再断言 SIGTERM 回收

Kirozeng106b4912d85c
diff --git a/packages/maker-core/src/agents/pi/__tests__/cindySubagentRunner.test.ts b/packages/maker-core/src/agents/pi/__tests__/cindySubagentRunner.test.ts
index 5dad5b390c..be39f9c9a4 100644
--- a/packages/maker-core/src/agents/pi/__tests__/cindySubagentRunner.test.ts
+++ b/packages/maker-core/src/agents/pi/__tests__/cindySubagentRunner.test.ts
@@ -1595,7 +1595,24 @@ describe('Cindy durable PI Subagent runner', () => {
undefined,
'the runner to launch its hanging child',
);
- const childPid = Number((await readFile(fixture.pidsFile, 'utf8')).trim().split('\n')[0]);
+ // The runner publishes `running` once the lane dispatches the task, but
+ // the freshly spawned child has not necessarily booted far enough to
+ // have recorded its pid yet — the same spawn/write window that
+ // `gateFinishOnPidCount` closes for the multi-lane cases. Wait for the
+ // pid to land on disk instead of racing the first read, or this flakes
+ // as an ENOENT under a loaded CI runner.
+ const childPid = await waitFor(
+ async () => {
+ try {
+ const pid = Number((await readFile(fixture.pidsFile, 'utf8')).trim().split('\n')[0]);
+ return Number.isSafeInteger(pid) ? pid : null;
+ } catch {
+ return null;
+ }
+ },
+ undefined,
+ 'the hanging child to record its pid',
+ );
expect(Number.isSafeInteger(childPid)).toBe(true);
process.kill(fixture.child.pid!, 'SIGTERM');