perf(test): reduce messaging and gateway setup overhead - #6282
Conversation
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
|
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 (1)
📝 WalkthroughWalkthroughThe sandbox gateway module updates import sources for known-hosts pruning and Docker driver recovery. Messaging build applier tests now read plans from env and call build/apply/render helpers directly, replacing many spawned-process assertions with direct thrown-error and return-value checks. ChangesGateway State Import Re-sourcing
Messaging Build Applier Direct Invocation Test Refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
E2E Target RecommendationRequired E2E targets: Dispatch required E2E targets:
Full E2E target advisor summaryE2E Target AdvisorBase: Required E2E targets
Optional E2E targets
Relevant changed files
|
PR Review Advisor (Nemotron Ultra) — Changes requestedMerge posture: Do not merge yet Action checklist
Findings index
Review findings by urgency: 0 required fixes, 6 items to resolve/justify, 4 in-scope improvements
|
PR Review Advisor — Changes requestedMerge posture: Do not merge yet Action checklist
Findings index
Review findings by urgency: 0 required fixes, 1 item to resolve/justify, 0 in-scope improvements
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
test/messaging-build-applier-integrity.test.ts (1)
56-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract
thrownMessageto the shared test helper module.This helper is duplicated verbatim in
test/messaging-build-applier.test.ts(lines 181-188) and is also referenced from a third call site there. Consider moving it intotest/messaging-plan-test-helper.tsalongsidewithLegacyMessagingPlanEnvDirectso all three messaging-applier test files import one implementation.♻️ Proposed consolidation
-function thrownMessage(run: () => void): string { - try { - run(); - } catch (error) { - return error instanceof Error ? error.message : String(error); - } - throw new Error("Expected operation to throw"); -} +import { thrownMessage } from "./messaging-plan-test-helper";🤖 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 `@test/messaging-build-applier-integrity.test.ts` around lines 56 - 63, The thrownMessage helper is duplicated across messaging-applier tests and should be centralized in the shared test helper module. Move thrownMessage into test/messaging-plan-test-helper.ts alongside withLegacyMessagingPlanEnvDirect, then update messaging-build-applier-integrity.test.ts and the existing call sites in messaging-build-applier.test.ts to import and use the shared implementation. Keep the behavior identical so all messaging-applier tests rely on one helper definition.src/lib/actions/sandbox/gateway-state.ts (1)
16-17: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a static import here instead of
require().src/lib/onboard/known-hosts.tsis a leaf module, so the deferred load is unnecessary; switching toimport { pruneKnownHostsEntries } from "../../onboard/known-hosts";keeps this file consistent with the rest of the imports and simplifies type-checking.🤖 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/gateway-state.ts` around lines 16 - 17, Replace the deferred require in gateway-state.ts with a static import for pruneKnownHostsEntries from the known-hosts module. Update the top-level import section to use import { pruneKnownHostsEntries } from "../../onboard/known-hosts"; and remove the inline type assertion, keeping the rest of the gateway-state logic unchanged.
🤖 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.
Nitpick comments:
In `@src/lib/actions/sandbox/gateway-state.ts`:
- Around line 16-17: Replace the deferred require in gateway-state.ts with a
static import for pruneKnownHostsEntries from the known-hosts module. Update the
top-level import section to use import { pruneKnownHostsEntries } from
"../../onboard/known-hosts"; and remove the inline type assertion, keeping the
rest of the gateway-state logic unchanged.
In `@test/messaging-build-applier-integrity.test.ts`:
- Around line 56-63: The thrownMessage helper is duplicated across
messaging-applier tests and should be centralized in the shared test helper
module. Move thrownMessage into test/messaging-plan-test-helper.ts alongside
withLegacyMessagingPlanEnvDirect, then update
messaging-build-applier-integrity.test.ts and the existing call sites in
messaging-build-applier.test.ts to import and use the shared implementation.
Keep the behavior identical so all messaging-applier tests rely on one helper
definition.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: dda3f324-c029-45e9-9dfd-471a2b0fb140
📒 Files selected for processing (4)
src/lib/actions/sandbox/gateway-state.tstest/messaging-build-applier-integrity.test.tstest/messaging-build-applier-render-safety.test.tstest/messaging-build-applier.test.ts
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
|
Final-head evidence for
Automated-review disposition:
Docs review found no user-facing change, so no docs update/build was needed. |
## Summary Removes repeated TypeScript process bootstrapping from the messaging build-applier tests while retaining representative executable and security boundaries. It also narrows `gateway-state`'s known-hosts dependency to the existing leaf module so shard 3 no longer collects the full onboarding graph for that helper. ## Related Issue Related to NVIDIA#6245. ## Changes - Build messaging plans in-process and exercise exported production phase/render seams directly where process behavior is not the contract. - Reduce the messaging-applier group from 57 top-level test-controlled subprocesses to 10: 21 legacy `npx tsx` builders are removed, while nine applier contracts and one generator contract remain. - Preserve real fake `npm`, `openclaw`, and `uv` command boundaries, including archive provenance/integrity, unsafe archive exit behavior, doctor rewrite/reapply, WeChat build-file routing, Hermes rendering, argv, env, and exit status. - Load `pruneKnownHostsEntries` from `onboard/known-hosts` instead of the 5,282-line onboarding barrel; the traced source graph falls from 495 modules to 138 modules (72.1% fewer). ## 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: internal dependency narrowing and test execution strategy only; no command, config, default, API, output, policy, or recovery behavior changes - [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 local review found no remaining actionable findings; archive integrity/provenance, unsafe-path failure, doctor reapply, and OpenClaw/Hermes process contracts remain real - [ ] 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 — fresh `npm run build:cli`, then 7 focused Vitest files: 67/67 passed in 3.93s wall - [ ] Applicable broad gate passed — `npm test` for broad runtime/test-harness changes; `npm run check` for repo-wide validation/coverage changes — command/result: not applicable to this focused four-file batch; final-head CI remains authoritative for full coverage - [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) ## Performance evidence - Messaging-applier merged-CI baseline: 19.163s across the four files; final local test execution: 1.60s. The environments differ, so final-head CI is the authoritative comparison. - Gateway-state traced source graph: 495 to 138 modules; simulated cold TypeScript transpilation: 1,330ms to 476ms. - This is another incremental NVIDIA#6245 batch, not a claim that the full suite has reached the 2–5 minute target. --- Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Refactored messaging build-applier suites to invoke messaging plan reading and build phases directly (instead of relying on process execution), improving validation of safety rules and failure behavior. * Strengthened integrity and “fails closed” checks by asserting specific thrown error messages and verifying expected trace/artifact outcomes. * **Chores** * Minor internal adjustments to sandbox connection and gateway-state wiring (no end-user behavior changes). <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Summary
Removes repeated TypeScript process bootstrapping from the messaging build-applier tests while retaining representative executable and security boundaries. It also narrows
gateway-state's known-hosts dependency to the existing leaf module so shard 3 no longer collects the full onboarding graph for that helper.Related Issue
Related to #6245.
Changes
npx tsxbuilders are removed, while nine applier contracts and one generator contract remain.npm,openclaw, anduvcommand boundaries, including archive provenance/integrity, unsafe archive exit behavior, doctor rewrite/reapply, WeChat build-file routing, Hermes rendering, argv, env, and exit status.pruneKnownHostsEntriesfromonboard/known-hostsinstead of the 5,282-line onboarding barrel; the traced source graph falls from 495 modules to 138 modules (72.1% fewer).Type of Change
Quality Gates
Verification
Verifiedin GitHubpre-commit,commit-msg, andpre-pushhooks passed, ornpm run check:diffpassed when hooks were skipped or unavailablenpm run build:cli, then 7 focused Vitest files: 67/67 passed in 3.93s wallnpm testfor broad runtime/test-harness changes;npm run checkfor repo-wide validation/coverage changes — command/result: not applicable to this focused four-file batch; final-head CI remains authoritative for full coveragenpm run docsbuilds without warnings (doc changes only)Performance evidence
Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit