Skip to content

Commit e560a17

Browse files
committed
fix: tighten gateway lifecycle review follow-ups
1 parent c46e937 commit e560a17

5 files changed

Lines changed: 33 additions & 9 deletions

File tree

‎bin/lib/onboard.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,8 +1484,7 @@ async function createSandbox(gpu, model, provider, preferredInferenceApi = null)
14841484
run(`cp -r "${path.join(ROOT, "nemoclaw-blueprint")}" "${buildCtx}/nemoclaw-blueprint"`);
14851485
run(`cp -r "${path.join(ROOT, "scripts")}" "${buildCtx}/scripts"`);
14861486
run(`rm -rf "${buildCtx}/nemoclaw/node_modules"`, { ignoreError: true });
1487-
run(`rm -rf "${buildCtx}/nemoclaw-blueprint/.venv" "${buildCtx}/nemoclaw-blueprint/.pytest_cache"`, { ignoreError: true });
1488-
run(`find "${buildCtx}/nemoclaw-blueprint" -type d -name __pycache__ -prune -exec rm -rf {} +`, { ignoreError: true });
1487+
run(`bash "${buildCtx}/scripts/clean-staged-tree.sh" "${buildCtx}/nemoclaw-blueprint"`, { ignoreError: true });
14891488

14901489
// Create sandbox (use -- echo to avoid dropping into interactive shell)
14911490
// Pass the base policy so sandbox starts in proxy mode (required for policy updates later)

‎bin/nemoclaw.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function getNamedGatewayLifecycleState() {
102102
const gatewayInfo = captureOpenshell(["gateway", "info", "-g", "nemoclaw"]);
103103
const cleanStatus = stripAnsi(status.output);
104104
const activeGateway = getActiveGatewayName(status.output);
105-
const connected = /Connected/i.test(cleanStatus);
105+
const connected = /^\s*Status:\s*Connected\b/im.test(cleanStatus);
106106
const named = hasNamedGateway(gatewayInfo.output);
107107
const refusing = /Connection refused|client error \(Connect\)|tcp connect error/i.test(cleanStatus);
108108
if (connected && activeGateway === "nemoclaw" && named) {

‎scripts/clean-staged-tree.sh‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
set -euo pipefail
6+
7+
target_dir="${1:-}"
8+
9+
if [ -z "$target_dir" ]; then
10+
echo "usage: $0 <directory>" >&2
11+
exit 1
12+
fi
13+
14+
rm -rf "$target_dir/.venv" "$target_dir/.pytest_cache"
15+
find "$target_dir" -type d -name __pycache__ -prune -exec rm -rf {} + 2>/dev/null || true

‎scripts/setup.sh‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ cp -r "$REPO_DIR/nemoclaw" "$BUILD_CTX/nemoclaw"
201201
cp -r "$REPO_DIR/nemoclaw-blueprint" "$BUILD_CTX/nemoclaw-blueprint"
202202
cp -r "$REPO_DIR/scripts" "$BUILD_CTX/scripts"
203203
rm -rf "$BUILD_CTX/nemoclaw/node_modules"
204-
rm -rf "$BUILD_CTX/nemoclaw-blueprint/.venv" "$BUILD_CTX/nemoclaw-blueprint/.pytest_cache"
205-
find "$BUILD_CTX/nemoclaw-blueprint" -type d -name __pycache__ -prune -exec rm -rf {} + 2>/dev/null || true
204+
bash "$BUILD_CTX/scripts/clean-staged-tree.sh" "$BUILD_CTX/nemoclaw-blueprint" 2>/dev/null || true
206205

207206
# Capture full output to a temp file so we can filter for display but still
208207
# detect failures. The raw log is kept on failure for debugging.

‎test/e2e/test-double-onboard.sh‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ section() {
4141
}
4242
info() { printf '\033[1;34m [info]\033[0m %s\n' "$1"; }
4343

44+
registry_has() {
45+
local sandbox_name="$1"
46+
[ -f "$REGISTRY" ] && grep -q "$sandbox_name" "$REGISTRY"
47+
}
48+
4449
SANDBOX_A="e2e-double-a"
4550
SANDBOX_B="e2e-double-b"
4651
REGISTRY="$HOME/.nemoclaw/sandboxes.json"
@@ -257,7 +262,7 @@ else
257262
fail "Sandbox '$SANDBOX_A' not found in openshell"
258263
fi
259264

260-
if [ -f "$REGISTRY" ] && grep -q "$SANDBOX_A" "$REGISTRY"; then
265+
if registry_has "$SANDBOX_A"; then
261266
pass "Registry contains '$SANDBOX_A'"
262267
else
263268
fail "Registry does not contain '$SANDBOX_A'"
@@ -357,7 +362,7 @@ info "Deleting '$SANDBOX_A' directly in OpenShell to leave a stale NemoClaw regi
357362

358363
openshell sandbox delete "$SANDBOX_A" 2>/dev/null || true
359364

360-
if [ -f "$REGISTRY" ] && grep -q "$SANDBOX_A" "$REGISTRY"; then
365+
if registry_has "$SANDBOX_A"; then
361366
pass "Registry still contains stale '$SANDBOX_A' entry"
362367
else
363368
fail "Registry was unexpectedly cleaned before status reconciliation"
@@ -381,7 +386,7 @@ else
381386
fail "Stale registry reconciliation message missing"
382387
fi
383388

384-
if [ -f "$REGISTRY" ] && grep -q "$SANDBOX_A" "$REGISTRY"; then
389+
if registry_has "$SANDBOX_A"; then
385390
fail "Registry still contains '$SANDBOX_A' after status reconciliation"
386391
else
387392
pass "Registry entry for '$SANDBOX_A' removed after status reconciliation"
@@ -409,7 +414,7 @@ else
409414
fi
410415

411416
if grep -qE \
412-
"Recovered NemoClaw gateway runtime|Removed stale local registry entry|gateway is no longer configured after restart/rebuild|gateway is still refusing connections after restart|gateway trust material rotated after restart" \
417+
"Recovered NemoClaw gateway runtime|gateway is no longer configured after restart/rebuild|gateway is still refusing connections after restart|gateway trust material rotated after restart" \
413418
<<<"$gateway_status_output"; then
414419
pass "Gateway lifecycle response was explicit after gateway stop"
415420
else
@@ -418,6 +423,12 @@ else
418423
printf '%s\n' "$gateway_status_output" | sed 's/^/ /'
419424
fi
420425

426+
if registry_has "$SANDBOX_B"; then
427+
pass "Registry still contains '$SANDBOX_B' after gateway stop"
428+
else
429+
fail "Registry is missing '$SANDBOX_B' after gateway stop"
430+
fi
431+
421432
# ══════════════════════════════════════════════════════════════════
422433
# Phase 7: Final cleanup
423434
# ══════════════════════════════════════════════════════════════════

0 commit comments

Comments
 (0)