fix: close Pi subagent review gaps
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user