mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-30 09:05:15 +01:00
fix(runner): continue in a fresh provider session after a confirmed lost plugin checkpoint (#23007)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - Paperclip Runner agents can run on plugin task environments that
keep a warm Runner between turns.
> - PR #22973 changed one recovery case. When the plugin confirms that
the prior task stopped and kept no session state, Core now retires the
settled prior owner instead of refusing the follow-up.
> - The follow-up still asked the new Runner to resume the old provider
session. The new Runner has no saved state for it, so the run failed
with `native_session_recovery_failed: ... PRP provider resume state is
unavailable`.
> - A retry reads the same empty state, so the task cannot continue.
Recovery must work without a person.
> - This pull request lets that follow-up replace the provider session
only when the Runner positively proves the saved state is gone. It
continues in a fresh provider session and records a continuity break.
> - The benefit is that the task continues, and Cloud readiness `verify
/ Verify Paperclip Runner (server-integration)` passes again, which
unblocks the Core Docker image and staging deploys.
## Linked Issues or Issue Description
Refs #22973.
**What happened?**
On master, four tests failed on every run in the Cloud readiness
`server-integration` lane: the "missing state" case of
`plugin-runner-eviction-{claude,codex}-{abrupt,retired}.integration.test.ts`
("4 failed | 439 passed"). The follow-up run failed with
`native_session_recovery_failed:
NativeRunnerResumeStateUnavailableError: PRP provider resume state is
unavailable`. A temporary revert of 71d7f86293 (#22973) made the case
pass again.
**Expected behavior**
When the plugin confirms that the prior task stopped and has no session
state, the follow-up run continues. This is the stated intent of #22973
("retires cleanly into `continuity-breaks` so the new run starts
fresh").
**Steps to reproduce**
Run `pnpm --filter @paperclipai/server exec vitest run
src/services/native-runtime/plugin-runner-eviction-codex-abrupt.integration.test.ts
-t "missing state"` on master.
## What Changed
- `server/src/services/native-runtime/native-session-executor.ts`: state
migration now returns a typed result `{ binding, pluginCheckpointRetired
}`. When Core retired the prior owner because the plugin confirmed a
lost checkpoint, the executor passes
`replaceAfterConfirmedProviderStateLoss` to the runtime.
`providerSessionReplaceableAfterStateLoss` keeps this off for a session
with an unfinished goal and for Antigravity while its release is
pending.
- `packages/paperclip-runner/src/native-session-runtime.ts`: with that
option, the runtime replaces the provider session only on the Runner's
positive proof: `PROVIDER_STATE_INCOMPATIBLE` with
`resumeStateUnavailable`, no restart interruption, no active turn, and
no pending runtime request. The governed-wait path now uses the same
proof (`runnerProvedSavedStateGone`). Every other recovery failure keeps
the named refusal. The checkpoint's saved recovery policy is not
changed.
- `server/src/__tests__/helpers/plugin-runner-eviction.ts`: the "missing
state" case encoded the behavior before #22973 (a refusal). It now
expects the follow-up to succeed. It also checks that Core read the
source checkpoint once and got no state, that the prior owner was
retired, and that a provider continuity break was logged. All other
modes keep their assertions.
- New unit cases: the runtime replaces on the positive proof, and
refuses when Core did not confirm, when the Runner did not prove state
loss, for an unclassified failure, with a turn in flight, and with a
pending runtime request. The executor keeps same-session recovery for
unfinished goals and Antigravity.
## Verification
- Red: with only the test change, the codex abrupt "missing state" case
fails with `NativeProviderStateIncompatibleError:
native_session_recovery_failed: NativeRunnerResumeStateUnavailableError:
PRP provider resume state is unavailable`.
- Green: with the fix, all four files pass locally, one file at a time:
codex-abrupt 10/10, codex-retired 11/11, claude-abrupt 10/10,
claude-retired 11/11.
- `native-session-executor.test.ts -t "plugin checkpoint"`: 94 passed
(includes the #22973 unit cases).
- Each new guard was shown red by removing it: dropping the Runner proof
fails 4 runtime refusal cases; dropping the goal check or the
Antigravity check fails the executor guard case.
- `native-session-runtime.test.ts`: 310 passed.
`native-session-executor.test.ts -t "plugin checkpoint|unfinished
goal"`: 95 passed.
- `tsc --noEmit` for `packages/paperclip-runner` and `server`: clean.
## Risks
- Behavior change is limited to one case: the plugin confirmed the task
stopped with no session state, Core retired its settled owner, and the
Runner proved it holds no saved state with nothing in flight. Such a
follow-up now loses the earlier provider conversation context instead of
failing. It records a continuity break in the run log and trace.
Transient or in-flight recovery failures still refuse.
- Sessions with an unfinished goal and Antigravity sessions keep failing
closed, as before.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`), via Claude Code with tool use
(shell, file edits).
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e45340c0cf
commit
2f9dc4a4c6
5 files changed
+158
-15
No files matched your search
@@ -7089,6 +7089,90 @@ describe("executeNativeSession recovery", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("a follow-up whose previous Runner Core proved stopped without saved state", () => {
|
||||
const sameSessionCheckpoint = (): PersistedNativeSession => ({
|
||||
backendKind: "mock", driverKind: "codex_app_server", sessionId: "driver-gone", identity,
|
||||
providerSessionId: "provider-gone", providerRecoveryPolicy: "same_session_only",
|
||||
cursor: "4", semanticResult: null, terminal: null, activeTurnId: null, terminalTurns: [],
|
||||
pendingRuntimeRequests: [], dispositionOnlyRecoveryConsumed: false, dispositionOnlyRecoveryTurnId: null,
|
||||
lineage: [],
|
||||
});
|
||||
const stateUnavailable: NativeSessionRecoveryResult = {
|
||||
recovered: false, failureClass: PROVIDER_STATE_INCOMPATIBLE, resumeStateUnavailable: true,
|
||||
reason: "Error: NativeRunnerResumeStateUnavailableError: PRP provider resume state is unavailable",
|
||||
};
|
||||
function harness(options: {
|
||||
confirmed: boolean;
|
||||
checkpoint?: PersistedNativeSession;
|
||||
recovery?: NativeSessionRecoveryResult;
|
||||
}) {
|
||||
const startTurn = vi.fn<NativeSession["startTurn"]>(async () => ({ turnId: "turn-fresh" }));
|
||||
const replacementSession: NativeSession = {
|
||||
identity: () => identity,
|
||||
capabilities: async () => ({ resume: true, typedEvents: true, steering: false, interruption: true, structuredResult: true }),
|
||||
async *events() { yield runnerEvent(1, "turn.completed"); },
|
||||
startTurn,
|
||||
result: async () => ({ result, terminal, turnId: "turn-fresh" }),
|
||||
snapshot: async () => ({ ...sameSessionCheckpoint(), sessionId: "driver-fresh", providerSessionId: "provider-fresh" }),
|
||||
close: async () => {},
|
||||
};
|
||||
const openReplacementSession = vi.fn(async () => replacementSession);
|
||||
const backend: NativeSessionBackend = {
|
||||
descriptor: async () => ({ kind: "mock", name: "confirmed-state-loss", version: "1",
|
||||
capabilities: { resume: true, typedEvents: true, steering: false, interruption: true, structuredResult: true } }),
|
||||
openSession: vi.fn(async () => { throw new Error("replacement seam must be used"); }),
|
||||
openReplacementSession,
|
||||
recoverSession: vi.fn(async () => options.recovery ?? stateUnavailable),
|
||||
};
|
||||
const events: PrpEvent[] = [];
|
||||
const controlPlane: ControlPlanePort = {
|
||||
openRun: vi.fn(async () => undefined),
|
||||
loadSessionCheckpoint: async () => structuredClone(options.checkpoint ?? sameSessionCheckpoint()),
|
||||
checkpointSession: async () => {},
|
||||
async appendEvent(event) {
|
||||
events.push(structuredClone(event as PrpEvent));
|
||||
return { cursor: events.length, highestContiguousSourceSeq: highestContiguous(events), disposition: "committed" };
|
||||
},
|
||||
replayEvents: async () => ({ events: [], highestContiguousSourceSeq: 0 }),
|
||||
completeRun: async () => {},
|
||||
};
|
||||
const onContinuityBreak = vi.fn(async () => undefined);
|
||||
const run = () => executeNativeSession({
|
||||
input, backend, controlPlane, onContinuityBreak,
|
||||
replaceAfterConfirmedProviderStateLoss: options.confirmed,
|
||||
runnerInstanceId: "runner-recovery", controlPlaneInstanceId: "control-recovery",
|
||||
});
|
||||
return { run, startTurn, openReplacementSession, onContinuityBreak };
|
||||
}
|
||||
|
||||
it("continues in a fresh provider session and records the continuity break", async () => {
|
||||
const h = harness({ confirmed: true });
|
||||
await expect(h.run()).resolves.toMatchObject({ providerSessionId: "provider-fresh" });
|
||||
expect(h.openReplacementSession).toHaveBeenCalledOnce();
|
||||
expect(h.startTurn).toHaveBeenCalledOnce();
|
||||
expect(h.onContinuityBreak).toHaveBeenCalledWith(expect.objectContaining({
|
||||
reason: expect.stringContaining("saved provider state is unavailable"),
|
||||
previousProviderSessionId: "provider-gone", replacementProviderSessionId: "provider-fresh",
|
||||
}));
|
||||
});
|
||||
|
||||
it.each([
|
||||
["Core did not prove the previous Runner stopped without state", { confirmed: false }],
|
||||
["the Runner did not prove the saved state is gone", { confirmed: true, recovery: {
|
||||
recovered: false as const, failureClass: PROVIDER_STATE_INCOMPATIBLE, reason: "saved launch profile changed" } }],
|
||||
["the recovery failure is unclassified", { confirmed: true, recovery: {
|
||||
recovered: false as const, reason: "provider transport closed" } }],
|
||||
["a provider turn was in flight", { confirmed: true, checkpoint: { ...sameSessionCheckpoint(), activeTurnId: "turn-open" } }],
|
||||
["a runtime request was pending", { confirmed: true, checkpoint: { ...sameSessionCheckpoint(),
|
||||
pendingRuntimeRequests: [{ requestId: "request-open" } as never] } }],
|
||||
] as const)("refuses to replace the provider session when %s", async (_label, options) => {
|
||||
const h = harness(options as Parameters<typeof harness>[0]);
|
||||
await expect(h.run()).rejects.toThrow("native_session_recovery_failed");
|
||||
expect(h.openReplacementSession).not.toHaveBeenCalled();
|
||||
expect(h.startTurn).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
// A remote workspace epoch was abandoned, so the run was assigned a new
|
||||
// sibling root while its checkpoint still names the old one. A checkpoint
|
||||
// that requires the same session (an unfinished goal) ends with the
|
||||
|
||||
@@ -395,6 +395,7 @@ export interface ExecuteNativeSessionOptions {
|
||||
onSessionQuarantined?: (reason: string) => Promise<void> | void;
|
||||
existingSession?: NativeSession;
|
||||
persistedSession?: PersistedNativeSession | null;
|
||||
replaceAfterConfirmedProviderStateLoss?: boolean;
|
||||
keepSessionOpen?: boolean;
|
||||
/** Apply a structured session-goal control instead of starting an ordinary turn. */
|
||||
sessionGoalControl?: NativeSessionGoalControl | null;
|
||||
@@ -2119,6 +2120,18 @@ function checkpointCursor(cursor: string | null | undefined): number {
|
||||
*/
|
||||
const GOVERNED_WAIT_PROVIDER_WORK_PROOF_TIMEOUT_MS = 30_000;
|
||||
|
||||
function runnerProvedSavedStateGone(
|
||||
checkpoint: PersistedNativeSession,
|
||||
recovery: NativeSessionRecoveryResult,
|
||||
restartInterruption: boolean,
|
||||
): boolean {
|
||||
return recovery.failureClass === PROVIDER_STATE_INCOMPATIBLE &&
|
||||
recovery.resumeStateUnavailable === true &&
|
||||
!restartInterruption &&
|
||||
checkpoint.activeTurnId === null &&
|
||||
Array.isArray(checkpoint.pendingRuntimeRequests) && checkpoint.pendingRuntimeRequests.length === 0;
|
||||
}
|
||||
|
||||
async function governedWaitFollowUpMayStartFresh(input: {
|
||||
input: NativeExecutionInput;
|
||||
checkpoint: PersistedNativeSession;
|
||||
@@ -2131,14 +2144,10 @@ async function governedWaitFollowUpMayStartFresh(input: {
|
||||
if (
|
||||
checkpoint.providerRecoveryPolicy !== "allow_replacement_after_governed_wait" ||
|
||||
("homeMode" in input.input && input.input.homeMode === "preconfigured") ||
|
||||
recovery.failureClass !== PROVIDER_STATE_INCOMPATIBLE ||
|
||||
recovery.resumeStateUnavailable !== true ||
|
||||
input.restartInterruption ||
|
||||
!runnerProvedSavedStateGone(checkpoint, recovery, input.restartInterruption) ||
|
||||
checkpoint.identity.runId !== input.input.binding.runId ||
|
||||
!(checkpoint.cursor === null || checkpoint.cursor === "0") ||
|
||||
checkpoint.activeTurnId !== null ||
|
||||
!Array.isArray(checkpoint.terminalTurns) || checkpoint.terminalTurns.length > 0 ||
|
||||
!Array.isArray(checkpoint.pendingRuntimeRequests) || checkpoint.pendingRuntimeRequests.length > 0 ||
|
||||
checkpoint.semanticResult !== null ||
|
||||
checkpoint.terminal !== null ||
|
||||
checkpoint.governedWait !== undefined ||
|
||||
@@ -2778,7 +2787,11 @@ export async function executeNativeSession(
|
||||
controlPlane: options.controlPlane,
|
||||
timeoutMs: recoveryTimeoutMs,
|
||||
});
|
||||
if (!replacementAllowed && !governedWaitFollowUpLostState) {
|
||||
const confirmedStateLoss = !replacementAllowed && !governedWaitFollowUpLostState &&
|
||||
options.replaceAfterConfirmedProviderStateLoss === true &&
|
||||
!("homeMode" in input && input.homeMode === "preconfigured") &&
|
||||
runnerProvedSavedStateGone(providerRecoveryCheckpoint, recovery, Boolean(checkpointedInterruption));
|
||||
if (!replacementAllowed && !governedWaitFollowUpLostState && !confirmedStateLoss) {
|
||||
if (recovery.failureClass === PROVIDER_STATE_INCOMPATIBLE) {
|
||||
throw new NativeProviderStateIncompatibleError(recovery.reason ?? "unknown");
|
||||
}
|
||||
@@ -2791,7 +2804,7 @@ export async function executeNativeSession(
|
||||
throw failure;
|
||||
}
|
||||
continuityBreak = {
|
||||
reason: governedWaitFollowUpLostState
|
||||
reason: governedWaitFollowUpLostState || confirmedStateLoss
|
||||
? `saved provider state is unavailable, so the follow-up continues in a fresh provider session without the earlier conversation context (${recovery.reason ?? "unknown"})`
|
||||
: recovery.reason ?? "provider session is no longer recoverable",
|
||||
previousDriverSessionId: providerRecoveryCheckpoint.sessionId,
|
||||
|
||||
@@ -81,7 +81,8 @@ export function registerPluginRunnerEvictionSuite(harness: "codex" | "claude", e
|
||||
const thisCase: { teardown?: () => Promise<void> } = {};
|
||||
currentCase = thisCase;
|
||||
const detached = mode === "detached" || mode === "missing state" || mode === "foreign state";
|
||||
const denied = mode.startsWith("missing") || mode.endsWith("state");
|
||||
const freshSession = mode === "missing state";
|
||||
const denied = !freshSession && (mode.startsWith("missing") || mode.endsWith("state"));
|
||||
const relaunch = mode === "relaunch after inspection";
|
||||
const unavailableResume = mode === "after inspection" || mode === "bare unavailable" || relaunch;
|
||||
const reusesLease = mode === "reused lease" || unavailableResume;
|
||||
@@ -166,6 +167,7 @@ export function registerPluginRunnerEvictionSuite(harness: "codex" | "claude", e
|
||||
const releases: DurableRecoveryIdentity[] = [], claims: DurableRecoveryIdentity[] = [];
|
||||
let handle: RunnerProcessHandle | undefined, submissions = 0, cleaning = false, sourceReadRequests = 0, sourceReadResponses = 0;
|
||||
let pendingFollowup: Promise<unknown> | undefined;
|
||||
const runLogs: string[] = [];
|
||||
thisCase.teardown = async () => {
|
||||
cleaning = true;
|
||||
const cleanup = await Promise.allSettled([closeIdleWarmNativeSessionsForRestart(), ...[...hosts.values()].map(host => host.close())]);
|
||||
@@ -313,7 +315,7 @@ export function registerPluginRunnerEvictionSuite(harness: "codex" | "claude", e
|
||||
runnerEnvironment: harness === "claude" ? { ANTHROPIC_API_KEY: "synthetic-fixture" } : {},
|
||||
...(mode === "prepared copy" ? { instructionWorkingCopy: instructionCopy(current.binding.runId) } : {}),
|
||||
managedAiCredentialHome: home, managedAiCredentialIdentity: "fixture-revision", managedAiAccountIdentity: "fixture-account", turnTimeoutMs: 15_000,
|
||||
runnerExecutionTarget: target });
|
||||
onLog: async (_stream, chunk) => { runLogs.push(chunk); }, runnerExecutionTarget: target });
|
||||
};
|
||||
try {
|
||||
const a = await execute(execution, leaseA); expect(a).toMatchObject({ exitCode: 0, timedOut: false });
|
||||
@@ -410,7 +412,11 @@ export function registerPluginRunnerEvictionSuite(harness: "codex" | "claude", e
|
||||
if (denied || mode === "bare unavailable") return;
|
||||
await waitForCondition("automatic release B", () => releases.length === 2);
|
||||
expect(await proof()).toBeUndefined();
|
||||
expect((await supervisor()).snapshot.providerSessionId).toBe(providerSessionId);
|
||||
if (freshSession) {
|
||||
expect({ sourceReadRequests, sourceReadResponses }).toEqual({ sourceReadRequests: 1, sourceReadResponses: 0 });
|
||||
expect(runLogs.join("")).toContain("finished without a saved runner checkpoint");
|
||||
expect(runLogs.join("")).toContain("provider session continuity break");
|
||||
} else expect((await supervisor()).snapshot.providerSessionId).toBe(providerSessionId);
|
||||
const methods = (await readFile(calls, "utf8")).trim().split(/\r?\n/);
|
||||
expect(submissions).toBe(2);
|
||||
if (mode === "after inspection" || relaunch) expect({ resumeAttempts, acquisitions }).toEqual({ resumeAttempts: 1, acquisitions: 1 });
|
||||
|
||||
@@ -545,6 +545,7 @@ import {
|
||||
verifyNativeHarnessBackupStreamed,
|
||||
shouldRestoreNativeHarnessBackupIntoSandbox,
|
||||
remoteProviderStateNeverOpened,
|
||||
providerSessionReplaceableAfterStateLoss,
|
||||
} from "./native-session-executor.js";
|
||||
import { onNativeRunnerEvidence } from "./native-runner-evidence-signal.js";
|
||||
|
||||
@@ -19987,6 +19988,20 @@ describe("runnerd provider runtime wiring", () => {
|
||||
} finally { owner.mockRestore(); resume.mockRestore(); }
|
||||
});
|
||||
|
||||
it("keeps same-session recovery for an unfinished goal or Antigravity after a confirmed lost plugin checkpoint", () => {
|
||||
const codex = { provider: { kind: "codex", model: null, approvalPolicy: "never" } } as unknown as NativeExecutionInput;
|
||||
const goal = (status: string) => ({ threadId: "thread", objective: "ship", status, tokenBudget: null, tokensUsed: 0, timeUsedSeconds: 0 }) as never;
|
||||
expect(providerSessionReplaceableAfterStateLoss({}, codex)).toBe(true);
|
||||
expect(providerSessionReplaceableAfterStateLoss({ goal: null }, codex)).toBe(true);
|
||||
expect(providerSessionReplaceableAfterStateLoss({ goal: goal("complete") }, codex)).toBe(true);
|
||||
for (const status of ["active", "paused", "blocked", "limited", "usageLimited", "budgetLimited"]) {
|
||||
expect(providerSessionReplaceableAfterStateLoss({ goal: goal(status) }, codex), status).toBe(false);
|
||||
}
|
||||
const antigravity = { provider: { kind: "acpx", agent: "antigravity" } } as unknown as NativeExecutionInput;
|
||||
expect(providerSessionReplaceableAfterStateLoss({}, antigravity))
|
||||
.toBe(!antigravityRelease.antigravityForcesSameSessionRecovery(antigravity.provider));
|
||||
});
|
||||
|
||||
it.each([
|
||||
"stopped-state-unavailable",
|
||||
"stopped-availability-omitted",
|
||||
|
||||
@@ -6544,7 +6544,15 @@ async function assertPluginTaskReattachmentBinding(input: {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
async function migrateRunnerdStateRootForExecution(input: {
|
||||
async function migrateRunnerdStateRootForExecution(
|
||||
input: Omit<Parameters<typeof migrateRunnerdStateRoot>[0], "onPluginCheckpointRetired">,
|
||||
): Promise<{ binding?: VerifiedWarmTransitionBinding; pluginCheckpointRetired: boolean }> {
|
||||
let pluginCheckpointRetired = false;
|
||||
const binding = await migrateRunnerdStateRoot({ ...input, onPluginCheckpointRetired: () => { pluginCheckpointRetired = true; } });
|
||||
return { binding, pluginCheckpointRetired };
|
||||
}
|
||||
|
||||
async function migrateRunnerdStateRoot(input: {
|
||||
db: Db;
|
||||
execution: NativeExecutionInput;
|
||||
preparedExecutionAdmission?: NativePreparedExecutionAdmission;
|
||||
@@ -6556,6 +6564,7 @@ async function migrateRunnerdStateRootForExecution(input: {
|
||||
runnerExecutionTarget?: AdapterExecutionTarget | null;
|
||||
bootstrapRetryLeaseOwner?: string;
|
||||
pluginCheckpointUnavailableConfirmed?: boolean;
|
||||
onPluginCheckpointRetired?: () => void;
|
||||
}): Promise<VerifiedWarmTransitionBinding | undefined> {
|
||||
const scoped = scopedRunnerdStateRoot(input.execution);
|
||||
await restoreWarmRunnerdController(input);
|
||||
@@ -6728,7 +6737,10 @@ async function migrateRunnerdStateRootForExecution(input: {
|
||||
if (verification === "terminal_state_indeterminate" && !input.retainedWarmOwnerRunId
|
||||
&& (!input.restartRecovery || input.restartRecovery.kind === "bootstrap_incomplete")) {
|
||||
const retirement = await retireFinishedPerTurnRunnerdOwner({ ...input, root: scoped, identity, pluginCheckpointUnavailableConfirmed });
|
||||
if (retirement.retired) return;
|
||||
if (retirement.retired) {
|
||||
if (pluginCheckpointUnavailableConfirmed) input.onPluginCheckpointRetired?.();
|
||||
return;
|
||||
}
|
||||
if (retirement.refused !== "lifecycle_not_per_turn") retirementRefusal = `; retirement_refused=${retirement.refused}`;
|
||||
}
|
||||
if (
|
||||
@@ -8975,6 +8987,14 @@ function loadWarmNativeCheckpoint(
|
||||
return resumed;
|
||||
}
|
||||
|
||||
export function providerSessionReplaceableAfterStateLoss(
|
||||
checkpoint: Pick<PersistedNativeSession, "goal">,
|
||||
execution: Pick<NativeExecutionInput, "provider">,
|
||||
): boolean {
|
||||
if (antigravityForcesSameSessionRecovery(execution.provider)) return false;
|
||||
return checkpoint.goal == null || checkpoint.goal.status === "complete";
|
||||
}
|
||||
|
||||
async function releaseWarmNativeSession(
|
||||
sessionId: string,
|
||||
ownerToken: symbol,
|
||||
@@ -11276,6 +11296,7 @@ async function executePaperclipNativeSessionAttempt(
|
||||
} else releasedWarmSource(input, cachedReleasedOwner.pluginTaskId ?? null);
|
||||
}
|
||||
let pluginCheckpointUnavailableConfirmed = false;
|
||||
let pluginCheckpointRetired = false;
|
||||
if (input.useRunnerd && canRecoverWarmOwner && !input.backend &&
|
||||
input.runnerExecutionTarget?.kind === "remote" &&
|
||||
input.execution.session.lifecyclePolicy.mode === "warm" &&
|
||||
@@ -11339,7 +11360,7 @@ async function executePaperclipNativeSessionAttempt(
|
||||
}
|
||||
}
|
||||
if (input.useRunnerd) {
|
||||
retainedTransition = await timeController("state_migration", () => migrateRunnerdStateRootForExecution({
|
||||
const migration = await timeController("state_migration", () => migrateRunnerdStateRootForExecution({
|
||||
db: input.db,
|
||||
execution: input.execution,
|
||||
preparedExecutionAdmission: input.preparedExecutionAdmission,
|
||||
@@ -11352,6 +11373,8 @@ async function executePaperclipNativeSessionAttempt(
|
||||
bootstrapRetryLeaseOwner: input.leaseOwner,
|
||||
pluginCheckpointUnavailableConfirmed,
|
||||
}));
|
||||
retainedTransition = migration.binding;
|
||||
pluginCheckpointRetired = migration.pluginCheckpointRetired;
|
||||
}
|
||||
const durableRunnerBinding = input.useRunnerd
|
||||
? loadRunnerdDurableBinding(input.execution, retainedTransition)
|
||||
@@ -12911,6 +12934,8 @@ async function executePaperclipNativeSessionAttempt(
|
||||
},
|
||||
existingSession: existingWarmSession,
|
||||
persistedSession: persistedWarmSession,
|
||||
replaceAfterConfirmedProviderStateLoss: pluginCheckpointRetired && persistedWarmSession
|
||||
? providerSessionReplaceableAfterStateLoss(persistedWarmSession, input.execution) : false,
|
||||
keepSessionOpen: warmSessionId !== null,
|
||||
sessionGoalControl: input.sessionGoalControl,
|
||||
resumeSessionGoalHeartbeat: input.resumeSessionGoalHeartbeat,
|
||||
@@ -16624,7 +16649,7 @@ export async function createRunnerdBackend(input: {
|
||||
input.execution.binding.runId ||
|
||||
hasRetainedWarmTransitionEvidence(scopedRunnerdStateRoot(input.execution))
|
||||
) {
|
||||
retainedTransition = await migrateRunnerdStateRootForExecution({
|
||||
retainedTransition = (await migrateRunnerdStateRootForExecution({
|
||||
db: input.db,
|
||||
execution: input.execution,
|
||||
preparedExecutionAdmission: input.preparedExecutionAdmission,
|
||||
@@ -16634,7 +16659,7 @@ export async function createRunnerdBackend(input: {
|
||||
onLog: input.onLog,
|
||||
restartRecovery: input.restartRecovery,
|
||||
runnerExecutionTarget: input.runnerExecutionTarget,
|
||||
});
|
||||
})).binding;
|
||||
}
|
||||
input.executionContext?.signal.throwIfAborted();
|
||||
const backend = await createRunnerdBackendWithinSessionClaim(
|
||||
|
||||
Reference in new issue
Block a user