fix(pi): settle delayed compact ownership

This commit is contained in:
2026-08-26 09:41:25 +08:00
parent f5e6a04c7d
commit 9f05e2d7e1
12 changed files with 334 additions and 25 deletions

View File

@@ -510,8 +510,8 @@ describe('Pi Conversation runtime', () => {
expect((await runtime.getSnapshot(right.id)).run.status).toBe('error');
expect(activeBackgroundLeases).toBe(0);
await runtime.compact(right.id);
expect((await runtime.getSnapshot(right.id)).run.status).toBe('compacting');
expect(activeBackgroundLeases).toBe(1);
await expect.poll(async () => (await runtime.getSnapshot(right.id)).run.status).toBe('idle');
expect(activeBackgroundLeases).toBe(0);
expect(workers.get(right.id)!.requests.at(-1)).toEqual({ type: 'compact' });
expect((await runtime.getSnapshot(left.id)).run.status).toBe('idle');
const rightDurable = {
@@ -529,7 +529,7 @@ describe('Pi Conversation runtime', () => {
durableSessions.set(right.id, rightDurable);
workers.get(right.id)!.setSessionData(rightDurable);
workers.get(right.id)!.emit({ type: 'agent_end' });
expect((await runtime.getSnapshot(right.id)).run.status).toBe('compacting');
expect((await runtime.getSnapshot(right.id)).run.status).toBe('idle');
workers.get(right.id)!.emit({ type: 'agent_settled' });
await expect.poll(async () => (await runtime.getSnapshot(right.id)).run.status).toBe('idle');
expect(activeBackgroundLeases).toBe(0);