Repository navigation
test(vitest): restore the fast source boundary - #6696
Conversation
Signed-off-by: Carlos Villela <[email protected]>
|
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 (5)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThe changes add transitive compiled-import boundary analysis, source-based Oclif metadata discovery, CLI contract coverage, controlled sandbox test loading, and dependency injection for the OpenShell gateway authentication E2E scenario. ChangesTest boundary and CLI metadata changes
Estimated code review effort: 4 (Complex) | ~60 minutes Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant FastTests
participant BoundaryAnalyzer
participant ModuleResolver
participant ReachableSource
FastTests->>BoundaryAnalyzer: scan fast-project entry files
BoundaryAnalyzer->>ModuleResolver: resolve recorded module references
ModuleResolver->>ReachableSource: load reachable repository modules
ReachableSource->>BoundaryAnalyzer: report compiled-load violations
BoundaryAnalyzer->>FastTests: return shortest violation chains
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe overall coverage remains at 96%, unchanged from the TypeScript / code-coverage/cliThe overall coverage in the Show a code coverage summary of the most impacted files.
Updated |
E2E Advisor RecommendationRequired E2E: None Dispatch hint: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
PR Review Advisor — No blocking findingsMerge posture: No blocking advisor findings This is an automated review. Required findings need action before merge. Warnings and optional suggestions do not require a response or follow-up. A human maintainer makes the final merge decision. |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/lib/actions/sandbox/doctor-flow.test.ts (1)
4-4: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winScope the filesystem mock to the CLI-build path.
mockReturnValueOnce(true)affects whicheverexistsSynccall happens first. Another filesystem check can consume it, causing this harness to depend on internal check ordering or the realdist/directory. Matchdist/nemoclaw.jsexplicitly and delegate all other paths to the original function.As per path instructions, tests should provide behavioral confidence rather than rely on broad mocks that bypass the behavior under test.
Also applies to: 184-185
🤖 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/doctor-flow.test.ts` at line 4, Update the filesystem mock in the test setup around the imported fs module and its existsSync configuration to return true only for the exact dist/nemoclaw.js path, while delegating all other paths to the original existsSync implementation. Remove the order-dependent mockReturnValueOnce behavior so unrelated filesystem checks and the real dist directory do not affect the test.Source: Path instructions
🤖 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 `@scripts/checks/no-test-dist-imports.ts`:
- Around line 57-60: Update isFastProjectTestPath to derive fast-project roots
and matching patterns from the canonical Vitest project configuration rather
than hardcoding src, nemoclaw/src, and test/e2e/support. Reuse the configuration
or generated project listing used by test:fast, while preserving the existing
.claude exclusion and test-file matching behavior.
- Around line 316-321: Update scan so embedded-template processing disables only
module-reference expansion, not module-load violation recording via
addModuleLoad. Preserve moduleLoadViolations for transitive checking when
recordModuleGraph is disabled, including violations found in imported helpers.
Add focused regression coverage for a fast test importing a helper with a
String.raw embedded dist require, along with the required false-positive case.
In `@test/package-contract/cli/oclif-pattern-discovery.test.ts`:
- Around line 82-87: Update the usage validation in the publicCommands contract
test to accept either a non-empty string or a non-empty array, while still
reporting missing usage for empty strings, empty arrays, and other invalid
values. Keep the existing summary and description checks unchanged.
---
Nitpick comments:
In `@src/lib/actions/sandbox/doctor-flow.test.ts`:
- Line 4: Update the filesystem mock in the test setup around the imported fs
module and its existsSync configuration to return true only for the exact
dist/nemoclaw.js path, while delegating all other paths to the original
existsSync implementation. Remove the order-dependent mockReturnValueOnce
behavior so unrelated filesystem checks and the real dist directory do not
affect the test.
🪄 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: d2e0d659-95e2-4517-9455-c0a15c3321ba
📒 Files selected for processing (12)
scripts/checks/no-test-dist-imports.tssrc/lib/actions/completion.test.tssrc/lib/actions/sandbox/doctor-flow.test.tssrc/lib/cli/oclif-command-metadata.test.tssrc/lib/cli/oclif-metadata.test.tssrc/lib/cli/oclif-metadata.tstest/e2e/live/openshell-gateway-auth-source-contract-helpers.tstest/e2e/live/openshell-gateway-auth-source-contract.test.tstest/package-contract/cli/completion.test.tstest/package-contract/cli/oclif-metadata.test.tstest/package-contract/cli/oclif-pattern-discovery.test.tstest/test-boundary-guards.test.ts
💤 Files with no reviewable changes (2)
- src/lib/cli/oclif-command-metadata.test.ts
- src/lib/actions/completion.test.ts
| export function isFastProjectTestPath(relativePath: string): boolean { | ||
| const normalized = relativePath.replaceAll("\\", "/"); | ||
| if (normalized.startsWith("src/") && normalized.split("/").includes(".claude")) return false; | ||
| return /^(?:src|nemoclaw\/src|test\/e2e\/support)\/.+\.test\.ts$/.test(normalized); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Derive fast-project roots from the canonical Vitest configuration.
The regex and three traversal roots independently duplicate the test:fast project inventory. A future Vitest-glob change can silently leave tests outside this guard, while the self-referential unit test still passes. Share the canonical project definitions or consume a generated project listing instead.
As per path instructions, derive inventories and limits from a canonical source where possible; duplicated lists can silently drift.
Also applies to: 865-871
🤖 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 `@scripts/checks/no-test-dist-imports.ts` around lines 57 - 60, Update
isFastProjectTestPath to derive fast-project roots and matching patterns from
the canonical Vitest project configuration rather than hardcoding src,
nemoclaw/src, and test/e2e/support. Reuse the configuration or generated project
listing used by test:fast, while preserving the existing .claude exclusion and
test-file matching behavior.
Source: Path instructions
There was a problem hiding this comment.
Keeping canonical root derivation out of PR2 intentionally. Issue #6692 assigns canonical project-membership and zero-membership enforcement to PR9, while PR3 canonicalizes the plugin project configuration. PR2 protects the exact current fast-root set with contract coverage plus test:projects:check; executing Vitest configuration from this import checker would conflate those ordered stack entries.
There was a problem hiding this comment.
@cv, that sequencing makes sense — thanks for the context on the stack ordering. Deferring canonical root derivation to PR9 (per issue #6692) and plugin config canonicalization to PR3, while PR2 locks down the current fast-root set with contract coverage and test:projects:check, is a reasonable way to avoid conflating those concerns. Withdrawing this suggestion.
Signed-off-by: Carlos Villela <[email protected]>
|
The d3f06bb follow-up also replaces the order-dependent one-shot existsSync mock with an exact CLI-build-path predicate that delegates every other filesystem query to the real implementation. The focused doctor flow passes 10/10, and the full import-boundary check remains green. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/package-contract/cli/oclif-pattern-discovery-helpers.ts`:
- Around line 20-26: Update commandOwnsHelpFlag to inspect the effective static
flags value on commandClass, including inherited flags, instead of requiring
flags to be an own property. Continue checking whether the resolved flags object
defines its own help entry, while preserving the existing function-type guard.
- Around line 10-18: Update extendsNemoClawCommand to compare each prototype in
the inheritance chain by constructor identity against the actual shared
NemoClawCommand constructor, rather than matching current.name. Reuse the loaded
base constructor or inject it into the helper, while preserving the existing
false result for non-functions and unrelated classes.
🪄 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: 805e3b80-602d-401a-9e01-e589d8757d9c
📒 Files selected for processing (6)
scripts/checks/no-test-dist-imports.tssrc/lib/actions/sandbox/doctor-flow.test.tstest/e2e/mock-parity.jsontest/package-contract/cli/oclif-pattern-discovery-helpers.tstest/package-contract/cli/oclif-pattern-discovery.test.tstest/test-boundary-guards.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/lib/actions/sandbox/doctor-flow.test.ts
- scripts/checks/no-test-dist-imports.ts
Signed-off-by: Carlos Villela <[email protected]>
|
Addressed the incremental PR Review Advisor warning in b20a01a. Source metadata now recognizes only the established |
## Summary Add per-test ownership for temporary HOME/bin directories, loopback servers, and child processes so cleanup is awaited even when setup or assertions fail. Migrate the current high-use CLI helpers and high-risk Hermes broker and Ollama proxy consumers, including cleanup of each implicit CLI HOME. This is PR4 in the #6692 stack; PRs #6696 and #6697 are already merged. ## Related Issue Related to #6692 ## Changes - Add `OwnedTestResources` and focused `test.extend` fixtures for LIFO cleanup of temporary directories, HOME/bin environments, servers, and child processes. - Add a shared child-process owner that waits for `close`, attempts graceful termination, escalates to `SIGKILL` when required, and confirms piped stdio is closed. The owned-resource fixture and Ollama proxy harness share this lifecycle because suite teardown did not consistently cover setup failures or await process closure. - Track server lifetime from ownership registration so fixture cleanup waits for both fixture-initiated shutdown and shutdown already started by code under test. - Remove the unowned per-invocation CLI HOME by deleting it when `runWithEnvInternal` completes, while preserving explicit caller-owned HOME directories. - Migrate the current repeated CLI HOME/bin setup helpers and the high-risk logs, doctor, Hermes broker, and Ollama proxy process/server consumers. - Add focused regressions for idempotent cleanup, server shutdown already in progress, graceful and forced child termination, proxy readiness failure cleanup, and CLI HOME cleanup after success, failure, and timeout. ## 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) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: This changes test-only resource ownership and cleanup. The required documentation-writer review confirmed there is no user-facing behavior, test command, lane, or contributor contract to document. - [ ] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [ ] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Verification - [x] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or `npm run check:diff` passed when hooks were skipped or unavailable - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: - `npx vitest run --project integration test/owned-test-resources.test.ts test/cli/helpers.test.ts test/cli/logs.test.ts test/cli/debug-command.test.ts test/cli/doctor-gateway-token.test.ts test/cli/sandbox-mutations.test.ts test/cli/snapshot-shields.test.ts test/hermes-tool-gateway-broker.test.ts test/ollama-auth-proxy-handler.test.ts` — 9 files, 71/71 tests passed on the rebased branch. - `NEMOCLAW_TEST_TIMEOUT=60000 npx vitest run --project integration test/cli/helpers.test.ts` — 12/12 tests passed; the synchronous timeout regression remained fixed at 2 seconds. - `npx vitest run --project integration test/cli/logs.test.ts --detectAsyncLeaks` — 10/10 tests passed with no async leaks. - `npm run typecheck:cli`, Biome on all changed files, `npm run source-shape:check`, `npm run test-size:check`, `npm run test:projects:check`, `npm run test:imports:check`, and `npm run test:titles:check` passed. - [x] Applicable broad gate passed — `npm test` for broad runtime/test-harness changes; `npm run check` for repo-wide validation/coverage changes — command/result: `npm test` passed on the rebased branch (1,438 files and 16,457 tests passed; 3 files and 40 opt-in platform tests skipped). - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `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 <[email protected]> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Improved CLI test hermeticity by standardizing on `owned-test-resources` with resource-scoped setup/teardown across logs, doctor, debug, sandbox mutations, snapshot shields, and sandbox/server-related suites. * Expanded HOME-related coverage, verifying no implicit HOME is left behind for successful, failed, and timed-out runs (while honoring explicit HOME). * Added dedicated child-process lifecycle ownership utilities and new verification tests for graceful shutdown, SIGTERM→SIGKILL escalation, and reliable stream closure/cleanup. * Strengthened ollama auth proxy startup/cleanup tests, including readiness timeout failures, listener removal, and retryable cleanup behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <[email protected]>
## Summary Vitest project validation now compares every filesystem test candidate with Vitest's complete eight-project roster, rejecting omissions, overlaps, wrong routing, unexpected files, and unexpected project names. The shared credential-free E2E workflow now applies Vitest's native e2e/credential-free tag filter in addition to the existing safe matrix scanner. The dashboard-port regression fixture also uses a coherent fake OpenShell 0.0.72 component set and an OS-assigned gateway port so the repo-wide gate stays hermetic. This is the final entry in the ordered #6692 stack after #6693, #6696, #6697, #6699, #6700, #6701, #6702, and #6705 landed. ## Related Issue Closes #6692 ## Changes - Discover broad test/spec JavaScript and TypeScript candidates under src, test, and nemoclaw/src, including nested dist, coverage, and .venv paths that Vitest would see. - Compare candidate routing with Vitest file listings and the complete roster from list-tags JSON, including empty and opt-in projects. - Produce sorted diagnostics for zero membership, overlap, wrong project, unsupported candidates, unexpected listed files, and missing or extra projects. - Invoke Vitest portably through process.execPath and node_modules/vitest/vitest.mjs. - Require the exact native credential-free tag filter in the shared E2E workflow contract while retaining the TypeScript scanner's path, project, ID, and declaration checks. - Keep the dashboard-port exhaustion regression independent of port 8080, developer OpenShell overrides, channel selection, and network installation. ## 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) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: these are contributor/test-harness safeguards; AGENTS.md now states the exhaustive project-membership contract, the E2E README already documents the native module tag, and the required documentation-writer review found no user-facing change. - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: independent review covered the shared credential-free workflow and onboarding regression fixture; it confirmed the filter preserves the existing scanner and the fixture's child-only environment cannot reach a real OpenShell install. - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Verification - [x] PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub - [x] Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — 46 integration tests passed across the boundary and dashboard-port files; 4 E2E-support workflow tests passed; project membership is exact for 1,537 candidates across 8 projects; CLI type-check, title style, Biome, and diff checks passed. The fixture also passed with hostile inherited OpenShell paths and dev-channel selection. - [x] Applicable broad gate passed — npm test passed 1,456 files / 16,515 tests before the final focused hardening; npm run check passed the repo-wide structural, CLI coverage, and plugin coverage gates, followed by focused reruns and normal hooks after the final child-environment pin. - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] npm run docs builds 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 <[email protected]> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Credential-free end-to-end test runs now execute only tests matching the credential-free tag. - Vitest project validation now checks for missing, overlapping, unsupported, wrong, zero-membership, and unexpected test-to-project assignments, plus roster mismatches. - Expanded boundary tests cover test candidate discovery, expected project mapping, Vitest invocation resolution, and listing/roster parsing. - Improved onboarding “dashboard port exhaustion” assertions for more hermetic, reliable verification. - **Documentation** - Updated testing guidance to require Vitest project globs be disjoint and exhaustive, enforced by the projects check. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <[email protected]>
<!-- markdownlint-disable MD041 --> ## Summary Restores `npm run test:fast` as a clean source-backed lane that succeeds after `dist/` is removed. Compiled CLI contracts now stay in `package-contract`, and the import guard follows transitive module edges so compiled artifacts cannot re-enter a fast project through a helper or alias. ## Related Issue Part of NVIDIA#6692. Follows NVIDIA#6693, which has merged. ## Changes - Keep the live gateway-auth scenario's compiled launch and TLS dependencies at the live test entry while its reusable helper imports source. - Discover the command IDs and literal routing metadata needed by source tests without loading command modules; compiled consumers remain generated-manifest-only and fail closed when the manifest is absent. This source-only path is required because command-registry consumers initialize before command modules can be loaded safely, and `src/lib/cli/oclif-metadata.test.ts` protects that contract. - Move Oclif discovery and completion assertions that require built artifacts into `test/package-contract/`. - Traverse the exact fast-project roots through static imports, exports, dynamic imports, `require`, and `createRequire`; report deterministic shortest chains and reject aliases that resolve into root CLI build output while ignoring external package layouts. - Make the doctor flow fixture own its CLI-build prerequisite without depending on an existing `dist/` tree. - Keep compiled Oclif inspection branches in a named package-contract helper and record the live gateway-auth scenario's existing fast parity owner. ## 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) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: this enforces the existing contributor contract documented in `CONTRIBUTING.md` and `AGENTS.md`; the required documentation-writer review found no user-facing change. - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: the live auth scenario still receives compiled launch/TLS functions only from its live entry, and compiled CLI metadata remains generated-manifest-only with a fail-closed regression test. - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Verification - [x] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or `npm run check:diff` passed when hooks were skipped or unavailable - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — `npm run test:fast -- --reporter=dot` (912 files, 9,759 passed, 1 skipped); `npm run test:package -- --reporter=dot` (19 files, 297 passed); boundary guard (34 passed); doctor flow (10 passed); mock-parity unit (6 passed); live-auth support (17 passed); import/project checks and CLI typecheck passed; the live auth test collected from rebuilt artifacts. - [x] Applicable broad gate passed — `npm test` for broad runtime/test-harness changes; `npm run check` for repo-wide validation/coverage changes — the complete non-live project set passed in boundary-preserving lanes: `test:fast`, `test:integration` (488 files, 6,206 passed, 38 skipped), and `test:package`. - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `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 <[email protected]> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Improvements** - Command routing and completion metadata can be discovered from source without executing command code, with a unified loader and safer handling when the generated manifest is missing. - Expanded import-boundary violation reporting with transitive reachability analysis and an optional violation chain. - **Bug Fixes** - Strengthened detection of disallowed module-loading forms and improved safeguards to avoid unintentionally loading compiled internals. - Updated sandbox doctor flow mocking to align with runtime path resolution. - **Tests** - Added/updated contract and e2e suites, including a gateway scenario using injected TLS/launch helpers, new compiled-completion metadata coverage, and a fail-closed manifest check. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <[email protected]>
## Summary Add per-test ownership for temporary HOME/bin directories, loopback servers, and child processes so cleanup is awaited even when setup or assertions fail. Migrate the current high-use CLI helpers and high-risk Hermes broker and Ollama proxy consumers, including cleanup of each implicit CLI HOME. This is PR4 in the NVIDIA#6692 stack; PRs NVIDIA#6696 and NVIDIA#6697 are already merged. ## Related Issue Related to NVIDIA#6692 ## Changes - Add `OwnedTestResources` and focused `test.extend` fixtures for LIFO cleanup of temporary directories, HOME/bin environments, servers, and child processes. - Add a shared child-process owner that waits for `close`, attempts graceful termination, escalates to `SIGKILL` when required, and confirms piped stdio is closed. The owned-resource fixture and Ollama proxy harness share this lifecycle because suite teardown did not consistently cover setup failures or await process closure. - Track server lifetime from ownership registration so fixture cleanup waits for both fixture-initiated shutdown and shutdown already started by code under test. - Remove the unowned per-invocation CLI HOME by deleting it when `runWithEnvInternal` completes, while preserving explicit caller-owned HOME directories. - Migrate the current repeated CLI HOME/bin setup helpers and the high-risk logs, doctor, Hermes broker, and Ollama proxy process/server consumers. - Add focused regressions for idempotent cleanup, server shutdown already in progress, graceful and forced child termination, proxy readiness failure cleanup, and CLI HOME cleanup after success, failure, and timeout. ## 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) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: This changes test-only resource ownership and cleanup. The required documentation-writer review confirmed there is no user-facing behavior, test command, lane, or contributor contract to document. - [ ] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [ ] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Verification - [x] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or `npm run check:diff` passed when hooks were skipped or unavailable - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: - `npx vitest run --project integration test/owned-test-resources.test.ts test/cli/helpers.test.ts test/cli/logs.test.ts test/cli/debug-command.test.ts test/cli/doctor-gateway-token.test.ts test/cli/sandbox-mutations.test.ts test/cli/snapshot-shields.test.ts test/hermes-tool-gateway-broker.test.ts test/ollama-auth-proxy-handler.test.ts` — 9 files, 71/71 tests passed on the rebased branch. - `NEMOCLAW_TEST_TIMEOUT=60000 npx vitest run --project integration test/cli/helpers.test.ts` — 12/12 tests passed; the synchronous timeout regression remained fixed at 2 seconds. - `npx vitest run --project integration test/cli/logs.test.ts --detectAsyncLeaks` — 10/10 tests passed with no async leaks. - `npm run typecheck:cli`, Biome on all changed files, `npm run source-shape:check`, `npm run test-size:check`, `npm run test:projects:check`, `npm run test:imports:check`, and `npm run test:titles:check` passed. - [x] Applicable broad gate passed — `npm test` for broad runtime/test-harness changes; `npm run check` for repo-wide validation/coverage changes — command/result: `npm test` passed on the rebased branch (1,438 files and 16,457 tests passed; 3 files and 40 opt-in platform tests skipped). - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `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 <[email protected]> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Improved CLI test hermeticity by standardizing on `owned-test-resources` with resource-scoped setup/teardown across logs, doctor, debug, sandbox mutations, snapshot shields, and sandbox/server-related suites. * Expanded HOME-related coverage, verifying no implicit HOME is left behind for successful, failed, and timed-out runs (while honoring explicit HOME). * Added dedicated child-process lifecycle ownership utilities and new verification tests for graceful shutdown, SIGTERM→SIGKILL escalation, and reliable stream closure/cleanup. * Strengthened ollama auth proxy startup/cleanup tests, including readiness timeout failures, listener removal, and retryable cleanup behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <[email protected]>
…A#6707) ## Summary Vitest project validation now compares every filesystem test candidate with Vitest's complete eight-project roster, rejecting omissions, overlaps, wrong routing, unexpected files, and unexpected project names. The shared credential-free E2E workflow now applies Vitest's native e2e/credential-free tag filter in addition to the existing safe matrix scanner. The dashboard-port regression fixture also uses a coherent fake OpenShell 0.0.72 component set and an OS-assigned gateway port so the repo-wide gate stays hermetic. This is the final entry in the ordered NVIDIA#6692 stack after NVIDIA#6693, NVIDIA#6696, NVIDIA#6697, NVIDIA#6699, NVIDIA#6700, NVIDIA#6701, NVIDIA#6702, and NVIDIA#6705 landed. ## Related Issue Closes NVIDIA#6692 ## Changes - Discover broad test/spec JavaScript and TypeScript candidates under src, test, and nemoclaw/src, including nested dist, coverage, and .venv paths that Vitest would see. - Compare candidate routing with Vitest file listings and the complete roster from list-tags JSON, including empty and opt-in projects. - Produce sorted diagnostics for zero membership, overlap, wrong project, unsupported candidates, unexpected listed files, and missing or extra projects. - Invoke Vitest portably through process.execPath and node_modules/vitest/vitest.mjs. - Require the exact native credential-free tag filter in the shared E2E workflow contract while retaining the TypeScript scanner's path, project, ID, and declaration checks. - Keep the dashboard-port exhaustion regression independent of port 8080, developer OpenShell overrides, channel selection, and network installation. ## 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) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: these are contributor/test-harness safeguards; AGENTS.md now states the exhaustive project-membership contract, the E2E README already documents the native module tag, and the required documentation-writer review found no user-facing change. - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [x] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: independent review covered the shared credential-free workflow and onboarding regression fixture; it confirmed the filter preserves the existing scanner and the fixture's child-only environment cannot reach a real OpenShell install. - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Verification - [x] PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub - [x] Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — 46 integration tests passed across the boundary and dashboard-port files; 4 E2E-support workflow tests passed; project membership is exact for 1,537 candidates across 8 projects; CLI type-check, title style, Biome, and diff checks passed. The fixture also passed with hostile inherited OpenShell paths and dev-channel selection. - [x] Applicable broad gate passed — npm test passed 1,456 files / 16,515 tests before the final focused hardening; npm run check passed the repo-wide structural, CLI coverage, and plugin coverage gates, followed by focused reruns and normal hooks after the final child-environment pin. - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] npm run docs builds 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 <[email protected]> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Credential-free end-to-end test runs now execute only tests matching the credential-free tag. - Vitest project validation now checks for missing, overlapping, unsupported, wrong, zero-membership, and unexpected test-to-project assignments, plus roster mismatches. - Expanded boundary tests cover test candidate discovery, expected project mapping, Vitest invocation resolution, and listing/roster parsing. - Improved onboarding “dashboard port exhaustion” assertions for more hermetic, reliable verification. - **Documentation** - Updated testing guidance to require Vitest project globs be disjoint and exhaustive, enforced by the projects check. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <[email protected]>
Summary
Restores
npm run test:fastas a clean source-backed lane that succeeds afterdist/is removed. Compiled CLI contracts now stay inpackage-contract, and the import guard follows transitive module edges so compiled artifacts cannot re-enter a fast project through a helper or alias.Related Issue
Part of #6692. Follows #6693, which has merged.
Changes
src/lib/cli/oclif-metadata.test.tsprotects that contract.test/package-contract/.require, andcreateRequire; report deterministic shortest chains and reject aliases that resolve into root CLI build output while ignoring external package layouts.dist/tree.Type of Change
Quality Gates
CONTRIBUTING.mdandAGENTS.md; the required documentation-writer review found no user-facing change.Verification
Verifiedin GitHubpre-commit,commit-msg, andpre-pushhooks passed, ornpm run check:diffpassed when hooks were skipped or unavailablenpm run test:fast -- --reporter=dot(912 files, 9,759 passed, 1 skipped);npm run test:package -- --reporter=dot(19 files, 297 passed); boundary guard (34 passed); doctor flow (10 passed); mock-parity unit (6 passed); live-auth support (17 passed); import/project checks and CLI typecheck passed; the live auth test collected from rebuilt artifacts.npm testfor broad runtime/test-harness changes;npm run checkfor repo-wide validation/coverage changes — the complete non-live project set passed in boundary-preserving lanes:test:fast,test:integration(488 files, 6,206 passed, 38 skipped), andtest:package.npm run docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela [email protected]
Summary by CodeRabbit