test(cli): split sandbox connect inference tests#4907
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (17)
💤 Files with no reviewable changes (10)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR sanitizes inherited GIT_* env use in git subprocesses, hardens permission and policy regression tests, adds shared sandbox-connect approval-pass test infrastructure and suite coverage, trims unused onboard/inference wiring, and removes miscellaneous unused test/script helpers and imports. ChangesGit environment variable sanitization
Test robustness improvements
Sandbox connect approval-pass testing
Onboard and inference wiring cleanup
Small script and test cleanups
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
E2E Advisor RecommendationRequired E2E: None Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
|
E2E Scenario Advisor RecommendationRequired scenario E2E: None Full scenario advisor summaryE2E Scenario AdvisorBase: Required scenario E2E
Optional scenario E2E
Relevant changed files
|
PR Review AdvisorFindings: 0 needs attention, 2 worth checking, 0 nice ideas Review findings🛠️ Needs attention
🔎 Worth checking
🌱 Nice ideas
Consider writing more tests for
Since last review detailsCurrent findings:
This is an automated advisory review. A human maintainer must make the final merge decision. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/sandbox-connect-inference/helpers.ts (1)
47-329: 🏗️ Heavy liftSplit
setupFixtureinto smaller helpers to satisfy complexity guidance.This function now combines filesystem setup + four executable stubs + state initialization in one block, which makes changes hard to audit and extends blast radius for test-only bugs. Extracting focused builders (state init, openshell stub, docker stub, curl stub, ps stub) would materially improve maintainability.
As per coding guidelines, “Keep function complexity low in JavaScript and TypeScript code.”
🤖 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 `@test/sandbox-connect-inference/helpers.ts` around lines 47 - 329, The setupFixture function is too large; split it into focused helpers to reduce complexity by extracting the state initialization and each executable stub into their own functions—e.g. initStateFile(stateFile, options), writeOpenshellStub(openshellPath, stateFile, sandboxName, options, liveInferenceProvider, liveInferenceModel), writeDockerStub(dockerPath, stateFile, sandboxName), writeCurlStub(curlPath, stateFile, options), writePsStub(psPath) — move the corresponding fs.writeFileSync blocks and related logic into those helpers, keep setupFixture to orchestrate directory creation and call these helpers, and ensure any behavior needed by tests (environment flags, state shape, and returned { tmpDir, stateFile, sandboxName }) remains unchanged.Source: Coding guidelines
🤖 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 `@test/sandbox-connect-inference/helpers.ts`:
- Around line 382-390: The env block in runConnect currently spreads process.env
which leaks host-level test hooks and causes flakiness; replace the spread with
a minimal, deterministic environment by constructing env = { HOME: tmpDir, PATH:
`${path.join(tmpDir, ".local", "bin")}:/usr/bin:/bin`, NEMOCLAW_NO_CONNECT_HINT:
"1", NEMOCLAW_OLLAMA_PORT: "11434", NEMOCLAW_OLLAMA_PROXY_PORT: "11435",
...extraEnv } so only required variables plus extraEnv are present (remove
...process.env), updating the env object used by runConnect in helpers.ts to
ensure hermetic tests while preserving tmpDir, PATH and the NEMOCLAW_* vars.
---
Nitpick comments:
In `@test/sandbox-connect-inference/helpers.ts`:
- Around line 47-329: The setupFixture function is too large; split it into
focused helpers to reduce complexity by extracting the state initialization and
each executable stub into their own functions—e.g. initStateFile(stateFile,
options), writeOpenshellStub(openshellPath, stateFile, sandboxName, options,
liveInferenceProvider, liveInferenceModel), writeDockerStub(dockerPath,
stateFile, sandboxName), writeCurlStub(curlPath, stateFile, options),
writePsStub(psPath) — move the corresponding fs.writeFileSync blocks and related
logic into those helpers, keep setupFixture to orchestrate directory creation
and call these helpers, and ensure any behavior needed by tests (environment
flags, state shape, and returned { tmpDir, stateFile, sandboxName }) remains
unchanged.
🪄 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: d01030c9-09eb-4895-a4de-837b98d5cb5c
📒 Files selected for processing (10)
ci/test-file-size-budget.jsonsrc/lib/core/version.tssrc/lib/onboard/config-sync.test.tssrc/lib/sandbox-base-image.test.tssrc/lib/state/config-io.test.tstest/policies.test.tstest/release-latest-tag.test.tstest/sandbox-connect-inference/auto-pair-approval.test.tstest/sandbox-connect-inference/helpers.tstest/sandbox-connect-inference/route-swap-repair.test.ts
## Summary Removes unused declarations reported by CodeQL's `js/unused-local-variable` rule across onboarding, inference helpers, scripts, and tests. Also stabilizes two test fixtures that blocked local full-hook verification under a restrictive umask and parallel temp-dir usage. ## Changes - Removed unused imports, constants, functions, and destructured bindings from `src/lib/onboard.ts`, inference helpers, the source-shape scanner, and affected tests. - Ratcheted legacy test-file size budgets after shrinking oversized test files. - Made permission and temp-dir assertions deterministic without changing production behavior. ## 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) ## Verification - [x] `npx prek run --all-files` passes - [x] `npm test` passes - [ ] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [x] Docs updated for user-facing behavior changes - [ ] `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) --- Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Updated test file imports and removed unused dependencies across multiple test suites. * Enhanced permission-handling tests for sandbox configuration validation scenarios. * Refactored test fixtures and improved test assertion clarity. * **Chores** * Reduced test file size budgets to reflect code optimization. * Removed unused internal helper functions and imports throughout the codebase. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Splits the sandbox connect inference CLI test coverage into focused files with shared helpers so the suite can parallelize more cleanly. While validating the hook path, this also hardens Git- and umask-sensitive tests that were exposed by running the full CLI coverage hook under an actual commit.
Related Issue
Relates to #4892
Changes
test/sandbox-connect-inference/route-swap-repair.test.tsand auto-pair approval scenarios intotest/sandbox-connect-inference/auto-pair-approval.test.ts.test/sandbox-connect-inference/helpers.tsand remove the legacy size-budget exception for the old monolithic file.umask 077, make temp-policy assertions process-local, and scrub inheritedGIT_*hook state from git-backed test fixtures/version checks.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesnpm run docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
New Features
Improvements