Skip to content

fix(cli): recover named gateway before sandbox inventory - #10424

Merged
prekshivyas merged 5 commits into
mainfrom
codex/fix-gateway-upgrade-recovery
Aug 27, 2026
Merged

fix(cli): recover named gateway before sandbox inventory#10424
prekshivyas merged 5 commits into
mainfrom
codex/fix-gateway-upgrade-recovery

Conversation

@rsliter

@rsliter rsliter commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Mutating sandbox inventory now recovers the exact named OpenShell gateway before it lists sandboxes. This restores installer recovery after legacy gateway retirement while keeping typed observer failures fail-closed.

Failure diagnostics now include the sanitized error kind, reason, and whether gateway recovery ran.

Related Issue

Fixes #10421

Changes

  • Recover the named gateway before the first inventory read for mutating callers. The read-only check remains observation-only.
  • Stop before inventory when named gateway recovery fails. Do not retry authentication, schema, gateway identity, or invalid-request failures.
  • Report typed, sanitized inventory failures without printing raw OpenShell output.
  • Add an ordering-sensitive regression test for the post-retirement state and focused fail-closed coverage.
  • Root cause: refactor(cli): add typed OpenShell sandbox observer #10132 moved recovery after typed observation. Opaque named-gateway command failures then skipped the transport-only recovery condition.
  • Detection gap: the previous missing-gateway test modeled Unknown gateway, not the opaque command failure observed after installer retirement.

Type of Change

  • 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

  • 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: Existing Update Sandboxes and command-reference pages already document recovery after gateway replacement.
  • 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: Implementation review covered exact-gateway lifecycle, fail-closed error classes, and raw-output redaction. Focused tests protect each boundary.
  • Non-success, skipped, or missing CI check accepted by maintainer; check name, approval link, and follow-up issue:

Documentation Writer Review

  • Documentation writer subagent reviewed the completed changes
  • Result: no-docs-needed
  • Evidence: Existing Update Sandboxes and command-reference pages already document recovery after gateway replacement. Commit 9c0a818 restores that behavior, prevents duplicate completed recovery, and adds sanitized typed diagnostics without changing the documented workflow.
  • Agent: Codex Desktop

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit: Not applicable; this PR does not change scripts/prepare-dgx-station-host.sh.
  • Station profile/scenario: Not applicable.
  • Result: Not applicable.
  • Supporting evidence: Not applicable.

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 validate:pr passed after refreshing origin/main when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above: npx vitest run --project cli src/lib/openshell-sandbox-list.test.ts src/lib/adapters/openshell/sandbox-observer-cli.test.ts src/lib/gateway-runtime-action.test.ts src/lib/actions/upgrade-sandboxes-preflight.test.ts src/lib/actions/upgrade-sandboxes-recovery.test.ts src/lib/actions/maintenance.test.ts src/lib/actions/sandbox/rebuild-flow-helpers.test.ts src/lib/actions/sandbox/rebuild-gateway-drift.test.ts: 8 files and 194 tests passed. npx vitest run --project e2e-support test/e2e/support/openshell-gateway-upgrade-workflow-boundary.test.ts: 1 file and 14 tests passed. npm run test:titles:check passed.
  • Applicable broad gate passed: Not applicable; focused CLI tests and npm run typecheck:cli passed.
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Rebecca Sliter 571084+rsliter@users.noreply.github.com

Summary by CodeRabbit

  • Bug Fixes
    • Improved sandbox listing reliability by attempting bounded recovery when a named gateway is unavailable.
    • Prevented unnecessary retry attempts for authentication, schema, identity, and invalid-request errors.
    • Enhanced error reporting with clearer failure reasons and recovery status.
    • Avoided querying inventory when gateway recovery fails.

@rsliter rsliter self-assigned this Aug 26, 2026
@github-code-quality

github-code-quality Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall line coverage in commit 9c0a818 in the codex/fix-gateway-up... branch remains at 96%, unchanged from commit 9de5af7 in the main branch.

TypeScript / code-coverage/cli

The overall line coverage in commit 9c0a818 in the codex/fix-gateway-up... branch remains at 84%, unchanged from commit 9de5af7 in the main branch.

Show a line coverage summary of the most impacted files.
File main 9de5af7 codex/fix-gateway-up... 9c0a818 +/-
src/lib/onboard...uild-context.ts 74% 74% 0%
src/lib/openshe...sandbox-list.ts 100% 100% 0%
src/lib/sandbox...rce-identity.ts 82% 82% 0%
src/lib/state/ssh-transport.ts 100% 100% 0%
src/lib/onboard...-transaction.ts 93% 94% +1%

Updated August 26, 2026 22:39 UTC

@coderabbitai

coderabbitai Bot commented Aug 26, 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: 88ea1602-2443-4487-94e5-c05a4fece0ec

📥 Commits

Reviewing files that changed from the base of the PR and between e3c098c and cb35b40.

📒 Files selected for processing (3)
  • src/lib/actions/sandbox/rebuild-gateway-drift.test.ts
  • src/lib/openshell-sandbox-list.test.ts
  • src/lib/openshell-sandbox-list.ts

Included review availability: Your plan provides up to 12 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Named-gateway sandbox listing now recovers the gateway before observation. Failed recovery prevents inventory queries. Diagnostics include normalized error metadata and recovery status. Tests cover ordering, healthy gateways, recovery failures, retry suppression, and non-recoverable observation errors.

Changes

Named Gateway Recovery

Layer / File(s) Summary
Recovery before sandbox observation
src/lib/openshell-sandbox-list.ts
Named-gateway requests attempt bounded recovery before listing sandboxes. Failed recovery returns an unreachable transport result. Failure output includes error kind, reason, recovery status, and the original message.
Recovery behavior and diagnostics tests
src/lib/openshell-sandbox-list.test.ts, src/lib/actions/sandbox/rebuild-gateway-drift.test.ts
Tests verify recovery ordering, healthy-gateway handling, failed recovery, retry suppression, fail-closed observation errors, and sanitized diagnostics without raw CLI output.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to cb35b

The change restores named gateway recovery before mutating sandbox inventory and fails closed on unrecoverable typed errors; targeted tests and checks are reported passing, so no actionable merge-blocking risk remains after normal review.

Sequence Diagram(s)

sequenceDiagram
  participant SandboxRequest
  participant captureSandboxListWithGatewayRecovery
  participant recoverNamedGatewayRuntime
  participant OpenShell
  SandboxRequest->>captureSandboxListWithGatewayRecovery: request sandbox inventory
  captureSandboxListWithGatewayRecovery->>recoverNamedGatewayRuntime: recover named gateway
  recoverNamedGatewayRuntime-->>captureSandboxListWithGatewayRecovery: recovery status
  captureSandboxListWithGatewayRecovery->>OpenShell: query sandbox list
  OpenShell-->>captureSandboxListWithGatewayRecovery: inventory or observation error
Loading

