fix: preserve Pi projection continuity
This commit is contained in:
1 parent
3599064bc4
commit
4bbe3f8b1e
7 files changed
+248
-9
No files matched your search
@@ -10,6 +10,10 @@ import {
|
||||
reduceConversationPatch,
|
||||
} from '../../electron/coding-runtime/conversation-reducer';
|
||||
import { PiEventProjector } from '../../electron/coding-runtime/pi/event-projector';
|
||||
import {
|
||||
PI_084_AUTO_RETRY_FAILURE_EVENTS,
|
||||
PI_084_SUMMARIZATION_RETRY_FAILURE_EVENTS,
|
||||
} from '../fixtures/pi-0.84.2-projector-fixtures';
|
||||
|
||||
function emptySnapshot(): ConversationSnapshot {
|
||||
return {
|
||||
@@ -312,6 +316,67 @@ describe('Pi event projector', () => {
|
||||
expect(snapshot.queue.items).toEqual([]);
|
||||
});
|
||||
|
||||
it('preserves a redacted failed auto-retry terminal through agent_settled', async () => {
|
||||
const ids = ['retry-boundary-a'];
|
||||
const projector = new PiEventProjector({ createId: () => ids.shift() as string });
|
||||
let snapshot = emptySnapshot();
|
||||
|
||||
for (const event of PI_084_AUTO_RETRY_FAILURE_EVENTS) {
|
||||
snapshot = apply(snapshot, await projector.project(snapshot, structuredClone(event)));
|
||||
}
|
||||
|
||||
expect(snapshot.run).toMatchObject({
|
||||
status: 'idle',
|
||||
terminalReason: 'failed',
|
||||
error: {
|
||||
code: 'CODING_RUNTIME_START_FAILED',
|
||||
recoverable: true,
|
||||
},
|
||||
});
|
||||
expect(JSON.stringify(snapshot)).not.toContain('sensitive');
|
||||
expect(projector.getDiagnostics()).not.toContainEqual(expect.objectContaining({
|
||||
eventType: 'auto_retry_end',
|
||||
}));
|
||||
});
|
||||
|
||||
it('maps all summary-retry events and keeps exhausted compaction failure redacted', async () => {
|
||||
const ids = ['compaction-a', 'summary-retry-boundary-a'];
|
||||
const projector = new PiEventProjector({ createId: () => ids.shift() as string });
|
||||
let snapshot = emptySnapshot();
|
||||
|
||||
for (const event of PI_084_SUMMARIZATION_RETRY_FAILURE_EVENTS) {
|
||||
snapshot = apply(snapshot, await projector.project(snapshot, structuredClone(event)));
|
||||
if (event.type === 'summarization_retry_scheduled') {
|
||||
expect(snapshot.run).toMatchObject({
|
||||
status: 'retrying',
|
||||
retry: { attempt: 1, delayMs: 500 },
|
||||
});
|
||||
}
|
||||
if (event.type === 'summarization_retry_attempt_start'
|
||||
|| event.type === 'summarization_retry_finished') {
|
||||
expect(snapshot.run.status).toBe('compacting');
|
||||
expect(snapshot.run.retry).toBeUndefined();
|
||||
}
|
||||
}
|
||||
|
||||
expect(snapshot.nodes).toContainEqual(expect.objectContaining({
|
||||
kind: 'boundary',
|
||||
id: 'summary-retry-boundary-a',
|
||||
boundary: 'retry',
|
||||
attempt: 1,
|
||||
delayMs: 500,
|
||||
}));
|
||||
expect(snapshot.run).toMatchObject({
|
||||
status: 'idle',
|
||||
terminalReason: 'failed',
|
||||
error: { code: 'CODING_RUNTIME_START_FAILED', recoverable: true },
|
||||
});
|
||||
expect(JSON.stringify(snapshot)).not.toContain('sensitive');
|
||||
expect(projector.getDiagnostics()).not.toContainEqual(expect.objectContaining({
|
||||
eventType: expect.stringMatching(/^summarization_retry_/),
|
||||
}));
|
||||
});
|
||||
|
||||
it('reconciles the optimistic user node and projects image bytes through an attachment hook', async () => {
|
||||
const projectedImages: unknown[] = [];
|
||||
const projector = new PiEventProjector({
|
||||
|
||||
Reference in new issue
Block a user