Skip to content

fix(cli): recover live sandboxes in list when local registry is empty - #5771

Closed
yimoj wants to merge 3 commits into
NVIDIA:mainfrom
yimoj:fix/5714-list-registry-recovery
Closed

yimoj wants to merge 3 commits into
NVIDIA:mainfrom
yimoj:fix/5714-list-registry-recovery

Conversation

@yimoj

@yimoj yimoj commented Jun 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

nemoclaw list printed "No sandboxes registered" while the live OpenShell gateway and container were healthy and nemoclaw <name> status reported Phase: Ready (reported on DGX Station with a Deep Agents sandbox). The list recovery path required a seed — an existing registry entry, an onboard session, or an explicit requested name — before it would probe the gateway. After a local registry loss with no seed, it trusted the empty registry and reported nothing, even though the named-status path could find and reconcile the same sandbox.

Related Issue

Fixes #5714

Changes

  • Widen list recovery for an empty registry. recoverRegistryEntries now attempts recovery whenever the local registry is empty, even with no session/requested-name seed.
  • Bounded, read-only, non-mutating gateway inspection for the unseeded case. Plain nemoclaw list never selects or starts a gateway. It inspects the live sandbox list only when OpenShell is connected to a NemoClaw-managed gateway (nemoclaw or a per-port nemoclaw-<port>) — never a foreign OpenShell gateway. Gateway probes are non-fatal (ignoreProbeErrors), so a hung/timed-out gateway falls back to the empty registry instead of exiting the process, and recovery is gated on a clean (status === 0) sandbox list so error text is never parsed as a sandbox name.
  • Display-only recovery — recovered entries are NOT persisted. The global openshell sandbox list exposes only NAME/CREATED/PHASE, not the agent or gateway binding. Persisting a recovered entry would default agent to openclaw everywhere downstream (state dirs, connect, rebuild, doctor) and permanently misclassify a Deep Agents/Hermes sandbox. Recovered sandboxes are surfaced for the current list only; follow-up named commands reconcile the real agent via the gateway.
  • Honest rendering. Recovered rows show agent/model/provider/GPU as unknown rather than inventing OpenClaw/CPU defaults.
  • getNamedGatewayLifecycleState gains an opt-in ignoreProbeErrors (default keeps existing fatal behavior); captureOpenshell forwards includeStderr so non-fatal probes still capture the gateway status text.

Type of Change

  • Code change (feature, bug fix, or refactor)

Verification

Verified end-to-end through the real worktree CLI (node ./bin/nemoclaw.js …) against a live OpenShell gateway. The local registry was emptied and the onboard session removed to simulate the reporter's registry loss; the on-disk registry is checked after each run.

1. Pre-fix (reporter mismatch) — list blind while a Ready sandbox is live:

$ node ./bin/nemoclaw.js list

  No sandboxes registered. Run `nemoclaw onboard` to get started.

$ node ./bin/nemoclaw.js sbox-4778 status
  Sandbox: sbox-4778
    Model:    nvidia/nemotron-3-super-120b-a12b
    Provider: nvidia-prod
    ...
  Phase: Ready
# docker ps -a → openshell-sbox-4778-… Up   (container healthy, gateway Connected)

2. Post-fix — list rediscovers the live sandboxes (display-only, registry stays empty):

$ node ./bin/nemoclaw.js list

  Recovered 5 sandbox entries from the live OpenShell gateway.

  Sandboxes:
    probe3014x
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    e2e-5468-ollama
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    issue4538-fix
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    sbox-4778
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    dcode5744
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none

$ node -e 'console.log(Object.keys(require(process.env.HOME+"/.nemoclaw/sandboxes.json").sandboxes))'
[]        # recovered for display only — NOT persisted (agent is unknowable from the gateway list)

(Recovery was also re-verified while OpenShell was connected to a NemoClaw per-port gateway nemoclaw-8092 — connected_other to a NemoClaw-managed name still recovers; a foreign gateway name does not.)

3. Post-fix graceful degradation — gateway unreachable, empty registry → no crash, no bogus names:

$ node ./bin/nemoclaw.js list      # gateway down: Connection refused on :8080
                                   # `openshell sandbox list` → transport error
  No sandboxes registered. Run `nemoclaw onboard` to get started.
$ echo $?
0