Suggested reviewers: cv, apurvvkumaria

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy the coding objectives in [#10421]. Mutating inventory now performs bounded recovery before observation, preserves fail-closed behavior for authentication, schema, identity, and inv…
Out of Scope Changes check ✅ Passed All changed files support named-gateway recovery, sandbox inventory diagnostics, or regression coverage for the linked issue. No unrelated code changes are identified.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: recovering the named gateway before listing sandbox inventory.
Full details: Linked Issues check

Explanation

The changes satisfy the coding objectives in [#10421]. Mutating inventory now performs bounded recovery before observation, preserves fail-closed behavior for authentication, schema, identity, and invalid-request failures, avoids duplicate recovery, and adds sanitized diagnostics with recovery status. Tests cover ordering, successful and failed recovery, healthy gateways, and the post-retirement regression.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-gateway-upgrade-recovery

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

Signed-off-by: Rebecca Sliter <571084+rsliter@users.noreply.github.com>
Signed-off-by: Rebecca Sliter <571084+rsliter@users.noreply.github.com>
@rsliter

rsliter commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Validated the #10421 gateway-upgrade regression on latest PR commit cb35b4039e2622a417a3ab39f8e212319de7992f.

Focused E2E evidence: manual E2E run, using trusted workflow commit 5619e956d778d1952f0a59c69a6444f4cc0b77a2. All five historical upgrade jobs passed:

Each job passed the current gateway upgrade, survivor-state and registry assertions, and all five owned cleanup actions. I checked each raw log and found no occurrence of Failed to query running sandboxes from OpenShell or No active gateway.

The current PR dispatch expands to the broader maintained matrix, so this run also contains unrelated failures outside these five jobs. Those failures do not affect this focused validation.

harjothkhara added a commit to harjothkhara/NemoClaw that referenced this pull request Aug 26, 2026
…utage

The round-3 advisor run (workflow run 33018204086) failed all 9
specialist lanes with 'PR review advisor inference configuration did
not complete' / 'analysis did not complete', not a code finding — a
sibling PR (NVIDIA#10424) passed the same lanes minutes earlier on the same
workflow. I don't have rerun rights on NVIDIA/NemoClaw Actions as an
outside contributor, so this empty commit re-triggers the
pull_request_target 'synchronize' event the advisor workflow listens
for. No source change.

Signed-off-by: harjoth <harjoth.khara@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

PR review advisory complete for commit 9c0a818: read the full review. Read it before deciding whether to request changes, approve, or merge this PR.

All previous runs

@rsliter

rsliter commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Revalidated #10421 after updating the branch from main. This supersedes my earlier cb35b4039 evidence.

Gateway-upgrade results from a broad manual PR run: run 33019075848

  • PR commit: 9c0a818fb4ba906f3858ced0b6354f4d5eb98b47
  • Base and trusted workflow commit: 9de5af7aef0d313231926f71436f1e8d8271bcac
  • Correlation ID: b1fcb7f5-cf4a-463e-b910-110ef1489226

All five issue-owned gateway-upgrade jobs passed:

Each job passed the upgrade assertion, the sandbox-survivor assertion, and all five cleanup checks. I also checked the raw logs for the retired failure signatures; none appeared.

Correction: this was not a focused run. The workflow does not currently support a gateway-only PR selector, so the dispatch expanded to the broad default PR matrix. Cancellation was requested after the five issue-owned jobs completed.

main later advanced to d67d2aaee4ec11c06ca7657a8dbb0adfd45b9d6c. The workflow contract therefore no longer treats this run as current-base E2E evidence. These results apply to the PR commit and base listed above; a new run after updating the PR would be required for exact current-base evidence.

@prekshivyas
prekshivyas merged commit 1d33408 into main Aug 27, 2026
93 of 96 checks passed
@prekshivyas
prekshivyas deleted the codex/fix-gateway-upgrade-recovery branch August 27, 2026 00:00
prekshivyas added a commit that referenced this pull request Aug 27, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Named-gateway recovery now rejects non-recoverable lifecycle probe
failures before it selects or starts a gateway. The change closes the
fail-closed test gap left by #10424.

## Related Issue

Related to #10421. Follow-up to #10424.

## Changes

- Reuse the typed OpenShell CLI error classifier for gateway lifecycle
probes.
- Block recovery for authentication, schema, gateway identity, and
invalid-request failures.
- Stop after a failed post-selection probe without starting the gateway.
- Apply the same guard to the direct named-gateway reconciliation path.
- Add negative tests that assert `gateway select` and `gateway start` do
not run.
- Root cause: raw lifecycle failures were classified as recoverable
topology states.
- Detection gap: #10424 tested these errors only after its mocked
recovery call returned success.

## 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

- [x] Tests added or updated for changed behavior
- [ ] Existing tests cover changed behavior — justification:
- [ ] Tests 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: The implementation
review covered authentication, schema, gateway identity,
invalid-request, and post-selection failure states. Negative tests
assert that forbidden mutations do not run.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## DGX Station Hardware Evidence

- [ ] Tested on DGX Station
- Tested commit: Not applicable; this PR does not change
`scripts/prepare-dgx-station-host.sh`.
- Station profile/scenario: Not applicable.
- Result: Not applicable.
- Supporting evidence: Not applicable.

## 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 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 — `npx vitest run --project cli
--maxWorkers=1 src/lib/gateway-runtime-action.test.ts
src/lib/adapters/openshell/sandbox-observer-cli.test.ts
src/lib/actions/sandbox/gateway-state-drift.test.ts`: 3 files and 47
tests passed. `npm run test:titles:check` passed.
- [ ] Applicable broad gate passed — Not applicable; this change extends
one lifecycle classifier and two current mutation guards.
- [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)

Informational local run: `npm run test:changed` passed 5,485 tests and
failed 16 tests across nine unchanged files under host concurrency.
Eight files passed sequentially; one unchanged uninstall test retained a
five-second timeout. GitHub CI remains the authoritative broad result.

---
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>


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

## Summary by CodeRabbit

* **Bug Fixes**
* Improved sandbox recovery handling when gateway lifecycle checks
detect authentication, schema, identity, or request-validation errors.
* Prevented recovery from selecting or starting a gateway when recovery
is blocked.
* Preserved the original missing-sandbox result and existing registry
data in blocked recovery scenarios.
* Improved recognition of missing administrator privileges during
gateway command checks.
* **Tests**
* Added coverage for blocked recovery, lifecycle probe failures, and
prevention of unintended gateway startup.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Installer upgrade skips named gateway recovery after typed sandbox observation

2 participants