fix(pi): settle delayed compact ownership
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
PiWorkerPool,
|
||||
type PiConversationWorker,
|
||||
type PiWorkerOpenResult,
|
||||
type PiWorkerPoolEvent,
|
||||
} from '../../electron/coding-runtime/pi/worker-pool';
|
||||
import type { PiProcessError } from '../../electron/coding-runtime/pi/process-errors';
|
||||
import { PiProcessError as PiProcessFailure } from '../../electron/coding-runtime/pi/process-errors';
|
||||
@@ -224,6 +225,34 @@ describe('Pi worker pool', () => {
|
||||
expect(pool.getResilienceProofDiagnostics().runs).toEqual({ active: 0, waiting: 0 });
|
||||
});
|
||||
|
||||
it('settles compact from its authoritative RPC success without agent_settled', async () => {
|
||||
const worker = new FakeWorker('worker-target');
|
||||
const events: PiWorkerPoolEvent[] = [];
|
||||
const pool = new PiWorkerPool({
|
||||
maxIdle: 2,
|
||||
openWorker: async () => ({
|
||||
worker,
|
||||
session: { piSessionId: 'session-target', sessionKey: 'key-target' },
|
||||
}),
|
||||
});
|
||||
pool.subscribe((event) => events.push(event));
|
||||
await pool.prepare(conversation('conversation-target'));
|
||||
|
||||
const ticket = pool.startTopLevel({
|
||||
conversationId: 'conversation-target',
|
||||
runId: 'run-compact-success',
|
||||
command: { type: 'compact' },
|
||||
});
|
||||
|
||||
await expect(ticket.accepted).resolves.toMatchObject({ success: true });
|
||||
expect(pool.getActiveRun('conversation-target')).toBeNull();
|
||||
expect(pool.getState('conversation-target')?.state).toBe('idle');
|
||||
expect(events).toContainEqual(expect.objectContaining({
|
||||
type: 'top-level.settled',
|
||||
runId: 'run-compact-success',
|
||||
}));
|
||||
});
|
||||
|
||||
it('treats agent settlement as authoritative when the RPC confirmation is still pending', async () => {
|
||||
const worker = new FakeWorker('worker-target');
|
||||
const pool = new PiWorkerPool({
|
||||
|
||||
Reference in New Issue
Block a user