fix(cli): resolve sandbox name for stop and status commands#1135
fix(cli): resolve sandbox name for stop and status commands#1135latenighthackathon wants to merge 7 commits intoNVIDIA:mainfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughReplaced leading SANDBOX_NAME= env-assignment with a new registrySandboxArg() that derives, validates, and shell-quotes a --sandbox from registry.listSandboxes().defaultSandbox; start(), stop(), and showStatus() now pass that computed --sandbox argument to the invoked scripts/commands. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (bin/nemoclaw.js)
participant Registry as Registry
participant API as ensureApiKey
participant Script as start-services.sh / stop/status scripts
CLI->>Registry: listSandboxes() -> defaultSandbox
Registry-->>CLI: default sandbox name
CLI->>CLI: registrySandboxArg() validate & shell-quote "--sandbox <name>"
CLI->>API: await ensureApiKey()
API-->>CLI: API key ensured
CLI->>Script: bash start-services.sh [--sandbox <name>] / stop/status with --sandbox
Script-->>CLI: service PIDs / status (resolved per sandbox)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@bin/nemoclaw.js`:
- Around line 478-481: The current code constructs an environment variable
SANDBOX_NAME (safeName/sandboxEnv) and invokes start-services.sh, but
scripts/start-services.sh prefers NEMOCLAW_SANDBOX and the registry-resolved
sandbox only wins when the script is called with --sandbox; change the
invocation in the run() calls (including the block using defaultSandbox /
safeName and the similar lines at 553-556 and in start()) to pass the resolved
sandbox via the --sandbox argument instead of SANDBOX_NAME, e.g. build a helper
that returns either `--sandbox <safeName>` or `""` and use that helper when
calling run(`bash "${SCRIPTS}/start-services.sh" --stop ...`) so the
registry-resolved sandbox consistently takes precedence; update references to
sandboxEnv, defaultSandbox, and run to use the new helper and remove the
SANDBOX_NAME env construction.
🪄 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: Pro
Run ID: 9f91fc8b-f491-4db8-909c-38bd9725387b
📒 Files selected for processing (1)
bin/nemoclaw.js
`nemoclaw stop` and `nemoclaw status` call start-services.sh without passing SANDBOX_NAME, so the script defaults to "default". If the user named their sandbox anything else during onboarding (e.g. "research"), the PID directory lookup fails — stop cannot find the running processes and status always reports services as stopped. `nemoclaw start` already resolves the sandbox name from the registry. Apply the same resolution to stop() and showStatus() so all three commands use consistent PID directories. Closes NVIDIA#1077 Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com>
Address review feedback: SANDBOX_NAME env var is overridden by NEMOCLAW_SANDBOX in start-services.sh (line 22), so a stale NEMOCLAW_SANDBOX in the user's shell could cause stop/status to look in the wrong PID directory. The --sandbox flag (lines 27-29) overwrites the initial resolution, making the registry value authoritative. Extract registrySandboxArg() helper so start, stop, and status all pass the registry-resolved sandbox consistently via --sandbox. Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com>
2634b50 to
93f4bb5
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
bin/nemoclaw.js (1)
769-773: Optional: avoid re-reading registry inshowStatus()to keep one snapshot.Line 840 already resolves
defaultSandbox, but Line 856 usesregistrySandboxArg()which fetches registry again. Passing the already-read value keeps display/default and service-status lookup perfectly consistent within the same invocation.Proposed refactor
-function registrySandboxArg() { - const { defaultSandbox } = registry.listSandboxes(); +function registrySandboxArg(defaultSandbox = registry.listSandboxes().defaultSandbox) { const safe = defaultSandbox && /^[a-zA-Z0-9._-]+$/.test(defaultSandbox) ? defaultSandbox : null; return safe ? ` --sandbox ${shellQuote(safe)}` : ""; } @@ - run(`bash "${SCRIPTS}/start-services.sh" --status${registrySandboxArg()}`); + run(`bash "${SCRIPTS}/start-services.sh" --status${registrySandboxArg(defaultSandbox)}`);Also applies to: 838-841, 855-856
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@bin/nemoclaw.js` around lines 769 - 773, registrySandboxArg() re-reads the registry snapshot causing inconsistency with the defaultSandbox resolved earlier in showStatus(); change registrySandboxArg to accept an optional sandbox value (e.g., registrySandboxArg(defaultSandbox)) and use that instead of calling registry.listSandboxes() internally, then update callers (notably showStatus() and the code around defaultSandbox resolution) to pass the already-read defaultSandbox so the display and service-status use the same snapshot.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@bin/nemoclaw.js`:
- Around line 769-773: registrySandboxArg() re-reads the registry snapshot
causing inconsistency with the defaultSandbox resolved earlier in showStatus();
change registrySandboxArg to accept an optional sandbox value (e.g.,
registrySandboxArg(defaultSandbox)) and use that instead of calling
registry.listSandboxes() internally, then update callers (notably showStatus()
and the code around defaultSandbox resolution) to pass the already-read
defaultSandbox so the display and service-status use the same snapshot.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d9d23af8-d30a-4cc0-affe-d6f9ab08ba2f
📒 Files selected for processing (1)
bin/nemoclaw.js
Accept an optional defaultSandbox parameter so callers that already read the registry (e.g. showStatus) reuse the same snapshot instead of re-reading it, keeping display and service-status consistent.
The start command should launch services without prompting for an API key. The ensureApiKey call was incorrectly introduced during conflict resolution.
59dae0f to
2e97e4b
Compare
Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com>
2e97e4b to
6b84a32
Compare
|
Closing — this is now resolved on main. The recent TypeScript refactor (#1306, #1307) replaced the shell-based start/stop/status with |
Summary
nemoclaw stopandnemoclaw statuscallstart-services.shwithout passingSANDBOX_NAME, so the script defaults to"default". If the user named their sandbox anything else during onboarding (e.g."research"), the PID directory lookup uses/tmp/nemoclaw-services-default/instead of/tmp/nemoclaw-services-research/— causingstopto miss running processes andstatusto always report services as stopped.nemoclaw startalready resolves the sandbox name from the registry viaregistry.listSandboxes().defaultSandbox. This applies the same resolution tostop()andshowStatus()so all three commands use consistent PID directories.Changes
stop()now resolvesdefaultSandboxfrom the registry and passes it asSANDBOX_NAME(matchingstart())showStatus()reuses thedefaultSandboxalready fetched for the sandbox list display and passes it asSANDBOX_NAMERoot Cause
start-services.shusesSANDBOX_NAMEto construct the PID directory path (/tmp/nemoclaw-services-${SANDBOX_NAME}). Whenstart()passes the correct name butstop()andstatusdon't, they look in different directories and can't find the PID files.Test Plan
start()already resolves sandbox name correctly (line 471-474)stop()andshowStatus()were missing the same resolutionservice-env.test.js)Closes #1077
Summary by CodeRabbit
Signed-off-by: latenighthackathon latenighthackathon@users.noreply.github.com