Skip to content

fix(sandbox): observe host gateway on probe-only and wait for readiness before probing - #7192

Merged
cv merged 9 commits into
mainfrom
fix/observe-vs-recover-sandbox-gateway
Jul 19, 2026
Merged

cv merged 9 commits into
mainfrom
fix/observe-vs-recover-sandbox-gateway

Conversation

@laitingsheng

@laitingsheng laitingsheng commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Sandbox-scoped commands (recover, start, connect --probe-only) now run gateway reconciliation in observe mode, so a transient host gateway RPC error surfaces with explicit next-step guidance instead of implicitly reaping and replacing the shared host OpenShell gateway process. Probe-only additionally waits for the target sandbox to reach Ready or Running (default 300 s, still honouring NEMOCLAW_CONNECT_TIMEOUT) before inspecting in-sandbox processes or host forwards, so a cold ~two-minute Hermes boot succeeds on the first invocation.

Related Issue

Fixes #7173

Changes

  • Add GatewayRecoveryMode = "observe" | "recover" to getReconciledSandboxGatewayState() and ensureLiveSandboxOrExit() (default recover preserves the existing contract for every other caller). Observe mode returns gateway_error verbatim; the outer helper prints host-gateway guidance and exits without invoking recoverNamedGatewayRuntime().
  • Extract the sandbox readiness poll from connect.ts into a reusable waitForSandboxReadyOrExit(sandboxName, { defaultTimeoutSec, successLogs }) helper; probe-only now calls it with a 300 s default budget before delegating to runSandboxConnectProbe, and the full-connect path calls it with the existing 120 s default. Both paths still honour NEMOCLAW_CONNECT_TIMEOUT.
  • Thread gatewayRecovery: "observe" from the probe-only branch of connectSandbox through ensureLiveSandboxOrExit.
  • Document the split between host OpenShell gateway recovery and in-sandbox agent recovery, including connect --probe-only, in docs/manage-sandboxes/recover-rebuild-sandboxes.mdx.
  • Update docs/reference/commands.mdx with the exact 120 s interactive and 300 s probe-only readiness budgets, the post-wait recorded-gateway recheck, sandbox-scoped process/forward repair, and the no-host-gateway-restart boundary.
  • Add gateway-state-observe-mode.test.ts covering the observe-vs-recover contract and default-recover regression.
  • Add connect-probe-observe.test.ts covering probe-only observe-mode propagation, readiness-before-recovery ordering, and the 300 s probe-only timeout budget.
  • Relax connect-route-containment.test.ts to allow the pre-probe sandbox list readiness call while still forbidding sandbox get/exec route reads and every route-repair spy.

Type of Change

  • Code change with doc updates
  • Code change (feature, bug fix, or refactor)
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification:
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification:
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: npm run test:changed — 33 files, 346 tests passed; npx vitest run on the two new files and connect-route-containment.test.ts — 19 tests passed.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result:
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs completed successfully (doc changes only) — 0 errors; 2 existing Fern warnings
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only) — not applicable; no new pages were added

Signed-off-by: Tinson Lai [email protected]

Summary by CodeRabbit

  • New Features
    • Improved sandbox readiness flow with centralized polling, clearer failure handling, and timeout-aware behavior.
    • connect --probe-only now waits for readiness, verifies/repairs sandbox-scoped gateway/forwarding, then rechecks before proceeding—without restarting the shared host gateway.
    • Added “observe” vs “recover” behavior for gateway-error reconciliation.
  • Documentation
    • Expanded recovery guidance: host OpenShell gateway versus in-sandbox agent recovery, including probe-only next-step instructions.
  • Tests
    • Updated and added coverage for probe-only observe mode, gateway-error behavior, route containment/lifecycle expectations, and CLI stubs.

…ss before probing

Sandbox-scoped commands (`recover`, `start`, `connect --probe-only`) now
run reconciliation in `observe` mode, so a transient host gateway RPC
error surfaces with explicit guidance instead of implicitly reaping and
replacing the shared host OpenShell gateway. Probe-only also waits for
the target sandbox to reach `Ready`/`Running` (default 300s, still
honouring `NEMOCLAW_CONNECT_TIMEOUT`) before inspecting in-sandbox
processes or host forwards, so a cold ~two-minute Hermes boot succeeds
on the first invocation.

Fixes #7173

Signed-off-by: Tinson Lai <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes add observe-only gateway reconciliation, centralize sandbox readiness polling, delay probe operations until readiness, expand readiness-focused tests and mocks, and document host gateway versus sandbox-scoped recovery behavior.

Changes

Sandbox recovery flow

Layer / File(s) Summary
Gateway reconciliation modes
src/lib/actions/sandbox/gateway-state.ts, src/lib/actions/sandbox/gateway-state-observe-mode.test.ts
Adds observe and recover gateway modes, preserves recovery by default, and returns gateway errors without host recovery in observe mode.
Connect readiness and probe ordering
src/lib/actions/sandbox/connect.ts, src/lib/actions/sandbox/connect-probe-observe.test.ts, src/lib/actions/sandbox/connect-route-containment.test.ts, src/lib/actions/sandbox/connect-route-lifecycle.test.ts
Centralizes readiness polling, selects recovery behavior by flow, and delays probe operations until the sandbox is ready.
Connect test environment updates
test/cli/connect-recovery*.test.ts, test/cli/connect-terminal-agent.test.ts, test/support/connect-flow-test-harness.ts
Updates mocked OpenShell responses and harness output for sandbox readiness checks.
Host and sandbox recovery guidance
docs/manage-sandboxes/recover-rebuild-sandboxes.mdx, docs/reference/commands.mdx
Documents shared host gateway boundaries, probe-only readiness behavior, timeout handling, and sandbox-scoped recovery.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant connectSandbox
  participant ensureLiveSandboxOrExit
  participant OpenShell
  participant InSandboxProbe
  connectSandbox->>ensureLiveSandboxOrExit: choose observe or recover mode
  connectSandbox->>OpenShell: poll sandbox list
  OpenShell-->>connectSandbox: report readiness
  connectSandbox->>ensureLiveSandboxOrExit: recheck recorded gateway
  connectSandbox->>InSandboxProbe: probe after Ready or Running
Loading

Possibly related issues

Possibly related PRs

Suggested labels: area: docs, area: cli

Suggested reviewers: cv, apurvvkumaria

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: probe-only observes the host gateway and waits for sandbox readiness.
Linked Issues check ✅ Passed The PR implements observe-vs-recover gateway modes, readiness polling, timeout handling, and docs/tests required by #7173.
Out of Scope Changes check ✅ Passed The changes stay focused on sandbox recovery/connect behavior, tests, and docs with no unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/observe-vs-recover-sandbox-gateway

Comment @coderabbitai help to get the list of available commands.

@github-code-quality

github-code-quality Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage remains at 96%, unchanged from the main branch.

TypeScript / code-coverage/cli

The overall coverage in the fix/observe-vs-recov... branch remains at 80%, unchanged from the main branch.

Show a code coverage summary of the most impacted files.
File main 78e0e4e fix/observe-vs-recov... 74700b2 +/-
src/lib/actions...ateway-state.ts 65% 65% 0%
src/lib/onboard...eway-binding.ts 83% 83% 0%
src/lib/sandbox...rce-identity.ts 91% 91% 0%
src/lib/state/m...-acquisition.ts 84% 84% 0%
src/lib/state/m...ock-identity.ts 95% 95% 0%
src/lib/adapter...shell/client.ts 88% 90% +2%
src/lib/onboard...carryforward.ts 92% 96% +4%
src/lib/actions...dbox/connect.ts 72% 77% +5%
src/lib/inferen...er-lifecycle.ts 65% 71% +6%
src/lib/inferen...lama/process.ts 50% 100% +50%

Updated July 19, 2026 12:48 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

Copy link
Copy Markdown
Contributor

@laitingsheng laitingsheng added area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression labels Jul 19, 2026
@github-actions

github-actions Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / medium confidence
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions
Status: No actionable findings remain in the canonical review ledger.

Model lanes

  • GPT-5.6 Terra (primary): Completed · medium confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Model comparison: normalized findings match; normalized E2E selections differ; severity counts match.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: onboard-repair, onboard-resume