Targeted + adjacent unit tests pass (registry-recovery, gateway-runtime, inventory, openshell adapter, repro-2666, gateway/connect drift; ~290 tests), npm run typecheck:cli clean, Biome clean; nemoclaw-start (126) passes with the nemoclaw/ subproject deps installed.

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Git hooks passed during commit and push, or npx prek run --from-ref main --to-ref HEAD passes
  • Targeted tests pass for changed behavior
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed

Signed-off-by: Yimo Jiang [email protected]

Summary by CodeRabbit

  • New Features

    • Added an option to include standard error in captured command output.
    • Enhanced gateway recovery to support unseeded “read-only” live inspection, showing recovered sandboxes as transient display-only entries.
    • Inventory rendering now marks recovered sandboxes with agent: unknown and GPU: unknown when applicable.
  • Bug Fixes

    • Gateway lifecycle probe failures can be handled without aborting recovery (including optional stderr-aware handling).
    • Live gateway inspection avoids listing unrelated/foreign gateways, skips when OpenShell isn’t available, and prevents error text from being interpreted as sandbox names.

`nemoclaw list` printed "No sandboxes registered" while the live gateway
and container were healthy and `nemoclaw <name> status` reported Ready,
because the list recovery path required a seed (existing registry entry,
onboard session, or requested name) before probing the gateway. After a
local registry loss with no seed, it trusted the empty registry.

Widen recovery so an empty registry always attempts a bounded, read-only
live-gateway inspection — no gateway select/start — whenever OpenShell is
connected to a NemoClaw-managed gateway (`nemoclaw` or `nemoclaw-<port>`),
never a foreign one. Recovered sandboxes are surfaced display-only and are
NOT persisted: the global `openshell sandbox list` exposes only
NAME/CREATED/PHASE, so a persisted entry would default agent to "openclaw"
everywhere downstream and permanently misclassify a Deep Agents/Hermes
sandbox. The renderer shows agent/model/provider/GPU as "unknown" for these
rows rather than inventing OpenClaw/CPU defaults. Gateway probes are
non-fatal (ignoreProbeErrors) so a hung gateway falls back to the empty
registry, and recovery is gated on a clean (status 0) `sandbox list` so
error text is never parsed as sandbox names.

Signed-off-by: Yimo Jiang <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2b02125f-84e2-482e-9087-9ecfd88c106a

📥 Commits

Reviewing files that changed from the base of the PR and between 17ec662 and 9f20898.

📒 Files selected for processing (2)
  • src/lib/adapters/openshell/runtime.ts
  • src/lib/gateway-runtime-action.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/lib/adapters/openshell/runtime.ts
  • src/lib/gateway-runtime-action.ts

📝 Walkthrough

Walkthrough

Adds read-only live-gateway registry recovery for empty local state, carries a recoveredFromGateway marker through registry and inventory rows, and forwards includeStderr and ignoreProbeErrors into OpenShell lifecycle probes.

Changes

Live gateway recovery and inventory display

Layer / File(s) Summary
OpenShell probe stderr handling
src/lib/adapters/openshell/runtime.ts, src/lib/gateway-runtime-action.ts, src/lib/gateway-runtime-action.test.ts
captureOpenshell accepts includeStderr, and getNamedGatewayLifecycleState forwards ignoreProbeErrors into probe options for openshell status and openshell gateway info.
Read-only live gateway recovery
src/lib/registry-recovery-action.ts, src/lib/registry-recovery-action.test.ts
Empty registries trigger live-gateway inspection, recovery can return display-only ephemeral sandboxes in read-only mode, and tests cover the empty-registry, foreign-gateway, missing-gateway, and OpenShell-unavailable paths.
Recovered sandbox marker and inventory output
src/lib/state/registry.ts, src/lib/inventory/index.ts, src/lib/inventory/index.test.ts
SandboxEntry and SandboxInventoryRow gain recoveredFromGateway, and inventory row/text rendering uses it to show unknown agent and GPU values for gateway-recovered sandboxes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested labels

area: cli, bug-fix, integration: openclaw

Suggested reviewers

  • cv
  • sandl99

Poem

A rabbit peeks through gateway mist,
Finds sandboxes on the list.
Stderr kept and markers bright,
nemoclaw list now shows the light. 🐇

🚥 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 describes the main change: recovering and listing live sandboxes when the local registry is empty.
Linked Issues check ✅ Passed The changes match #5714 by making nemoclaw list recover live gateway sandboxes from an empty registry and display them read-only.
Out of Scope Changes check ✅ Passed No obvious unrelated changes; the helper updates, display markers, and tests all support the live-recovery fix.
Docstring Coverage ✅ Passed Docstring coverage is 95.83% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

yimoj added 2 commits June 25, 2026 07:21
Add TSDoc summaries to the functions introduced/changed for NVIDIA#5714
(registry recovery, gateway lifecycle classification, OpenShell capture,
and inventory row projection) to satisfy the CodeRabbit docstring-coverage
pre-merge check. No behavior change.

Signed-off-by: Yimo Jiang <[email protected]>
Add TSDoc to the OpenShell runtime adapter helpers and the gateway
status-parsing helpers in the files touched by NVIDIA#5714 to clear the
CodeRabbit docstring-coverage threshold (80%). No behavior change.

Signed-off-by: Yimo Jiang <[email protected]>
@yimoj

yimoj commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #5786, opened from NVIDIA/NemoClaw branch so trusted PR advisor workflows can run.

@yimoj

yimoj commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #5786.

@yimoj yimoj closed this Jun 25, 2026
cv added a commit that referenced this pull request Jun 26, 2026
…#5786)

## Summary

`nemoclaw list` printed "No sandboxes registered" while the live
OpenShell gateway and container were healthy and `nemoclaw <name>
status` reported `Phase: Ready` (reported on DGX Station with a Deep
Agents sandbox). The `list` recovery path required a *seed* — an
existing registry entry, an onboard session, or an explicit requested
name — before it would probe the gateway. After a local registry loss
with no seed, it trusted the empty registry and reported nothing, even
though the named-status path could find and reconcile the same sandbox.

## Related Issue

Fixes #5714

## Changes

- **Widen list recovery for an empty registry.**
`recoverRegistryEntries` now attempts recovery whenever the local
registry is empty, even with no session/requested-name seed.
- **Bounded, read-only, non-mutating gateway inspection for the unseeded
case.** Plain `nemoclaw list` never selects or starts a gateway. It
inspects the live sandbox list only when OpenShell is connected to a
**NemoClaw-managed** gateway (`nemoclaw` or a per-port
`nemoclaw-<port>`) — never a foreign OpenShell gateway. Gateway probes
are non-fatal (`ignoreProbeErrors`), so a hung/timed-out gateway falls
back to the empty registry instead of exiting the process, and recovery
is gated on a clean (`status === 0`) `sandbox list` so error text is
never parsed as a sandbox name.
- **Display-only recovery — recovered entries are NOT persisted.** The
global `openshell sandbox list` exposes only NAME/CREATED/PHASE, not the
agent or gateway binding. Persisting a recovered entry would default
`agent` to `openclaw` everywhere downstream (state dirs, connect,
rebuild, doctor) and permanently misclassify a Deep Agents/Hermes
sandbox. Recovered sandboxes are surfaced for the current `list` only;
follow-up named commands reconcile the real agent via the gateway.
- **Honest rendering.** Recovered rows show
`agent`/`model`/`provider`/`GPU` as `unknown` rather than inventing
OpenClaw/CPU defaults.
- `getNamedGatewayLifecycleState` gains an opt-in `ignoreProbeErrors`
(default keeps existing fatal behavior); `captureOpenshell` forwards
`includeStderr` so non-fatal probes still capture the gateway status
text.

## Type of Change

- [x] Code change (feature, bug fix, or refactor)

## Verification

Verified end-to-end through the real worktree CLI (`node
./bin/nemoclaw.js …`) against a live OpenShell gateway. The local
registry was emptied and the onboard session removed to simulate the
reporter's registry loss; the on-disk registry is checked after each
run.

**1. Pre-fix (reporter mismatch) — `list` blind while a Ready sandbox is
live:**

```console
$ node ./bin/nemoclaw.js list

  No sandboxes registered. Run `nemoclaw onboard` to get started.

$ node ./bin/nemoclaw.js sbox-4778 status
  Sandbox: sbox-4778
    Model:    nvidia/nemotron-3-super-120b-a12b
    Provider: nvidia-prod
    ...
  Phase: Ready
# docker ps -a → openshell-sbox-4778-… Up   (container healthy, gateway Connected)
```

