fix: close Pi subagent review gaps

This commit is contained in:
2026-08-23 13:14:03 +08:00
parent f1c7cd8ad4
commit 3de85d61d7
9 changed files with 234 additions and 34 deletions

View File

@@ -213,7 +213,13 @@ describe('Pi subagent scheduler', () => {
const processBudget = new PiProcessBudget(2);
const firstParent = await processBudget.acquire();
const idleParent = await processBudget.acquire();
let waitingParentSettled = false;
const waitingParent = processBudget.acquire().then((lease) => {
waitingParentSettled = true;
return lease;
});
let reclaimed = 0;
let childRanBeforeWaitingParent = false;
const scheduler = new PiSubagentScheduler({
processBudget,
reclaimProcessCapacity: async () => {
@@ -223,7 +229,10 @@ describe('Pi subagent scheduler', () => {
},
openChild: async (input) => ({
id: input.taskId,
async run() { return { summary: 'done' }; },
async run() {
childRanBeforeWaitingParent = !waitingParentSettled;
return { summary: 'done' };
},
async stop() {},
}),
});
@@ -234,8 +243,12 @@ describe('Pi subagent scheduler', () => {
details: { tasks: [{ status: 'complete' }] },
});
expect(reclaimed).toBe(1);
expect(processBudget.activeCount).toBe(1);
expect(childRanBeforeWaitingParent).toBe(true);
const waitingParentLease = await waitingParent;
expect(processBudget.activeCount).toBe(2);
waitingParentLease.release();
firstParent.release();
expect(processBudget.activeCount).toBe(0);
await scheduler.close();
});
});