Skip to content

Commit 8b775b4

Browse files
author
hzq
committed
Exercise late approval expiry after the run is parked
1 parent a32a887 commit 8b775b4

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎test/approval-scheduling.test.ts‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,10 @@ test('approval decisions arriving before the parking checkpoint are not lost', a
577577
}
578578
});
579579

580-
test('parked cancellations and denials expire remaining approvals without dispatching tools', async () => {
580+
test('parked cancellations and denials expire remaining approvals without dispatching tools', async (t) => {
581581
for (const decision of ['cancel', 'deny'] as const) {
582582
let writes = 0;
583-
const s = await setup(basicModel(), { maxActiveRuns: 1, approvalTimeoutMs: 80 });
583+
const s = await setup(basicModel(), { maxActiveRuns: 1, approvalTimeoutMs: 60_000 });
584584
try {
585585
const binding = installTool(s, 'guarded', true, async () => ({ value: ++writes }));
586586
s.store.publish('owner', makeBundle(agent({ id: 'agent/review', tools: [binding] })));
@@ -596,8 +596,19 @@ test('parked cancellations and denials expire remaining approvals without dispat
596596
() => s.kernel.decide(principal, run.id, action.id, 'approve'),
597597
/no longer pending/,
598598
);
599-
await sleep(90);
599+
// Replay the parked timer's wake after expiry, even if its cancellation raced an already queued callback.
600+
const scheduler = (
601+
s.kernel as unknown as { admission: { scheduleParked(id: string): boolean; pump(): void } }
602+
).admission;
603+
const now = t.mock.method(Date, 'now', () => action.expiresAt + 1);
604+
try {
605+
scheduler.scheduleParked(run.id);
606+
scheduler.pump();
607+
} finally {
608+
now.mock.restore();
609+
}
600610
assert.equal(s.store.run(run.id).status, final.status);
611+
assert.equal(writes, 0);
601612
} finally {
602613
await s.cleanup();
603614
}

0 commit comments

Comments
 (0)