Repository navigation
feat(tooling): SPDX --fix, hook ordering, and strict shellcheck fixes - #670
Conversation
Drop --severity=warning and --exclude=SC1091 so local hooks match strict shellcheck; script issues are fixed in-tree instead.
Add shellcheck shell=bash directive so SC2148 is satisfied without weakening global hook rules.
Use >/path form so shellcheck does not flag spacing around redirects.
Replace SC2015 if/else chains with explicit if/else, add source directives for dynamic sources, fix exit-status checks, and remove unused variables so strict shellcheck passes.
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughPre-commit hook ordering changed to run spdx-headers earlier with a Changes
Sequence Diagram(s)sequenceDiagram
participant PreCommit as Pre-commit
participant HookRunner as Hook runner
participant Script as check-spdx-headers.sh
participant FS as Repository files
PreCommit->>HookRunner: invoke `spdx-headers` hook (priority 4, --fix)
HookRunner->>Script: run script with file list and `--fix`
Script->>FS: read top ~16 lines of each target file
alt header present
Script->>FS: leave file unchanged
Script-->>HookRunner: report OK
else header missing
Script->>FS: insert SPDX block (preserve shebang, use comment style)
Script-->>HookRunner: report Added header
end
HookRunner-->>PreCommit: aggregate results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@package.json`:
- Around line 40-42: The lint-staged glob "nemoclaw-blueprint/**/*.py" is
including blueprint __init__.py files (e.g.
nemoclaw-blueprint/orchestrator/__init__.py) while .pre-commit-config.yaml
explicitly excludes them; update the lint-staged entry for
"nemoclaw-blueprint/**/*.py" to also exclude __init__.py files (for example by
adding a negative glob such as "nemoclaw-blueprint/**/__init__.py" prefixed with
"!" or an equivalent exclusion) so the SPDX header fixer and lint-staged
behavior match.
In `@scripts/check-spdx-headers.sh`:
- Around line 65-82: The temp-file rewrite currently creates a 0600 file and
then mv's it over the original, losing executable bits; before mv "$tmp" "$file"
set the temp file's mode to match the original (e.g. run chmod
--reference="$file" "$tmp" or use stat to get and apply the original mode)
inside the insert_spdx block that creates tmp so the original file permissions
(including +x) are preserved when moving the temp into place.
In `@test/e2e/test-double-onboard.sh`:
- Around line 125-129: The pipeline using echo "$outputN" | grep -q should be
replaced with here-strings to avoid SIGPIPE when running with set -o pipefail:
for each check that currently uses echo "$output1" | grep -q "..." (and the
similar occurrences for output2 and output3 around the other ranges), change to
using grep -q with a here-string (grep -q "pattern" <<< "$output1") so grep
reads directly from the here-string; update the three blocks that test for
"Sandbox '${SANDBOX_A}' created" and the other two sandbox/step checks (the ones
referencing output1/output2/output3 and variables like SANDBOX_A) to use this
here-string form and keep the existing pass/fail calls unchanged.
In `@test/e2e/test-full-e2e.sh`:
- Around line 207-211: Replace the pipeline-based grep checks that read from
shell variables (e.g., echo "$list_output" | grep -Fq -- "$SANDBOX_NAME", echo
"$policy_output" | grep -q ...) with here-strings to avoid pipefail/SIGPIPE
issues; locate the grep invocations that use echo of variables such as
list_output, policy_output (and similar checks around the sandbox/name
assertions) and change them to use grep -Fq -- "$SANDBOX_NAME" <<<"$list_output"
(and grep -q <<<"$policy_output" for the policy checks) so grep reads directly
from the variable without a pipe.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3f48d530-7af6-4c51-aa87-eb084f0456c9
📒 Files selected for processing (8)
.pre-commit-config.yamlpackage.jsonscripts/check-spdx-headers.shscripts/husky-env.shscripts/test-inference-local.shscripts/test-inference.shtest/e2e/test-double-onboard.shtest/e2e/test-full-e2e.sh
|
Thanks for contributing to the tooling, adding SPDX fix, hook ordering, and strict shellcheck fixes will be really helpful for improving testing and code quality. |
Address CodeRabbit review feedback on PR NVIDIA#670: - check-spdx-headers.sh: capture and restore original file mode when rewriting via mktemp+mv so executable bits are not lost - test-double-onboard.sh, test-full-e2e.sh: replace echo|grep -q pipes with here-strings to avoid SIGPIPE under pipefail; convert A&&B||C patterns to proper if/then/else (SC2015); check exit codes directly (SC2181); remove unused skip() function (SC2329) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Convert A&&B||C patterns to proper if/then/else (SC2015) in e2e-test.sh, and replace ls with find in backup-workspace.sh (SC2012). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
fix: address CodeRabbit review feedback
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 `@scripts/backup-workspace.sh`:
- Around line 83-84: In do_restore(), the unguarded find assignment for ts can
cause the script to exit under set -euo pipefail if BACKUP_BASE doesn't exist;
guard the failure by first testing the directory (e.g., if [ -d "$BACKUP_BASE"
]; then ts="$(find "$BACKUP_BASE" -mindepth 1 -maxdepth 1 -type d -printf '%f\n'
2>/dev/null | sort -r | head -n1)"; else ts=""; fi) or alternatively append ||
true to the find pipeline (ts="$(find ... 2>/dev/null | sort -r | head -n1 ||
true)") so the command won't abort the script and the subsequent [ -n "$ts" ] ||
fail "No backups found in ${BACKUP_BASE}/" path still runs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 91b4d809-d7ae-4965-bc5e-c478ee3c706e
📒 Files selected for processing (5)
scripts/backup-workspace.shscripts/check-spdx-headers.shtest/e2e-test.shtest/e2e/test-double-onboard.shtest/e2e/test-full-e2e.sh
Take upstream semantic changes (ncp profile, nvidia-prod provider, wording updates) with our structural improvements (herestrings, if/then/else). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The unguarded find pipeline in do_restore() aborts under set -euo pipefail when BACKUP_BASE doesn't exist, before the descriptive error on the next line can run. Append || true so the [ -n "$ts" ] guard produces a clear "No backups found" message instead. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…NVIDIA#670) * feat(scripts): add SPDX --fix and exclude blueprint __init__.py files * chore: SPDX hook at priority 4 with --fix; lint-staged uses --fix * chore: add SPDX headers to shell scripts missing them * chore(pre-commit): run shellcheck with default rules Drop --severity=warning and --exclude=SC1091 so local hooks match strict shellcheck; script issues are fixed in-tree instead. * fix(scripts): declare bash for shellcheck in husky-env Add shellcheck shell=bash directive so SC2148 is satisfied without weakening global hook rules. * chore(scripts): normalize redirection in test-inference helpers Use >/path form so shellcheck does not flag spacing around redirects. * fix(e2e): satisfy shellcheck in onboard and full e2e tests Replace SC2015 if/else chains with explicit if/else, add source directives for dynamic sources, fix exit-status checks, and remove unused variables so strict shellcheck passes. * fix: preserve file permissions in SPDX fixer and harden e2e test scripts Address CodeRabbit review feedback on PR NVIDIA#670: - check-spdx-headers.sh: capture and restore original file mode when rewriting via mktemp+mv so executable bits are not lost - test-double-onboard.sh, test-full-e2e.sh: replace echo|grep -q pipes with here-strings to avoid SIGPIPE under pipefail; convert A&&B||C patterns to proper if/then/else (SC2015); check exit codes directly (SC2181); remove unused skip() function (SC2329) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: resolve shellcheck warnings in e2e-test.sh and backup-workspace.sh Convert A&&B||C patterns to proper if/then/else (SC2015) in e2e-test.sh, and replace ls with find in backup-workspace.sh (SC2012). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: guard find in do_restore against missing backup directory The unguarded find pipeline in do_restore() aborts under set -euo pipefail when BACKUP_BASE doesn't exist, before the descriptive error on the next line can run. Append || true so the [ -n "$ts" ] guard produces a clear "No backups found" message instead. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --------- Co-authored-by: Carlos Villela <[email protected]> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
…NVIDIA#670) * feat(scripts): add SPDX --fix and exclude blueprint __init__.py files * chore: SPDX hook at priority 4 with --fix; lint-staged uses --fix * chore: add SPDX headers to shell scripts missing them * chore(pre-commit): run shellcheck with default rules Drop --severity=warning and --exclude=SC1091 so local hooks match strict shellcheck; script issues are fixed in-tree instead. * fix(scripts): declare bash for shellcheck in husky-env Add shellcheck shell=bash directive so SC2148 is satisfied without weakening global hook rules. * chore(scripts): normalize redirection in test-inference helpers Use >/path form so shellcheck does not flag spacing around redirects. * fix(e2e): satisfy shellcheck in onboard and full e2e tests Replace SC2015 if/else chains with explicit if/else, add source directives for dynamic sources, fix exit-status checks, and remove unused variables so strict shellcheck passes. * fix: preserve file permissions in SPDX fixer and harden e2e test scripts Address CodeRabbit review feedback on PR NVIDIA#670: - check-spdx-headers.sh: capture and restore original file mode when rewriting via mktemp+mv so executable bits are not lost - test-double-onboard.sh, test-full-e2e.sh: replace echo|grep -q pipes with here-strings to avoid SIGPIPE under pipefail; convert A&&B||C patterns to proper if/then/else (SC2015); check exit codes directly (SC2181); remove unused skip() function (SC2329) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: resolve shellcheck warnings in e2e-test.sh and backup-workspace.sh Convert A&&B||C patterns to proper if/then/else (SC2015) in e2e-test.sh, and replace ls with find in backup-workspace.sh (SC2012). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: guard find in do_restore against missing backup directory The unguarded find pipeline in do_restore() aborts under set -euo pipefail when BACKUP_BASE doesn't exist, before the descriptive error on the next line can run. Append || true so the [ -n "$ts" ] guard produces a clear "No backups found" message instead. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --------- Co-authored-by: Carlos Villela <[email protected]> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
…NVIDIA#670) * feat(scripts): add SPDX --fix and exclude blueprint __init__.py files * chore: SPDX hook at priority 4 with --fix; lint-staged uses --fix * chore: add SPDX headers to shell scripts missing them * chore(pre-commit): run shellcheck with default rules Drop --severity=warning and --exclude=SC1091 so local hooks match strict shellcheck; script issues are fixed in-tree instead. * fix(scripts): declare bash for shellcheck in husky-env Add shellcheck shell=bash directive so SC2148 is satisfied without weakening global hook rules. * chore(scripts): normalize redirection in test-inference helpers Use >/path form so shellcheck does not flag spacing around redirects. * fix(e2e): satisfy shellcheck in onboard and full e2e tests Replace SC2015 if/else chains with explicit if/else, add source directives for dynamic sources, fix exit-status checks, and remove unused variables so strict shellcheck passes. * fix: preserve file permissions in SPDX fixer and harden e2e test scripts Address CodeRabbit review feedback on PR NVIDIA#670: - check-spdx-headers.sh: capture and restore original file mode when rewriting via mktemp+mv so executable bits are not lost - test-double-onboard.sh, test-full-e2e.sh: replace echo|grep -q pipes with here-strings to avoid SIGPIPE under pipefail; convert A&&B||C patterns to proper if/then/else (SC2015); check exit codes directly (SC2181); remove unused skip() function (SC2329) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: resolve shellcheck warnings in e2e-test.sh and backup-workspace.sh Convert A&&B||C patterns to proper if/then/else (SC2015) in e2e-test.sh, and replace ls with find in backup-workspace.sh (SC2012). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: guard find in do_restore against missing backup directory The unguarded find pipeline in do_restore() aborts under set -euo pipefail when BACKUP_BASE doesn't exist, before the descriptive error on the next line can run. Append || true so the [ -n "$ts" ] guard produces a clear "No backups found" message instead. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --------- Co-authored-by: Carlos Villela <[email protected]> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
) Apply now stops a Fabric agent's failed runtime before it starts another in the same sandbox, so an agent recovers on the next apply after provider errors instead of failing every apply until someone stops the runtime by hand or replaces the sandbox. ## Problem After provider errors, such as a model endpoint that answers 500, Fabric can mark a runtime failed while its adapter host and native processes keep running ([NVIDIA/NeMo-Fabric#670](NVIDIA/NeMo-Fabric#670)). Refresh then finds the runtime not running, and the plan gives `fabric_agent` an unknown `runtime_id`. Apply received no runtime ID, skipped `fabric-agent-ctl stop`, and started another runtime beside the failed one, which Fabric refused: - With `runtime.keep_state`, the failed runtime still held the agent's state lock: `start (state_in_use)` on every apply until someone ran `fabric-agent-ctl stop`. - Without kept state, OpenClaw's Gateway still held its ports: `start (start_failed)`, with unknown effects, after which Fabric refused every start until the sandbox was replaced. The comment in `configuration::ensure` said a stopped runtime is stopped in Fabric first, and the provider reference and usage guide said the same, but only the backend tests passed a runtime ID that a real plan never carries. ## Change - `fabric_agent`'s backend implements `update`: when the planned `runtime_id` is unknown, it takes the prior state's ID, so `ensure` stops that runtime before it starts another. Stopping a runtime Fabric no longer has already counts as stopped. If the stop fails, apply keeps the prior state, and the next apply stops the runtime again. - The `fabric` provider's backend passes `update` through to it; before, the trait's default dropped the prior state. - The fake gateway can mark a runtime failed (`fail_agent_runtime`) as Fabric at the pinned revision does: checks and invokes find it unavailable, a stop ends it, and until then a start in its sandbox fails with `state_in_use` when the agent keeps state, or `start_failed` with unknown effects otherwise. - Tests: the `failed_runtime` contract scenario applies through OpenTofu after the runtime fails without kept state, and a backend test covers kept state. The existing restart backend test now passes the row a real plan produces. Each new test failed before the fix. - Docs: the provider reference, the `state_in_use` troubleshooting row, and the release notes. Stopping the failed runtime is the caller's step under Fabric's current contract; #670 asks whether Fabric should stop the host itself. This change stays correct either way, since a stop of a runtime that's already gone succeeds. ## Beyond CI The provider-500 case isn't verified live with this change. #670 records the failure live, with kept state on the pending Fabric pin bump and without kept state at Fabric `135147a0`. A rerun on this branch, with OpenClaw at `135147a0` and no kept state, didn't reach it: six invocations against a model stub that answered 500 or hung each returned a failed result, and Fabric kept the runtime active, so apply had nothing to recover. Signed-off-by: Carlos Villela <[email protected]>
Summary
Adds --fix option to scripts/check-spdx-headers.sh (with exclusions for init.py), run the corresponding hook at higher priority with the new option, and align to lint-staged in package.json.
Fill missing SPDX headers on shell scripts, align shellcheck with default pre-commit rules (no relaxed args), and updates husky-env.sh, test-inference*.sh, and e2e scripts so strict shellcheck passes.
Changes
Type of Change
Testing
make checkpasses.npm testpasses.make docsbuilds without warnings. (for doc-only changes)Checklist
General
Code Changes
make formatapplied (TypeScript and Python).Doc Changes
update-docsagent skill to draft changes while complying with the style guide. For example, prompt your agent with "/update-docscatch up the docs for the new changes I made in this PR."Summary by CodeRabbit
Chores
Bug Fixes
Tests