2 optional E2E recommendations
  • sandbox-operations
  • gateway-guard-recovery

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@docs/manage-sandboxes/recover-rebuild-sandboxes.mdx`:
- Line 89: Update the host gateway repair command in the shared documentation to
use the variant-aware `$$nemoclaw onboard` placeholder instead of bare `nemoclaw
onboard`, while leaving the other commands unchanged.
- Around line 83-87: Scope the “Host OpenShell Gateway Versus In-Sandbox Agent
Recovery” guidance to gateway-capable sandboxes by wrapping the gateway-specific
claims in an AgentOnly block for the openclaw and hermes variants. Ensure Deep
Agents instead see guidance to use rebuild, consistent with the existing
instructions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: cd8eeeb8-e8cf-4ad5-83cd-42079af49022

📥 Commits

Reviewing files that changed from the base of the PR and between 78e0e4e and 22f846a.

📒 Files selected for processing (6)
  • docs/manage-sandboxes/recover-rebuild-sandboxes.mdx
  • src/lib/actions/sandbox/connect-probe-observe.test.ts
  • src/lib/actions/sandbox/connect-route-containment.test.ts
  • src/lib/actions/sandbox/connect.ts
  • src/lib/actions/sandbox/gateway-state-observe-mode.test.ts
  • src/lib/actions/sandbox/gateway-state.ts

Probe-only connect now waits for sandbox readiness via
`openshell sandbox list` before probing. Several pre-existing fake
openshell scripts and the shared connect-flow harness only stubbed
`sandbox get`, so the new wait hung until timeout. Add matching
`sandbox list` stubs, and derive the harness's default list output
from the registry entry name instead of hardcoding 'alpha'.

The drift-recovery quoting test used a sandbox name containing a
literal space, which the whitespace-column `sandbox list` parser can
never match; swap it for a hyphen while keeping the apostrophe that
the test actually exercises.

Signed-off-by: Tinson Lai <[email protected]>
@apurvvkumaria apurvvkumaria self-assigned this Jul 19, 2026
laitingsheng and others added 2 commits July 19, 2026 08:34
The host-vs-in-sandbox gateway recovery section referenced an
in-sandbox agent gateway unconditionally, but Deep Agents sandboxes
have no such gateway. Wrap it in an AgentOnly block and use the
variant-aware $$nemoclaw placeholder for the onboarding command.

Signed-off-by: Tinson Lai <[email protected]>
Co-authored-by: Tinson Lai <[email protected]>
Signed-off-by: Apurv Kumaria <[email protected]>
Co-authored-by: Tinson Lai <[email protected]>
Signed-off-by: Apurv Kumaria <[email protected]>

@apurvvkumaria apurvvkumaria left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two exact-head readiness issues need correction before merge:

  1. waitForSandboxReadyOrExit() still runs an unscoped openshell sandbox list. OpenShell gateway selection is process-global and can change while the 300-second loop runs. A concurrent CLI can therefore make a same-named sandbox on a sibling gateway appear Ready; the later recorded-owner recheck then exits instead of continuing to wait for the intended sandbox. Pin every readiness poll to the sandbox registry’s recorded gateway (sandbox list -g <gateway>) and add a regression assertion that all polls carry that exact gateway.

  2. On the new probe-only 300-second timeout path, the printed override is also 300 seconds and the suggested command omits --probe-only. The retry is therefore neither longer nor behaviorally equivalent. Print an actually larger budget and preserve the probe-only command form.

Please keep the post-wait owner recheck as defense in depth and retain the no-process/no-forward-mutation-before-readiness tests.

Co-authored-by: Tinson Lai <[email protected]>
Signed-off-by: Apurv Kumaria <[email protected]>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator

Final docs audit found one additional boundary mismatch: the new sentence says nemoclaw <name> gateway restart may reap or replace the shared host OpenShell gateway, but that command is supervisor-mediated inside the named sandbox. Separate workflows such as onboarding, rebuild, and doctor --fix own host-gateway recovery. I am correcting the wording append-only so the page does not direct operators to the wrong recovery layer.

Co-authored-by: Tinson Lai <[email protected]>
Signed-off-by: Apurv Kumaria <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/lib/actions/sandbox/connect-probe-observe.test.ts`:
- Around line 110-120: Extend the timeout test for connectSandbox in
createConnectHarness to assert that harness.checkAndRecoverSpy has not been
called after the rejection. Preserve the existing exit and guidance assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 09cf2b31-8e08-4e90-b273-e0c60bc29dc7

📥 Commits

Reviewing files that changed from the base of the PR and between 813f348 and 67ebc87.

📒 Files selected for processing (6)
  • docs/manage-sandboxes/recover-rebuild-sandboxes.mdx
  • docs/reference/commands.mdx
  • src/lib/actions/sandbox/connect-probe-observe.test.ts
  • src/lib/actions/sandbox/connect-route-containment.test.ts
  • src/lib/actions/sandbox/connect.ts
  • test/support/connect-flow-test-harness.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • test/support/connect-flow-test-harness.ts
  • src/lib/actions/sandbox/connect-route-containment.test.ts
  • docs/manage-sandboxes/recover-rebuild-sandboxes.mdx
  • src/lib/actions/sandbox/connect.ts

