Recognize remote computer state during exact warm handoff

This commit is contained in:
Dotta committed 2026-10-10 09:09:12 -05:00
1 parent 46fd97371a
commit 440482b396
2 files changed
+29 -2

No files matched your search

@@ -332,6 +332,7 @@ import {
nativeProviderUsageLimitFromEvent,
nativeSessionFailureSourceCode,
nativeProviderRecoveryEvidence,
verifyPriorRunnerdStateForSessionScope,
nativeSessionRecoveryProjection,
nativeGovernedWaitResult,
nativeConversationReplyResult,
@@ -13171,6 +13172,27 @@ describe("runnerd provider runtime wiring", () => {
}
});
it.each([
{ owner: true, status: "succeeded", expected: "retained_warm_runner" },
{ owner: false, status: "succeeded", expected: "terminal_state_indeterminate" },
{ owner: true, status: "running", expected: "active" },
])("requires exact idle ownership for remote computer state ($owner, $status)", async ({ owner, status, expected }) => {
const root = await mkdtemp(join(tmpdir(), "paperclip-remote-warm-state-"));
const prior = execution;
const current = { ...execution, binding: { ...execution.binding, runId: "next-computer-run" } };
const db = { select: () => ({ from: () => ({ where: () => ({ limit: async () => [
{ status, runnerProfileJson: { nativeExecutionInput: prior } },
] }) }) }) } as unknown as Db;
try {
expect(await verifyPriorRunnerdStateForSessionScope({
db, root, execution: current,
identity: { runId: prior.binding.runId, normalizedSessionId: prior.session.normalizedSessionId,
runnerInstanceId: "computer-runner", environmentLeaseId: "computer-lease" },
allowVerifiedBackup: false, remoteRunnerState: true, allowRetainedWarmRunner: owner,
})).toBe(expected);
} finally { await rm(root, { recursive: true, force: true }); }
});
it.each([
{ override: undefined, expected: "@openai/codex@0.160.0" },
{ override: "@openai/codex@0.159.0", expected: "@openai/codex@0.159.0" },
@@ -4275,13 +4275,14 @@ export function nativePreProviderRetryAfterCleanupStateIsSafe(input: {
}
}
async function verifyPriorRunnerdStateForSessionScope(input: {
export async function verifyPriorRunnerdStateForSessionScope(input: {
db: Db;
root: string;
identity: RunnerdDurableIdentity;
execution: NativeExecutionInput;
allowVerifiedBackup: boolean;
allowRetainedWarmRunner: boolean;
remoteRunnerState?: boolean;
}): Promise<PriorRunnerdStateVerification> {
let priorRun: {
status: string;
@@ -4335,7 +4336,7 @@ async function verifyPriorRunnerdStateForSessionScope(input: {
// there is intentionally no suspended failover backup yet. The exact
// idle in-memory session owner is the authority for this one case;
// after a restart that owner is absent and this remains fail-closed.
(input.allowVerifiedBackup && directLifecycle === "absent"))
((input.allowVerifiedBackup || input.remoteRunnerState) && directLifecycle === "absent"))
) {
return "retained_warm_runner";
}
@@ -4881,6 +4882,8 @@ async function migrateRunnerdStateRootForExecution(input: {
execution: input.execution,
allowVerifiedBackup: input.allowVerifiedBackup,
allowRetainedWarmRunner: input.allowRetainedWarmRunner,
remoteRunnerState: input.runnerExecutionTarget?.kind === "remote" &&
input.runnerExecutionTarget.transport === "computer",
});
if (
verification !== "verified" &&
@@ -4923,6 +4926,8 @@ async function migrateRunnerdStateRootForExecution(input: {
execution: input.execution,
allowVerifiedBackup: input.allowVerifiedBackup,
allowRetainedWarmRunner: input.allowRetainedWarmRunner,
remoteRunnerState: input.runnerExecutionTarget?.kind === "remote" &&
input.runnerExecutionTarget.transport === "computer",
});
if (
verification !== "verified" &&