**2. Post-fix — `list` rediscovers the live sandboxes (display-only,
registry stays empty):**

```console
$ node ./bin/nemoclaw.js list

  Recovered 5 sandbox entries from the live OpenShell gateway.

  Sandboxes:
    probe3014x
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    e2e-5468-ollama
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    issue4538-fix
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    sbox-4778
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    dcode5744
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none

$ node -e 'console.log(Object.keys(require(process.env.HOME+"/.nemoclaw/sandboxes.json").sandboxes))'
[]        # recovered for display only — NOT persisted (agent is unknowable from the gateway list)
```

(Recovery was also re-verified while OpenShell was connected to a
NemoClaw per-port gateway `nemoclaw-8092` — `connected_other` to a
NemoClaw-managed name still recovers; a foreign gateway name does not.)

**3. Post-fix graceful degradation — gateway unreachable, empty registry
→ no crash, no bogus names:**

```console
$ node ./bin/nemoclaw.js list      # gateway down: Connection refused on :8080
                                   # `openshell sandbox list` → transport error
  No sandboxes registered. Run `nemoclaw onboard` to get started.
$ echo $?
0
```

Targeted + adjacent unit tests pass (registry-recovery, gateway-runtime,
inventory, openshell adapter, repro-2666, gateway/connect drift; ~290
tests), `npm run typecheck:cli` clean, Biome clean; `nemoclaw-start`
(126) passes with the `nemoclaw/` subproject deps installed.

- [x] PR description includes the DCO sign-off declaration and every
commit appears as `Verified` in GitHub
- [x] Git hooks passed during commit and push, or `npx prek run
--from-ref main --to-ref HEAD` passes
- [x] Targeted tests pass for changed behavior
- [x] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed

Signed-off-by: Yimo Jiang <[email protected]>

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

* **New Features**
* Improved recovery for empty registries with unseeded sessions via
bounded, read-only ephemeral results.
* Inventory rendering now supports gateway-recovered sandboxes (uses
`unknown` agent/GPU and shows `phase` when available).
  * Added live sandbox phase parsing with `parseLiveSandboxEntries`.
* **Bug Fixes**
* Added stderr retention for lifecycle/probe classification
(`includeStderr`) when probe errors are ignored.
* Prevented transient recovery/display markers (`recoveredFromGateway`,
`livePhase`) from persisting to disk.
* **Tests**
* Added cases for unseeded vs seeded recovery, probe option behavior,
and phase parsing variations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---
Supersedes #5771 (reopened from NVIDIA/NemoClaw branch so trusted
advisor workflows can run).

---------

Signed-off-by: Yimo Jiang <[email protected]>
Co-authored-by: Carlos Villela <[email protected]>
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
…NVIDIA#5786)

## Summary

`nemoclaw list` printed "No sandboxes registered" while the live
OpenShell gateway and container were healthy and `nemoclaw <name>
status` reported `Phase: Ready` (reported on DGX Station with a Deep
Agents sandbox). The `list` recovery path required a *seed* — an
existing registry entry, an onboard session, or an explicit requested
name — before it would probe the gateway. After a local registry loss
with no seed, it trusted the empty registry and reported nothing, even
though the named-status path could find and reconcile the same sandbox.

## Related Issue

Fixes NVIDIA#5714

## Changes

- **Widen list recovery for an empty registry.**
`recoverRegistryEntries` now attempts recovery whenever the local
registry is empty, even with no session/requested-name seed.
- **Bounded, read-only, non-mutating gateway inspection for the unseeded
case.** Plain `nemoclaw list` never selects or starts a gateway. It
inspects the live sandbox list only when OpenShell is connected to a
**NemoClaw-managed** gateway (`nemoclaw` or a per-port
`nemoclaw-<port>`) — never a foreign OpenShell gateway. Gateway probes
are non-fatal (`ignoreProbeErrors`), so a hung/timed-out gateway falls
back to the empty registry instead of exiting the process, and recovery
is gated on a clean (`status === 0`) `sandbox list` so error text is
never parsed as a sandbox name.
- **Display-only recovery — recovered entries are NOT persisted.** The
global `openshell sandbox list` exposes only NAME/CREATED/PHASE, not the
agent or gateway binding. Persisting a recovered entry would default
`agent` to `openclaw` everywhere downstream (state dirs, connect,
rebuild, doctor) and permanently misclassify a Deep Agents/Hermes
sandbox. Recovered sandboxes are surfaced for the current `list` only;
follow-up named commands reconcile the real agent via the gateway.
- **Honest rendering.** Recovered rows show
`agent`/`model`/`provider`/`GPU` as `unknown` rather than inventing
OpenClaw/CPU defaults.
- `getNamedGatewayLifecycleState` gains an opt-in `ignoreProbeErrors`
(default keeps existing fatal behavior); `captureOpenshell` forwards
`includeStderr` so non-fatal probes still capture the gateway status
text.

