Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,45 @@ describe("Docker GPU patch diagnostics", () => {
expect(result.headline).toContain("Provisioning");
});

it("assigns OpenShell lifecycle ownership when a healthy container remains in Deleting (#9531)", () => {
const result = classify(
failureSnapshot("Deleting", {
Status: "running",
Running: true,
ExitCode: 0,
Health: { Status: "healthy" },
}),
);

expect(result).toMatchObject({
kind: "sandbox_deleting_phase",
headline:
"OpenShell kept the sandbox in Deleting after the replacement container became healthy.",
summaryLines: expect.arrayContaining([
"sandbox_phase=Deleting",
"patched_container_status=running",
"patched_container_running=true",
"patched_container_exit_code=0",
"patched_container_health=healthy",
"lifecycle_authority=openshell",
]),
hints: [
"OpenShell owns the sandbox lifecycle phase. NemoClaw does not accept Docker container health as lifecycle success.",
],
});
});

it.each([
["health is not healthy", { ...RUNNING, Health: { Status: "starting" } }],
["container is not running", { Status: "exited", Running: false, ExitCode: 0 }],
["container state is incomplete", RUNNING],
])("does not assign OpenShell lifecycle ownership when %s (#9531)", (_case, state) => {
const result = classify(failureSnapshot("Deleting", state));

expect(result.kind).not.toBe("sandbox_deleting_phase");
expect(result.summaryLines).not.toContain("lifecycle_authority=openshell");
});

it("prefers supervisor_unreachable over proof_failure when the sandbox is non-live but non-terminal", () => {
const result = classify(
failureSnapshot("Provisioning"),
Expand Down
1 change: 1 addition & 0 deletions src/lib/onboard/docker-gpu-patch-failure-print.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ describe("Docker GPU patch failure reporting (#7996)", () => {

it.each([
"sandbox_error_phase",
"sandbox_deleting_phase",
"supervisor_unreachable",
"proof_failure",
] as const)("ignores a saved %s verdict after rollback", (kind) => {
Expand Down
1 change: 1 addition & 0 deletions src/lib/onboard/docker-gpu-patch-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export type DockerGpuPatchSandboxSnapshot = {
export type DockerGpuPatchFailureKind =
| "patched_container_failed"
| "sandbox_error_phase"
| "sandbox_deleting_phase"
| "supervisor_unreachable"
| "proof_failure"
| "unknown";
Expand Down
20 changes: 20 additions & 0 deletions src/lib/onboard/docker-gpu-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,15 @@ function patchedContainerLooksFailed(state: DockerContainerState | null): boolea
return false;
}

function patchedContainerIsHealthyAndRunning(state: DockerContainerState | null): boolean {
return (
state?.Status?.toLowerCase() === "running" &&
state.Running === true &&
state.ExitCode === 0 &&
state.Health?.Status?.toLowerCase() === "healthy"
);
}

/**
* Turn the snapshot + selected GPU mode into a user-facing classification
* that distinguishes "the patched container itself died" from "the sandbox
Expand All @@ -504,6 +513,9 @@ export function classifyDockerGpuPatchFailure(
if (selectedMode) lines.push(`patched_create_option=${selectedMode.label}`);

const containerFailed = patchedContainerLooksFailed(snapshot.patchedContainerState);
const healthyContainerInDeletingPhase =
snapshot.sandboxPhase === "Deleting" &&
patchedContainerIsHealthyAndRunning(snapshot.patchedContainerState);
const sandboxInErrorPhase = isFailurePhase(snapshot.sandboxPhase);
const sandboxNotLive =
!!snapshot.sandboxPhase && !SANDBOX_LIVE_PHASE_TOKENS.has(snapshot.sandboxPhase);
Expand All @@ -528,6 +540,14 @@ export function classifyDockerGpuPatchFailure(
} else if (sandboxInErrorPhase) {
kind = "sandbox_error_phase";
headline = `OpenShell sandbox entered ${snapshot.sandboxPhase} phase before the GPU proof could run.`;
} else if (healthyContainerInDeletingPhase) {
kind = "sandbox_deleting_phase";
headline =
"OpenShell kept the sandbox in Deleting after the replacement container became healthy.";
lines.push("lifecycle_authority=openshell");
hints.push(
"OpenShell owns the sandbox lifecycle phase. NemoClaw does not accept Docker container health as lifecycle success.",
);
} else if (sandboxNotLive && (snapshot.patchedContainerState || options.proofError)) {
// Cover the non-live-but-non-terminal case (e.g. Provisioning / NotReady)
// BEFORE the proof-error branch — a proof failing while the sandbox
Expand Down
Loading