fix(sandbox): wait for managed supervisor on start - #8728
Conversation
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
📝 WalkthroughWalkthroughSandbox startup now waits for a missing managed supervisor before retrying recovery. The change exports the existing waiter, adds an optional startup dependency, preserves terminal failures, and adds targeted tests. ChangesManaged supervisor startup recovery
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant SandboxStart
participant waitForManagedGatewaySupervisor
participant RecoveryAndGatewayVerification
SandboxStart->>RecoveryAndGatewayVerification: initial recovery attempt
SandboxStart->>waitForManagedGatewaySupervisor: wait after missing-supervisor failure
waitForManagedGatewaySupervisor-->>SandboxStart: readiness result
SandboxStart->>RecoveryAndGatewayVerification: retry recovery and verify gateway
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/actions/sandbox/start.test.ts (1)
201-215: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover a throwing managed-supervisor waiter.
Lines 150-158 in
src/lib/actions/sandbox/start.tspreserve the first recovery failure whenwaitForManagedGatewaySupervisorthrows. Add a test that makes the waiter throw. Assert that startup reports the first recovery failure, performs one recovery attempt, and does not callverifyGateway.As per path instructions, review tests for behavioral confidence rather than implementation lock-in.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/actions/sandbox/start.test.ts` around lines 201 - 215, Add a test alongside the existing recovery-failure test that configures waitForManagedGatewaySupervisor to throw after the initial recovery failure. Assert startSandbox rejects with the first recovery failure, restoreStartupState is called once, and verifyGateway is not called; avoid asserting internal implementation details beyond this behavior.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/lib/actions/sandbox/start.test.ts`:
- Around line 201-215: Add a test alongside the existing recovery-failure test
that configures waitForManagedGatewaySupervisor to throw after the initial
recovery failure. Assert startSandbox rejects with the first recovery failure,
restoreStartupState is called once, and verifyGateway is not called; avoid
asserting internal implementation details beyond this behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: e26e2be3-6304-4217-8330-c3a803790f65
📒 Files selected for processing (3)
src/lib/actions/sandbox/connect.tssrc/lib/actions/sandbox/start.test.tssrc/lib/actions/sandbox/start.ts
PR Review Advisor — No blocking findings reportedAdvisor assessment: No blocking advisor findings reported Model lanes
3 terminology differences from the second opinionAdvisory only. These are normalized differences from the primary terminology receipt.
4 additional E2E selections from the second opinionAdvisory only. The primary lane did not select these E2E jobs or targets.
Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests. 3 semantic terminology decisionsTerminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.
E2E guidanceAdvisory only. A maintainer can dispatch the default E2E suite against this exact revision. Recommended E2E: This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge. |
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
<!-- markdownlint-disable MD041 --> ## Summary Live onboarding now waits for the OpenShell create client to release ownership before applying restart-safe Docker recreation. Previously the active onboarding path bypassed the existing ownership barrier, so recreation could race the still-running create process and leave fresh sandboxes unready. ## Related Issue Follow-up to #8720. This is complementary to the stopped-sandbox recovery change in #8728. ## Changes - Reuse `streamSandboxCreate`'s existing `waitForReadyTermination` barrier in the active unmanaged, non-compatibility restart-safe path. - Suppress the existing poll-time recreation in that path so the existing `ensureApplied()` cutover runs only after create ownership is released. - Tighten the existing no-GPU Docker-route test to cover the barrier, suppressed early patch, and deferred cutover without adding a new test file. - Leave stopped-sandbox recovery, timing thresholds, legacy upgrades, and MCP coverage unchanged. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Quality Gates <!-- Check one tests line and one docs line. Check other lines when applicable. Add every requested justification or approval reference. --> - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: This restores the documented onboarding-ready contract without changing commands, configuration, remediation, or intended output. - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: The change only gates the existing restart-safe recreation on release of create-process ownership. Existing failure classification, managed lifecycle handling, compatibility recreation, rollback, and readiness checks remain unchanged. - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Documentation Writer Review <!-- Required for code and documentation changes after the changes and applicable validation are complete. Keep one review checkbox and one instance of each visible or hidden field. For Evidence, list changed documentation paths. For documentation-only changes, also state that the writing rules and documentation style were reviewed. For other results, explain why no documentation change is needed or why the review is blocked. For Agent, use a consistent product and surface name, such as Codex Desktop, Codex CLI, Claude Code, or Cursor. After committing all review changes, put `git rev-parse --short HEAD` and `git rev-parse --short HEAD:AGENTS.md` in the hidden metadata below. Rerun the review and refresh that metadata after any new commit. This receipt is advisory during the data-collection pilot. --> - [x] Documentation writer subagent reviewed the completed changes - Result: `no-docs-needed` - Evidence: No documentation paths changed. Existing `docs/reference/commands.mdx` and `docs/get-started/quickstart.mdx` already own the unchanged create, ready, and dashboard contract. - Agent: Codex Desktop <!-- docs-review-head-sha: b13bb57 --> <!-- docs-review-agents-blob-sha: c4923a3 --> ## DGX Station Hardware Evidence <!-- Required only when scripts/prepare-dgx-station-host.sh changes. Maintainers must review the linked evidence before approving or merging. This is human-reviewed evidence, not authenticated hardware provenance. Exceptional bypasses use existing repository governance and must be documented on the PR. --> - [ ] Tested on DGX Station - Tested commit: - Station profile/scenario: - Result: - Supporting evidence: ## Verification <!-- Check each applicable item only when supported by the requested evidence. Run targeted tests once per relevant change set and rerun after later edits or hook autofixes that can affect the tested behavior. Do not rerun hook-covered checks. --> - [x] PR description includes a `Signed-off-by:` line and every commit appears as `Verified` in GitHub - [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or `npm run validate:pr` passed after refreshing `origin/main` when hooks were skipped or unavailable - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: `npx vitest run --project cli src/lib/onboard/sandbox-gpu-create-flow.test.ts src/lib/sandbox/create-stream.test.ts` (56 passed); `npm run typecheck:cli` passed. - [ ] Applicable broad gate passed — `npm test` for broad runtime/test-harness changes; `npm run check` for repo-wide validation/coverage changes — command/result: Not applicable; the change is a focused two-file onboarding sequencing fix covered by targeted tests and normal hooks. - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- <!-- DCO sign-off is required in this PR description, and every commit must appear as Verified in GitHub. Run: git config user.name && git config user.email --> Signed-off-by: Apurv Kumaria <akumaria@nvidia.com> Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Summary
Ordinary stopped-sandbox startup now waits through only an exact transient missing-supervisor result, then repeats the complete startup recovery before readiness and forward verification. Definitive or unclassified failures remain terminal, and successful legacy supervisor relaunch recovery does not incur a settling delay.
Related Issue
Fixes #8726
Changes
SUPERVISOR_NOT_RUNNING.Type of Change
Quality Gates
Documentation Writer Review
no-docs-neededstartrecovery contract for one exact transient supervisor race. The final additional test only proves that a waiter exception preserves the existing fail-closed result; it does not change user-facing behavior or documentation ownership.DGX Station Hardware Evidence
Verification
Signed-off-by:line and every commit appears asVerifiedin GitHubpre-commit,commit-msg, andpre-pushhooks passed, ornpm run validate:prpassed after refreshingorigin/mainwhen hooks were skipped or unavailablenpx vitest run --project cli src/lib/actions/sandbox/start.test.ts(28 passed) andnpx vitest run --project integration test/process-recovery-supervisor-relaunch.test.ts(21 passed).npm testfor broad runtime/test-harness changes;npm run checkfor repo-wide validation/coverage changes — command/result:npm run docsbuilds without warnings (doc changes only)Signed-off-by: Apurv Kumaria akumaria@nvidia.com
Summary by CodeRabbit