## Type of Change

- [x] Code change (feature, bug fix, or refactor)

## Verification

Verified end-to-end through the real worktree CLI (`node
./bin/nemoclaw.js …`) against a live OpenShell gateway. The local
registry was emptied and the onboard session removed to simulate the
reporter's registry loss; the on-disk registry is checked after each
run.

**1. Pre-fix (reporter mismatch) — `list` blind while a Ready sandbox is
live:**

```console
$ node ./bin/nemoclaw.js list

  No sandboxes registered. Run `nemoclaw onboard` to get started.

$ node ./bin/nemoclaw.js sbox-4778 status
  Sandbox: sbox-4778
    Model:    nvidia/nemotron-3-super-120b-a12b
    Provider: nvidia-prod
    ...
  Phase: Ready
# docker ps -a → openshell-sbox-4778-… Up   (container healthy, gateway Connected)
```

**2. Post-fix — `list` rediscovers the live sandboxes (display-only,
registry stays empty):**

```console
$ node ./bin/nemoclaw.js list

  Recovered 5 sandbox entries from the live OpenShell gateway.

  Sandboxes:
    probe3014x
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    e2e-5468-ollama
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    issue4538-fix
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    sbox-4778
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none
    dcode5744
      agent: unknown  model: unknown  provider: unknown  GPU: unknown  policies: none

$ node -e 'console.log(Object.keys(require(process.env.HOME+"/.nemoclaw/sandboxes.json").sandboxes))'
[]        # recovered for display only — NOT persisted (agent is unknowable from the gateway list)
```

(Recovery was also re-verified while OpenShell was connected to a
NemoClaw per-port gateway `nemoclaw-8092` — `connected_other` to a
NemoClaw-managed name still recovers; a foreign gateway name does not.)

**3. Post-fix graceful degradation — gateway unreachable, empty registry
→ no crash, no bogus names:**

```console
$ node ./bin/nemoclaw.js list      # gateway down: Connection refused on :8080
                                   # `openshell sandbox list` → transport error
  No sandboxes registered. Run `nemoclaw onboard` to get started.
$ echo $?
0
```

Targeted + adjacent unit tests pass (registry-recovery, gateway-runtime,
inventory, openshell adapter, repro-2666, gateway/connect drift; ~290
tests), `npm run typecheck:cli` clean, Biome clean; `nemoclaw-start`
(126) passes with the `nemoclaw/` subproject deps installed.

- [x] PR description includes the DCO sign-off declaration and every
commit appears as `Verified` in GitHub
- [x] Git hooks passed during commit and push, or `npx prek run
--from-ref main --to-ref HEAD` passes
- [x] Targeted tests pass for changed behavior
- [x] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed

Signed-off-by: Yimo Jiang <[email protected]>

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

* **New Features**
* Improved recovery for empty registries with unseeded sessions via
bounded, read-only ephemeral results.
* Inventory rendering now supports gateway-recovered sandboxes (uses
`unknown` agent/GPU and shows `phase` when available).
  * Added live sandbox phase parsing with `parseLiveSandboxEntries`.
* **Bug Fixes**
* Added stderr retention for lifecycle/probe classification
(`includeStderr`) when probe errors are ignored.
* Prevented transient recovery/display markers (`recoveredFromGateway`,
`livePhase`) from persisting to disk.
* **Tests**
* Added cases for unseeded vs seeded recovery, probe option behavior,
and phase parsing variations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---
Supersedes NVIDIA#5771 (reopened from NVIDIA/NemoClaw branch so trusted
advisor workflows can run).

---------

Signed-off-by: Yimo Jiang <[email protected]>
Co-authored-by: Carlos Villela <[email protected]>
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression labels Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression

Projects

None yet

2 participants