fix(antigravity): a startup retry after a never-opened candidate session starts fresh

After a candidate session.open failed, each same-run startup retry met the
first launch's provider state in the run-scoped runner root (lifecycle
closed, no identity, no turn) and runnerd refused it: "ACPX candidate
cannot adopt a prior durable runner activation". Every attempt and every
follow-up run ended that way instead of reporting the real cause.

Before a local same-run bootstrap, the server now retires that root only
when it provably never opened a provider session (this run's identity,
no provider identity, no turn, no pending events, requests or calls,
provider exit confirmed, no live runner process). Any root that opened a
session is kept and the runner's candidate gate still refuses it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DottaandClaude Opus 5.5 committed 2026-11-24 13:21:09 -06:00
1 parent 4f26416e1c
commit 1b3fcb46ff
2 files changed
+98 -3

No files matched your search

@@ -6678,6 +6678,9 @@ async function migrateRunnerdStateRootForExecution(input: {
return;
}
if (durableIdentityMatchesExecution(identity, input.execution)) {
if (!input.restartRecovery && !input.retainedWarmOwnerRunId
&& (!input.runnerExecutionTarget || input.runnerExecutionTarget.kind === "local")
&& await retireNeverOpenedCandidateRunRoot(input.execution, scoped)) return;
if (!input.restartRecovery && !input.retainedWarmOwnerRunId && input.bootstrapRetryLeaseOwner
&& input.runnerExecutionTarget?.kind === "remote"
&& runnerdAuthorityLifecycle(scoped, identity) === "absent"
@@ -7172,6 +7175,34 @@ export function prepareNativeSessionOpenTimeoutRetry(execution: NativeExecutionI
return true;
}
/**
* The pending Antigravity candidate's runner refuses every prior activation in
* its run-scoped root. A same-run startup retry after a session.open that never
* recorded a provider identity has nothing to adopt, so its root is retired and
* the retry bootstraps fresh. A root whose provider state recorded an identity,
* a turn, or anything unreadable is kept, and the runner's gate refuses it.
*/
export async function retireNeverOpenedCandidateRunRoot(execution: NativeExecutionInput, root: string): Promise<boolean> {
if (!antigravityUsesRunScopedState(execution) || !isSafeNativeStateDirectory(root)) return false;
const identity = readRunnerdDurableIdentity(root);
if (!durableIdentityMatchesExecution(identity, execution)) return false;
let state: Record<string, unknown>;
try {
state = record(JSON.parse(readBoundedNativeFile(resolve(root, "runner", "acpx-provider-state.json"),
NATIVE_RUNNER_STATE_MAX_BYTES, "native_runner_checkpoint_invalid").toString("utf8")));
} catch {
return false;
}
const empty = (value: unknown) => value == null || (Array.isArray(value) ? value.length === 0 : Object.keys(record(value)).length === 0);
if (state.schema !== ACPX_PROVIDER_STATE_SCHEMA || !["prepared", "closed"].includes(String(state.lifecycle))
|| state.identity !== null || state.activeTurnId !== null || state.providerExitUnconfirmed !== false
|| state.semanticResult != null || !empty(state.pendingEvents) || !empty(state.pendingRuntimeRequests)
|| !empty(state.openSemanticCalls)) return false;
if (!(await noLocalRunnerProcessForRun(execution.binding.runId))) return false;
quarantineRunnerdStateRoot(root, "identity_indeterminate");
return true;
}
export function runnerdStateProvesIncompleteBootstrap(
root: string,
options: { localProcesses: boolean } = { localProcesses: false },