Co-authored-by: Tinson Lai <[email protected]>
Signed-off-by: Apurv Kumaria <[email protected]>
Co-authored-by: Tinson Lai <[email protected]>
Signed-off-by: Apurv Kumaria <[email protected]>

@apurvvkumaria apurvvkumaria left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-head re-review complete at 74700b2. The gateway-scoped readiness polling, probe-only timeout guidance, failure-semantics coverage, and documentation corrections address the requested changes. All review threads are resolved; focused validation, platform smoke lanes, security scans, automated advisors, and ordinary CI are clean. Approving for protected E2E coordination; this is not a merge action.

@cv
cv merged commit 1b05c5a into main Jul 19, 2026
54 checks passed
@cv
cv deleted the fix/observe-vs-recover-sandbox-gateway branch July 19, 2026 13:52
@ericksoa ericksoa mentioned this pull request Jul 20, 2026
9 of 21 tasks
ericksoa added a commit that referenced this pull request Jul 20, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Add the canonical dated changelog entry for NemoClaw `v0.0.89` before
the release plan captures the tag commit.
The entry summarizes the user-visible Station preparation, inference,
recovery, policy-disclosure, and CLI-containment changes merged since
`v0.0.88`.

## Changes

- Add `docs/changelog/2026-07-20.mdx` with the exact `## v0.0.89`
release heading, parser-safe SPDX comment, summary, and detailed
bullets.
- Link each shipped theme to the most specific published OpenClaw
documentation routes.
- Keep internal E2E, advisory-registry, and review-workflow refactors
out of the user-facing release summary.

Source summary:

- #7214, #7241, #7237, #7223, #7204, #7202, #7183, and #7090 ->
`docs/changelog/2026-07-20.mdx`: Summarize qualified DGX Station
identity, package-state, PackageKit, DKMS, and reboot-handoff fixes.
- #7242, #7221, #7186, #7164, and #6874 ->
`docs/changelog/2026-07-20.mdx`: Summarize inference endpoint
provenance, provider attachment, managed vLLM cleanup and progress, and
Ollama selection guidance.
- #7225, #7216, #7192, #7136, #7096, and #6910 ->
`docs/changelog/2026-07-20.mdx`: Summarize sandbox readiness, recovery
guidance, rebuilt model routing, durable Hermes state, and gateway
restart behavior.
- #7187 -> `docs/changelog/2026-07-20.mdx`: Summarize complete effective
messaging-preset egress disclosure before policy mutation.
- #7218, #7165, and #7184 -> `docs/changelog/2026-07-20.mdx`: Summarize
structured output containment, terminal-safe route display, and Hermes
forward cleanup.

## Type of Change

- [ ] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [x] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Quality Gates

- [ ] Tests added or updated for changed behavior
- [ ] Existing tests cover changed behavior — justification:
- [x] Tests not applicable — justification: This PR adds release-history
prose only; the focused changelog contract test validates its required
structure and routes.
- [x] Docs updated for user-facing behavior changes
- [ ] Docs not applicable — justification:
- [ ] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [ ] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification:
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Verification

- [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 check:diff` passed when hooks were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — `mise exec [email protected] -- npx vitest
run test/changelog-docs.test.ts` (6 passed).
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — not applicable to this doc-only release
entry.
- [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) — `mise
exec [email protected] -- npm run docs` completed with 0 errors and 2
existing site-wide warnings.
- [x] 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)
— the native changelog entry uses the required parser-safe MDX SPDX
comment and does not use frontmatter.

---
Signed-off-by: Aaron Erickson <[email protected]>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Expanded DGX Station installation support for qualified GB300 and
OTA-upgraded environments.
* Preserved selected inference providers, endpoints, model pins, and
tuning settings during sandbox creation and rebuilds.
* Improved sandbox recovery by validating availability and stability
before restarting services.
* Added clearer policy output showing the complete effective messaging
egress configuration.

* **Bug Fixes**
* Hardened status and inference route displays by sanitizing terminal
control characters.
* Improved Hermes uninstall behavior by stopping detached dashboard
forwarding.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Aaron Erickson <[email protected]>
cv added a commit that referenced this pull request Aug 13, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Starting a stopped sandbox recovered in-sandbox processes and host
forwards before OpenShell had re-registered the sandbox, so recovery
raced cold registration. `start` reported a recovery failure and left
the primary dashboard and API host forward unstarted, while the
`recover` the operator then ran succeeded because it waits for readiness
first. `start` now waits for the sandbox to reach the `Ready` or
`Running` state before it recovers, using the same budget and
`NEMOCLAW_CONNECT_TIMEOUT` override as `connect --probe-only`.

## Related Issue

Fixes #8978

## Changes

- `src/lib/actions/sandbox/start.ts`:
`restoreStoppedSandboxStartupState` waits for the `Ready` or `Running`
state between the locked-access restore and process recovery. The
locked-access restore stays ahead of the wait because sealed state
blocks the container's own startup; it runs over the direct container,
so it does not depend on OpenShell re-registration. The new step is
injectable through the existing `SandboxStartupStateDeps` seam, which
the three added tests use.
- `src/lib/actions/sandbox/connect.ts`: export
`waitForSandboxReadyOrExit` and add `SANDBOX_REPAIR_READY_TIMEOUT_SEC`,
replacing the literal `300` that `connect --probe-only` already used.
This is a shared constant rather than a second literal so the two paths
that prove the same readiness for the same sandbox cannot drift again;
the added `start` ordering test protects the contract.
- `src/lib/actions/sandbox/start.test.ts`: three tests covering the
readiness position for OpenClaw, for a sandbox with no sealed state, and
across the whole `start` sequence. Each was confirmed to fail without
the fix. One existing test is retitled because its old title described
the ordering this change corrects.
- `docs/manage-sandboxes/run-sandboxes.mdx` and
`docs/reference/commands.mdx`: document the corrected sequence, the
readiness budget, its override, and the timeout result.

This restores the ordering established for #7173 by #7192. #8146
introduced process recovery ahead of the readiness wait on the `start`
path only, so `connect --probe-only` kept the ordering and `start` lost
it. The recovery-owned budget in `process-recovery.ts` is deliberately
untouched: it also backs the `gateway restart` health wait and the
onboarding control-plane wait, and with the ordering corrected the
reported failure no longer depends on it.

## Type of Change

- [ ] Code change (feature, bug fix, or refactor)
- [x] 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:
- [x] Docs updated for user-facing behavior changes
- [ ] Docs not applicable — justification:
- [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: Maintainer security and
cross-issue review passed for commit `51b25f270`; no findings:
#8990 (comment)
- [ ] 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: `docs-updated`
- Evidence: `docs/manage-sandboxes/run-sandboxes.mdx` and
`docs/reference/commands.mdx`. The `start` command waits for the
OpenShell `Ready` or `Running` state before agent-specific recovery.
Documentation distinguishes gateway-runtime recovery for OpenClaw and
Hermes from terminal-runtime verification for Deep Agents Code.
- Agent: Codex Desktop
<!-- docs-review-head-sha: df90422 -->
<!-- docs-review-agents-blob-sha: e30afb2 -->

## 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/actions/sandbox/start.test.ts
src/lib/actions/sandbox/process-recovery.test.ts
src/lib/actions/sandbox/connect-probe-observe.test.ts` — 97 passed. `npx
vitest run --project integration test/process-recovery.test.ts
test/process-recovery-supervisor-relaunch.test.ts
test/process-recovery-managed-controller.test.ts
test/process-recovery-custom-agent.test.ts
test/cli/connect-readiness.test.ts
test/cli/connect-recovery-settle.test.ts
test/sandbox-stuck-recovery.test.ts test/cli/dispatch-basics.test.ts
test/cli/docker-outage.test.ts` — 141 passed. `npm run typecheck:cli`
and `npm --prefix nemoclaw run typecheck` — 0 errors. The three added
tests were each confirmed to fail with the fix reverted.
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result:
- [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) — builds
with 0 errors and the 2 warnings already present on `main`.
- [x] 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)

---
Signed-off-by: Tinson Lai <[email protected]>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Sandbox startup now waits for readiness before recovering agent
processes and host forwards.
- Startup and connection commands use a 300-second readiness timeout,
preserve existing containers if readiness times out, and report
configured retry settings.
- OpenClaw restores locked startup access before readiness checks when
Shields are enabled.
- Deep Agents verifies the managed terminal runtime before confirming
startup success.

- **Documentation**
- Updated sandbox startup and command references to describe readiness
checks, timeout behavior, and recovery ordering.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Tinson Lai <[email protected]>
Signed-off-by: Carlos Villela <[email protected]>
Co-authored-by: Carlos Villela <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

recover and start can restart the host gateway and probe before sandbox readiness

3 participants