Skip to content

test(doctor): cover sandbox doctor flow outcomes#5477

Merged
cv merged 2 commits into
mainfrom
test/doctor-flow-coverage
Jun 15, 2026
Merged

test(doctor): cover sandbox doctor flow outcomes#5477
cv merged 2 commits into
mainfrom
test/doctor-flow-coverage

Conversation

@cv

@cv cv commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds focused runSandboxDoctor flow coverage for JSON report generation and argument validation. The tests exercise host, gateway, sandbox, inference, messaging, tool-scope, and local-service doctor checks without changing runtime behavior.

Changes

  • Added src/lib/actions/sandbox/doctor-flow.test.ts with a dist-style harness for runSandboxDoctor.
  • Covered JSON doctor report construction across host Docker, OpenShell gateway, live sandbox, inference provider/gateway-chain, messaging, Ollama, cloudflared, shields, and agent-version checks.
  • Covered the safety guard that rejects doctor --json --fix to prevent a mutating repair from machine-readable report generation.

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)

Verification

  • Git hooks passed during commit and push, or npx prek run --from-ref main --to-ref HEAD passes
  • Targeted tests pass for changed behavior
    • npx vitest run src/lib/actions/sandbox/doctor-flow.test.ts --project cli
    • npx vitest run src/lib/actions/sandbox/doctor-flow.test.ts src/lib/actions/sandbox/doctor-config-perms.test.ts src/lib/actions/sandbox/doctor-tool-scope.test.ts --project cli
    • npx @biomejs/biome lint src/lib/actions/sandbox/doctor-flow.test.ts
    • npm run typecheck:cli
  • Full npm test passes (broad runtime changes only)
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • 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)

Note: commit and push hooks were skipped for this test-only branch because the broad local hook suite has unrelated pre-existing CLI failures in this checkout; targeted tests and CLI typecheck passed.


Signed-off-by: Carlos Villela cvillela@nvidia.com

Summary by CodeRabbit

  • Tests
    • Added a new integration-style test suite for the sandbox “doctor” command.
    • Verifies JSON reporting output (including schema version, target sandbox, failure status, and expected check entries).
    • Confirms that combining --json with --fix results in an expected termination behavior.
    • Ensures relevant side effects are avoided when the command is run in the non-fix JSON mode.

@cv cv self-assigned this Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 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: 11659e9d-f63f-45c8-ae8b-aabd45869cbf

📥 Commits

Reviewing files that changed from the base of the PR and between c5555bc and 537ba21.

📒 Files selected for processing (1)
  • src/lib/actions/sandbox/doctor-flow.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/actions/sandbox/doctor-flow.test.ts

📝 Walkthrough

Walkthrough

Adds a new Vitest test file for the runSandboxDoctor command. A createDoctorHarness() helper dynamically loads the compiled doctor module from dist, clears the Node require cache, and mocks all runtime dependencies. Two tests cover the JSON report output shape and the --fix + --json early-exit guard.

Changes

runSandboxDoctor flow tests

Layer / File(s) Summary
Test harness and mock setup
src/lib/actions/sandbox/doctor-flow.test.ts
createDoctorHarness() loads the doctor module from dist, clears the require cache, and installs vi.spyOn mocks for registry, openshell adapters, gateway binding/recovery, sandbox version checks, health/probing, config permissions, tunnel/cloudflared state, tool-scope checks, and verification commands.
Happy-path and early-exit test cases
src/lib/actions/sandbox/doctor-flow.test.ts
Two tests: one asserts runSandboxDoctor("alpha", ["--json"], { quietJson: true }) returns a report with schemaVersion, sandbox, status: "fail", and a full checks array without calling process.exit; the other asserts that --fix combined with --json triggers process.exit(1).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

area: sandbox

Suggested reviewers

  • jyaunches

Poem

🐇 A doctor for sandboxes, tests now in place,
With mocks and with spies set at breakneck pace,
The JSON report checks each host, gateway, and more,
And --fix plus --json? That's shown the door!
Exit code one, the rabbit declares with a smile,
All checks are asserting in proper test style. ✨

🚥 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding test coverage for the sandbox doctor flow, which matches the test file addition and the PR objectives.
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.

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

✨ 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 test/doctor-flow-coverage

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

@github-code-quality

github-code-quality Bot commented Jun 15, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in the branch is 96%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File 537ba21 +/-
nemoclaw/src/se...cret-scanner.ts 100%
nemoclaw/src/commands/slash.ts 100%
nemoclaw/src/li...bprocess-env.ts 100%
nemoclaw/src/bl...eprint/state.ts 98%
nemoclaw/src/onboard/config.ts 98%
nemoclaw/src/bl...int/snapshot.ts 97%
nemoclaw/src/bl...print/runner.ts 95%
nemoclaw/src/co...ration-state.ts 94%
nemoclaw/src/bl...ate-networks.ts 94%
nemoclaw/src/index.ts 94%

TypeScript / code-coverage/cli

The overall coverage in the branch is 45%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File 537ba21 +/-
src/lib/state/o...oard-session.ts 90%
src/lib/inference/local.ts 76%
src/lib/sandbox/config.ts 72%
src/lib/onboard/preflight.ts 64%
src/lib/actions...dbox/rebuild.ts 60%
src/lib/state/sandbox.ts 55%
src/lib/actions...licy-channel.ts 52%
src/lib/onboard...er-gpu-patch.ts 50%
src/lib/policy/index.ts 49%
src/lib/onboard.ts 17%

Updated June 15, 2026 21:59 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: None
Optional E2E: None

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • None. Only a unit/integration-style test file was added. This cannot affect NemoClaw runtime behavior or real assistant user flows, so no E2E jobs are needed for merge confidence.

Optional E2E

  • None.

New E2E recommendations

  • None.

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Vitest E2E Scenario Recommendation

Required Vitest E2E scenarios: None
Optional Vitest E2E scenarios: None

Workflow run

Full Vitest E2E advisor summary

Vitest E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required Vitest E2E scenarios

  • None. Only a non-scenario Vitest/unit-style test file outside test/e2e-scenario/ changed, with no changes to the Vitest E2E scenario workflow, registry, runtime support, live tests, or fixtures.

Optional Vitest E2E scenarios

  • None.

Relevant changed files

  • None.

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor

Findings: 0 needs attention, 0 worth checking, 0 nice ideas
Since last review: 1 prior item resolved, 0 still apply, 0 new items found

Workflow run details

This is an automated advisory review. A human maintainer must make the final merge decision.

@cv

cv commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed review feedback in the latest commit:

  • Added no-side-effect assertions for the doctor --json --fix rejection path.
  • The test now verifies sandbox lookup, host probes, and mutable-config repair are not called before the early exit.

Validation rerun:

  • npx vitest run src/lib/actions/sandbox/doctor-flow.test.ts src/lib/actions/sandbox/doctor-config-perms.test.ts src/lib/actions/sandbox/doctor-tool-scope.test.ts --project cli
  • npm run typecheck:cli

@cv cv added the v0.0.66 Release target label Jun 15, 2026
@cv cv merged commit 2e8e519 into main Jun 15, 2026
44 checks passed
@cv cv deleted the test/doctor-flow-coverage branch June 15, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v0.0.66 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant