Allow native Pi cleanup to finish before checkpointing

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-21 16:26:34 -05:00
1 parent 6e7076cc0a
commit a433748a12
2 files changed
+9 -7

No files matched your search

@@ -1653,9 +1653,11 @@ it.each([
const { preparationDeadline, closeDeadline } = runnerdRecoveryInternals.runnerCloseDeadlines( const { preparationDeadline, closeDeadline } = runnerdRecoveryInternals.runnerCloseDeadlines(
Date.now(), runnerdRecoveryInternals.runnerCloseGraceMs(options), Date.now(), runnerdRecoveryInternals.runnerCloseGraceMs(options),
); );
// The retained restart failure spent 5.2s stopping idle Pi before its // Native Pi allows thirty seconds for snapshot cleanup and five seconds
// remote drain acknowledgement crossed the next command round trip. // for its lifetime fence before the drain acknowledgement round trip.
await vi.advanceTimersByTimeAsync(5_200); const stopMs = options.provider === "acpx" && options.acpxAgent === "pi"
&& options.closeGraceMs === undefined ? 35_200 : 5_200;
await vi.advanceTimersByTimeAsync(stopMs);
const commands: { commandId: string; status: string; result?: unknown }[] = []; const commands: { commandId: string; status: string; result?: unknown }[] = [];
const result = runnerdRecoveryInternals.awaitProviderDrainBarrier({ const result = runnerdRecoveryInternals.awaitProviderDrainBarrier({
readProviderState: () => null, readProviderState: () => null,
@@ -1675,7 +1677,7 @@ it.each([
await vi.advanceTimersByTimeAsync(5_000); await vi.advanceTimersByTimeAsync(5_000);
expect(await result).toBe(drained); expect(await result).toBe(drained);
expect(closeDeadline - preparationDeadline).toBeLessThanOrEqual(2_500); expect(closeDeadline - preparationDeadline).toBeLessThanOrEqual(2_500);
expect(runnerdRecoveryInternals.runnerCloseGraceMs(options)).toBeLessThanOrEqual(15_000); expect(runnerdRecoveryInternals.runnerCloseGraceMs(options)).toBeLessThanOrEqual(45_000);
} finally { vi.useRealTimers(); } } finally { vi.useRealTimers(); }
}); });
@@ -850,11 +850,11 @@ async function awaitRunnerSuspensionBarrier(input: {
} }
function runnerCloseGraceMs(options: Pick<CapabilityRunnerdCodexTransportOptions, "provider" | "acpxAgent" | "closeGraceMs">): number { function runnerCloseGraceMs(options: Pick<CapabilityRunnerdCodexTransportOptions, "provider" | "acpxAgent" | "closeGraceMs">): number {
// Idle Pi retirement may consume its five-second RPC stop window. Keep a // Native Pi retirement allows thirty seconds for snapshot cleanup and five
// separate five-second drain round trip and the bounded suspension reserve. // for its lifetime fence. Keep a drain round trip and suspension reserve too.
// Explicit caller deadlines remain authoritative; all settlement proofs stay // Explicit caller deadlines remain authoritative; all settlement proofs stay
// mandatory even when the provider already completed its task. // mandatory even when the provider already completed its task.
return options.closeGraceMs ?? (options.provider === "acpx" && options.acpxAgent === "pi" ? 15_000 : 10_000); return options.closeGraceMs ?? (options.provider === "acpx" && options.acpxAgent === "pi" ? 45_000 : 10_000);
} }
function runnerCloseDeadlines( function runnerCloseDeadlines(