refactor(cli): lower cognitive complexity ratchet below 150 - #5432
Conversation
Signed-off-by: Carlos Villela <cvillela@nvidia.com> (cherry picked from commit 41fcd6a)
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
…t/244-rebuild-cognitive-complexity
…243-rebuild-confirm-cognitive-complexity
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
## Summary Continue the stacked cognitive-complexity ratchet by lowering the threshold from 185 to 184. The previous stack step brought all remaining offenders to 184 or below, so this PR only tightens the Biome configuration. ## Changes - Lowered `complexity/noExcessiveCognitiveComplexity` from `185` to `184` in `biome.json`. ## 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 - `npx @biomejs/biome lint --only=complexity/noExcessiveCognitiveComplexity --max-diagnostics=none .` - [x] Git hooks passed during commit and push, or `npx prek run --from-ref main --to-ref HEAD` passes - [x] Targeted tests pass for changed behavior - [ ] Tests added or updated for new or changed behavior - [ ] Full `npm test` passes (broad runtime changes only) - [x] 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](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- <!-- DCO sign-off required by CI. Run: git config user.name && git config user.email --> Signed-off-by: Carlos Villela <cvillela@nvidia.com> Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com> (cherry picked from commit 167e6e3)
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
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:
📝 WalkthroughWalkthroughThree parallel refactors extract rebuild preflight logic, snapshot post-restore handling, and Ollama onboarding selection into dedicated helpers and factories. New ChangesRebuild flow helper extraction
Snapshot post-restore helper extraction and policy reconciliation
Setup NIM Ollama handler extraction and state
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Poem
🚥 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 unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage in the Show a code coverage summary of the most covered files.
TypeScript / code-coverage/cliThe overall coverage in the Show a code coverage summary of the most covered files.
Updated |
E2E Advisor RecommendationRequired E2E: Dispatch hint: Auto-dispatched E2E: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
Vitest E2E Scenario RecommendationRequired Vitest E2E scenarios: Dispatch required Vitest E2E scenarios:
Full Vitest E2E advisor summaryVitest E2E Scenario AdvisorBase: Required Vitest E2E scenarios
Optional Vitest E2E scenarios
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. |
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
…ild-snapshot-onboard-stack
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
…ort, function or class' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/lib/actions/sandbox/rebuild.ts (1)
639-673: Run the rebuild channel lifecycle E2E before merge.Given this file controls rebuild flow behavior, please run
channels-stop-start-e2eto validate channel disable/enable persistence across rebuild with cached credentials.As per coding guidelines:
src/lib/actions/sandbox/rebuild.tschanges should be validated withchannels-stop-start-e2e.🤖 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 `@src/lib/actions/sandbox/rebuild.ts` around lines 639 - 673, The changes to the rebuild flow in the openRebuildShieldsWindowForState, relockRebuildShieldsWindow, and backupSandboxStateForRebuild code paths need validation through end-to-end testing. Run the channels-stop-start-e2e E2E test to confirm that channel disable/enable persistence is properly maintained across rebuild operations with cached credentials before merging this change.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 `@src/lib/actions/sandbox/snapshot.ts`:
- Around line 600-635: The preflight validation of fromImage at lines 601-608 is
decoupled from the actual recreate operation at line 634. The validated
fromImage value is not passed to autoCreateSandboxFromSource, causing it to
re-probe the image internally — if this re-probe fails after the destination has
been deleted, the operation aborts in a destructive state. Modify the call to
autoCreateSandboxFromSource to accept and use the pre-validated fromImage value
instead of re-probing, ensuring the preflight validation is directly bound to
the actual recreate step and no transient failures can occur after destination
deletion.
---
Nitpick comments:
In `@src/lib/actions/sandbox/rebuild.ts`:
- Around line 639-673: The changes to the rebuild flow in the
openRebuildShieldsWindowForState, relockRebuildShieldsWindow, and
backupSandboxStateForRebuild code paths need validation through end-to-end
testing. Run the channels-stop-start-e2e E2E test to confirm that channel
disable/enable persistence is properly maintained across rebuild operations with
cached credentials before merging this change.
🪄 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: 461ff0b2-585b-4444-b12f-2c3030379d6d
📒 Files selected for processing (11)
biome.jsonsrc/lib/actions/sandbox/rebuild-flow-helpers.tssrc/lib/actions/sandbox/rebuild.tssrc/lib/actions/sandbox/snapshot.test.tssrc/lib/actions/sandbox/snapshot.tssrc/lib/onboard.tssrc/lib/onboard/setup-nim-ollama.test.tssrc/lib/onboard/setup-nim-ollama.tssrc/lib/onboard/setup-nim-selection.test.tssrc/lib/onboard/setup-nim-selection.tstest/rebuild-credential-preflight.test.ts
Selective E2E Results — ✅ All requested jobs passedRun: 27587386845
|
Selective E2E Results —
|
| Job | Result |
|---|---|
| double-onboard-e2e | |
| gpu-e2e | ⏭️ skipped |
Selective E2E Results —
|
| Job | Result |
|---|---|
| gpu-e2e | ⏭️ skipped |
Selective E2E Results —
|
| Job | Result |
|---|---|
| gpu-e2e | ⏭️ skipped |
Summary
Lower the cognitive-complexity ratchet from 184 to 149 by extracting the remaining high-complexity rebuild, snapshot, and setupNim paths. This brings the configured limit below 150 without adding suppressions or per-file exceptions.
Changes
complexity/noExcessiveCognitiveComplexityfrom184to149inbiome.json.rebuild.tshotspot intosrc/lib/actions/sandbox/rebuild-flow-helpers.ts.src/lib/onboard/setup-nim-ollama.ts, keepingsrc/lib/onboard.tsnet smaller.allowToolsIncompatiblethrough running, Windows-host, and installed Ollama selection paths.Type of Change
Verification
npx @biomejs/biome lint src/lib/onboard/setup-nim-ollama.test.ts src/lib/onboard/setup-nim-ollama.ts src/lib/onboard.ts src/lib/onboard/setup-nim-selection.tsnpx @biomejs/biome lint test/rebuild-credential-preflight.test.ts src/lib/onboard/setup-nim-ollama.test.tsnpx @biomejs/biome lint src/lib/actions/sandbox/rebuild.ts src/lib/actions/sandbox/rebuild-flow-helpers.ts test/rebuild-credential-preflight.test.tsnpx @biomejs/biome lint --only=complexity/noExcessiveCognitiveComplexity --max-diagnostics=none .npm run typecheck:clinpx vitest run --project cli test/rebuild-credential-preflight.test.ts test/rebuild-stale-recovery.test.ts src/lib/actions/sandbox/rebuild-gateway-drift.test.ts test/snapshot.test.ts test/openclaw-config-snapshot.test.ts test/security-sandbox-tar-traversal.test.ts src/lib/onboard/providers.test.ts src/lib/onboard/vllm-menu.test.ts src/lib/onboard/windows-host-ollama.test.ts src/lib/onboard/install-ollama-linux-upgrade.test.tsnpx vitest run --project cli src/lib/onboard/setup-nim-ollama.test.ts src/lib/onboard/windows-host-ollama.test.ts src/lib/onboard/install-ollama-linux-upgrade.test.ts src/lib/onboard/vllm-menu.test.tsnpx vitest run --project cli src/lib/onboard/setup-nim-ollama.test.ts src/lib/onboard/windows-host-ollama.test.ts src/lib/onboard/install-ollama-linux-upgrade.test.ts src/lib/onboard/vllm-menu.test.ts test/rebuild-credential-preflight.test.tsnpx vitest run --project cli test/rebuild-credential-preflight.test.ts test/rebuild-stale-recovery.test.ts src/lib/actions/sandbox/rebuild-gateway-drift.test.tsGit hooks passed during commit and push, or
npx prek run --from-ref main --to-ref HEADpassesTargeted tests pass for changed behavior
Tests added or updated for new or changed behavior
Full
npm testpasses (broad runtime changes only)No secrets, API keys, or credentials committed
Docs updated for user-facing behavior changes
npm run docsbuilds 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)
Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
Release Notes