Skip to content

fix(status): keep gateway selection out of JSON stdout - #7218

Merged
ericksoa merged 6 commits into
mainfrom
fix/status-json-gateway-select-output/ae
Jul 20, 2026
Merged

fix(status): keep gateway selection out of JSON stdout#7218
ericksoa merged 6 commits into
mainfrom
fix/status-json-gateway-select-output/ae

Conversation

@ericksoa

@ericksoa ericksoa commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the status --json regression introduced by #7113, where OpenShell's ANSI gateway-selection confirmation bypassed the CLI's stdout guard and made Deep Agents target discovery fail to parse the response. Human-readable status output remains unchanged while JSON stdout is again machine-parseable.

Changes

  • Capture openshell gateway select stdout instead of letting the child process write directly to file descriptor 1.
  • Replay captured output through an injected stdio adapter that writes to stderr, keeping the human confirmation visible without contaminating structured stdout or coupling the action to process streams.
  • Add unit coverage for the subprocess stdio contract and integration coverage for the exact ANSI gateway-selection message.
  • Remove the temporary test(e2e): tolerate gateway banner in fresh re-onboard #7233 consumer-side banner sanitizer so the Deep Agents fresh re-onboard check again parses the raw JSON document and detects any producer regression.

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: this restores the existing documented structured status --json contract; stdout routing is an internal implementation detail.
  • 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: pending independent review; no waiver claimed.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes the DCO sign-off declaration 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 — gateway selection unit tests (6 passed); sandbox status JSON integration tests (18 passed); npm run typecheck:cli, bash -n, and shellcheck passed.
  • Exact-head GitHub CI and protected E2E evidence passed — ordinary CI, controller, and child suite.
  • 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 narrow stdout-routing regression; focused unit/integration tests, CLI typecheck, and normal hooks passed.
  • Quality Gates section completed with required justifications or waivers — pending independent sensitive-path review.
  • 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: Aaron Erickson aerickson@nvidia.com

Summary by CodeRabbit

  • Bug Fixes

    • Gateway selection output is now displayed correctly without contaminating structured JSON status responses.
    • sandbox status --json now consistently returns machine-readable output, even when gateway status messages are generated.
  • Tests

    • Expanded coverage for gateway selection output handling and command execution behavior.
    • Updated end-to-end validation to parse status JSON reliably.

Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
@ericksoa ericksoa added area: cli Command line interface, flags, terminal UX, or output bug-fix PR fixes a bug or regression labels Jul 20, 2026
@ericksoa ericksoa self-assigned this Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

selectSandboxOwningGateway now pipes command stdout and forwards it through a stderr adapter. Tests cover execution options, output forwarding, and exclusion of gateway messages from sandbox status JSON.

Changes

Gateway output handling

Layer / File(s) Summary
Forward gateway selection output
src/lib/adapters/stdio.ts, src/lib/actions/sandbox/gateway-select.ts, src/lib/actions/sandbox/gateway-select.test.ts
Gateway selection pipes stdout, writes returned output through the stderr adapter, and tests the configured execution options and forwarding behavior.
Filter gateway messages from JSON status
test/cli/sandbox-status-json.test.ts, test/e2e/.../04-deepagents-code-fresh-reonboard.sh
CLI and end-to-end checks verify that gateway-selection text is excluded from structured JSON parsing.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#7113: Modifies selectSandboxOwningGateway, its runOpenshell invocation, and related tests.
  • NVIDIA/NemoClaw#7233: Modifies the same end-to-end status parsing flow for the gateway-selection banner.

Suggested labels: area: sandbox, integration: dcode

Suggested reviewers: cv, jyaunches

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preventing gateway-selection output from polluting JSON stdout.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/status-json-gateway-select-output/ae

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-code-quality

github-code-quality Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit 64cd07a in the fix/status-json-gate... branch remains at 96%, unchanged from commit 821aa06 in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit 64cd07a in the fix/status-json-gate... branch remains at 80%, unchanged from commit 821aa06 in the main branch.

Show a code coverage summary of the most impacted files.
File main 821aa06 fix/status-json-gate... 64cd07a +/-
src/lib/inferen...lama/process.ts 100% 50% -50%
src/lib/inferen...er-lifecycle.ts 71% 65% -6%
src/lib/actions...teway-select.ts 100% 100% 0%
src/lib/adapters/stdio.ts 0% 0% 0%
src/lib/sandbox...rce-identity.ts 91% 91% 0%

Updated July 20, 2026 14:08 UTC

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

🧹 Nitpick comments (1)
src/lib/actions/sandbox/gateway-select.ts (1)

23-26: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep stdout routing behind an adapter or injected writer.

selectSandboxOwningGateway now calls process.stdout.write directly from an action. Route this through a stdout adapter or injected writer instead, so the action remains decoupled from the host boundary and tests do not need to spy on a global.

As per path instructions, process/stdout routing belongs in src/lib/adapters/** so actions can remain testable.

🤖 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/gateway-select.ts` around lines 23 - 26, Update
selectSandboxOwningGateway to remove its direct process.stdout.write call and
route stdout through an adapter or injected writer defined under the adapters
boundary. Preserve writing result.stdout while keeping process/stdout access out
of the action and allowing tests to provide a controlled writer.

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/gateway-select.ts`:
- Around line 23-26: Update selectSandboxOwningGateway to remove its direct
process.stdout.write call and route stdout through an adapter or injected writer
defined under the adapters boundary. Preserve writing result.stdout while
keeping process/stdout access out of the action and allowing tests to provide a
controlled writer.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 29260ad7-0f35-4b76-b42d-11cc20388e09

📥 Commits

Reviewing files that changed from the base of the PR and between 3c4ea5a and c621279.

📒 Files selected for processing (3)
  • src/lib/actions/sandbox/gateway-select.test.ts
  • src/lib/actions/sandbox/gateway-select.ts
  • test/cli/sandbox-status-json.test.ts

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / high 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 · high 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: cloud-onboard, credential-sanitization, security-posture, onboard-repair, onboard-resume

2 optional E2E recommendations
  • gateway-drift-preflight
  • 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.

ericksoa added 2 commits July 19, 2026 23:08
Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
ericksoa added 3 commits July 20, 2026 06:26
…ay-select-output/ae

Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
@ericksoa
ericksoa requested a review from jyaunches July 20, 2026 14:25

@cjagwani cjagwani 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.

Maintainer review complete: exact-head gates pass; JSON stdout remains machine-parseable while gateway-selection output is preserved on stderr; no unresolved correctness or security findings remain.

@ericksoa
ericksoa merged commit 949b5f9 into main Jul 20, 2026
103 of 104 checks passed
@ericksoa
ericksoa deleted the fix/status-json-gateway-select-output/ae branch July 20, 2026 14:35
@ericksoa ericksoa mentioned this pull request Jul 20, 2026
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 node@22.23.1 -- 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 node@22.23.1 -- 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 <aerickson@nvidia.com>


<!-- 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 <aerickson@nvidia.com>
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 bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants