Skip to content

perf(test): retire rebuild CommonJS loader seams - #6388

Merged
cv merged 7 commits into
mainfrom
codex/perf-retire-rebuild-create-require
Jul 7, 2026
Merged

perf(test): retire rebuild CommonJS loader seams#6388
cv merged 7 commits into
mainfrom
codex/perf-retire-rebuild-create-require

Conversation

@cv

@cv cv commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Reduce cold collection overhead in four rebuild-focused CLI test files by replacing CommonJS source-loader/cache-invalidation seams with native source imports and dependency-light production boundaries. This preserves the existing behavioral coverage while removing incidental loading of the full rebuild graph.

Related Issue

Refs #6245
Refs #6237

Changes

  • Extract messaging-plan staging and config-hash command construction into dependency-light leaf modules while preserving the public rebuild facade exports.
  • Defer loading sandbox/rebuild from upgrade-sandboxes until a sandbox actually needs rebuilding, with an explicit dependency seam for focused tests.
  • Convert four CLI suites from createRequire, cache deletion, and loader warmups to native imports and typed spies.
  • Tighten the exact-path createRequire ratchet from 32 to 28 CLI test files.
  • Preserve all 43 existing assertions in the optimized suites and the real Bash/filesystem, manifest planner, recovery, and gateway-classification contracts.
  • Add a compiled package-contract test for lazy rebuild loading and facade exports, and make config-hash refresh propagate sha256sum failures instead of masking them behind best-effort permission repair.

Matched CI evidence: the previous merged head reported 28.806s of aggregate collection time for these four files. Final-head #6388 CI reports 3.041s, a reduction of 25.765s (89.44%; 9.47× faster), while preserving the original assertions and adding the hash-failure regression. Aggregate collection work overlaps across Vitest shards, so this is not a claim of equivalent one-for-one shard-wall savings.

Type of Change

  • 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

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: internal module-boundary and test-loader refactor only; commands, flags, defaults, configuration, protocols, and user-visible behavior are unchanged.
  • 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: two independent source reviews found no blocking findings; focused rebuild, recovery, preflight, messaging, config-hash, and compiled package-contract coverage passed.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — 126/126 focused CLI tests passed across the optimized suites, upgrade preflight, and the broader rebuild flow; 2/2 compiled package-contract tests and the ratchet's 8/8 integration tests also passed.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — five-shard final-head CI / Pull Request and coverage merge passed; all 40 PR checks are green.
  • Quality Gates section completed with required justifications or waivers
  • 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)

Additional local verification:

  • npm run typecheck:cli
  • npm run build:cli
  • compiled package-contract coverage proves importing dist/lib/actions/upgrade-sandboxes.js does not eagerly load the rebuild module, forwards the lazy call exactly, and preserves both extracted rebuild facade exports
  • npx tsx scripts/checks/test-create-require-budget.ts (28 CLI files, 8 support files)
  • npm run test:projects:check
  • required live E2E passed: rebuild-openclaw, rebuild-hermes, sandbox-rebuild, upgrade-stale-sandbox, and channels-add-remove, and messaging-providers (OpenClaw passed on retry after an initial npm ECONNRESET during fixture setup)
  • git diff --check

Signed-off-by: Carlos Villela cvillela@nvidia.com

Summary by CodeRabbit

  • New Features

    • Added rebuild messaging “recreate contract” planning based on built-in channel manifests.
    • Introduced a safer sandbox config-hash refresh command with stricter pre-checks before updating the mutable OpenClaw config hash.
  • Bug Fixes

    • Improved restore/recovery and rebuild messaging preparation, including safer skip conditions when messaging support is unavailable.
    • Ensured config-hash refresh failures surface correctly, with stronger protections against symlinked/mismatched config inputs.
  • Tests

    • Updated and expanded package-contract and rebuild flow tests to validate loader laziness and expected rebuild entrypoints.

@cv cv self-assigned this Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR extracts sandbox helper logic into standalone modules, routes upgrade-sandboxes through an injectable dependency wrapper, updates related tests to static ES imports and new spies, adds a package-contract boundary test, and revises the createRequire budget allowlist.

Changes

Sandbox rebuild and upgrade module refactor

Layer / File(s) Summary
Extract config-hash command builder
src/lib/actions/sandbox/rebuild-config-hash-command.ts, src/lib/actions/sandbox/rebuild-config-hash.ts, src/lib/actions/sandbox/rebuild-config-hash.test.ts
New module builds the shell command to refresh .config-hash; original file re-exports it, and the test switches from createRequire to direct import and adds failure-path coverage.
Extract messaging manifest staging function
src/lib/actions/sandbox/rebuild-messaging-stage.ts, src/lib/actions/sandbox/rebuild-messaging-phase.ts, src/lib/actions/sandbox/rebuild-messaging-stage.test.ts
New stageMessagingManifestPlanForRebuild builds a messaging plan via MessagingWorkflowPlanner, is re-exported from the phase file, and the test moves to static imports/spies with added type assertions.
Introduce upgradeSandboxesDependencies wrapper
src/lib/actions/upgrade-sandboxes.ts, src/lib/actions/upgrade-sandboxes-preflight.test.ts, src/lib/actions/upgrade-sandboxes-recovery.test.ts
Adds an exported dependency object wrapping getGatewayPort and rebuildSandbox; upgradeSandboxes calls through it, and tests spy on it instead of mocking modules/CommonJS cache.
Refactor rebuild-flow-helpers tests to static imports
src/lib/actions/sandbox/rebuild-flow-helpers.test.ts
Replaces dynamic module reload helpers with static ES imports, updates fixture typings and mock resolved-value shapes.
Add rebuild loader boundary contract test
test/package-contract/rebuild-loader-boundary.test.ts
Adds a runtime contract test for lazy rebuild loading through upgrade and the public rebuild facade exports.
Update createRequire budget allowlist
scripts/checks/test-create-require-budget.ts
Swaps allowlisted test paths reflecting the converted/new test files.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#2897 — Also restructures the upgrade-sandboxes execution path and its orchestration boundaries.
  • NVIDIA/NemoClaw#3833 — Touches the same rebuild facade exports and loader-boundary contract tested here.

Suggested labels: refactor

Suggested reviewers: ericksoa, cjagwani

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing CommonJS loader seams from rebuild-focused tests.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/perf-retire-rebuild-create-require

Comment @coderabbitai help to get the list of available commands.

@github-code-quality

github-code-quality Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in the codex/perf-retire-re... branch is 96%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main codex/perf-retire-re... abce9b7 +/-
nemoclaw/src/se...cret-scanner.ts 100%
nemoclaw/src/commands/slash.ts 100%
nemoclaw/src/li...bprocess-env.ts 100%
nemoclaw/src/bl...eprint/state.ts 98%
nemoclaw/src/onboard/config.ts 98%
nemoclaw/src/bl...int/snapshot.ts 97%
nemoclaw/src/bl...print/runner.ts 95%
nemoclaw/src/co...ration-state.ts 94%
nemoclaw/src/bl...ate-networks.ts 94%
nemoclaw/src/index.ts 94%

TypeScript / code-coverage/cli

The overall coverage in the codex/perf-retire-re... branch is 75%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main codex/perf-retire-re... abce9b7 +/-
src/lib/shields...nsition-lock.ts 85%
src/lib/onboard/preflight.ts 83%
src/lib/actions...all/run-plan.ts 81%
src/lib/state/o...oard-session.ts 80%
src/lib/actions...licy-channel.ts 79%
src/lib/state/sandbox.ts 75%
src/lib/onboard...er-gpu-patch.ts 69%
src/lib/policy/index.ts 66%
src/lib/shields/index.ts 61%
src/lib/onboard.ts 28%

Updated July 07, 2026 10:18 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings

Merge posture: No blocking advisor findings
Primary next action: Add or justify PRA-T1 and any related test follow-ups.
Open items: 0 required · 0 warnings · 0 suggestions · 2 test follow-ups
Since last review: 0 prior items resolved · 0 still apply · 0 new items found

Action checklist

  • PRA-T1 Add or justify test follow-up: Runtime validation
  • PRA-T2 Add or justify test follow-up: Runtime validation
Test follow-ups to resolve or justify

If these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.

  • PRA-T1 Runtime validation — Verify `upgrade-sandboxes --check` reports stale or prepared-recovery candidates without invoking `upgradeSandboxesDependencies.loadRebuildModule` or loading `dist/lib/actions/sandbox/rebuild.js`.. The changed source files touch sandbox rebuild, messaging, post-restore config hashing, and upgrade recovery paths. The PR adds strong targeted unit/package-contract coverage, but these paths ultimately cross real sandbox/OpenShell runtime boundaries that benefit from behavior-specific runtime validation.
  • PRA-T2 Runtime validation — Verify a post-restore config-hash refresh where sandbox `sha256sum` exits nonzero logs a redacted warning and marks the mutable config hash refresh as unverified without continuing as a confirmed refresh.. The changed source files touch sandbox rebuild, messaging, post-restore config hashing, and upgrade recovery paths. The PR adds strong targeted unit/package-contract coverage, but these paths ultimately cross real sandbox/OpenShell runtime boundaries that benefit from behavior-specific runtime validation.

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor (Nemotron Ultra) — Changes requested

Merge posture: Do not merge yet
Primary next action: Fix PRA-1: Overlapping changes with PR #6211 on rebuild-flow-helpers.test.ts; then add or justify PRA-T1.
Open items: 1 required · 2 warnings · 2 suggestions · 6 test follow-ups
Since last review: 1 prior item resolved · 1 still applies · 3 new items found

Action checklist

  • PRA-1 Fix: Overlapping changes with PR fix(sandbox): allow rebuild --force to skip backup when container is unreachable #6211 on rebuild-flow-helpers.test.ts in src/lib/actions/sandbox/rebuild-flow-helpers.test.ts:1
  • PRA-2 Resolve or justify: Missing direct unit tests for config hash command edge cases (exit codes 10, 12, 13) in src/lib/actions/sandbox/rebuild-config-hash-command.ts:1
  • PRA-3 Resolve or justify: Missing integration test for MessagingWorkflowPlanner with real channel manifests in src/lib/actions/sandbox/rebuild-messaging-stage.ts:1
  • PRA-T1 Add or justify test follow-up: Runtime validation
  • PRA-T2 Add or justify test follow-up: Runtime validation
  • PRA-T3 Add or justify test follow-up: Runtime validation
  • PRA-T4 Add or justify test follow-up: Missing direct unit tests for config hash command edge cases (exit codes 10, 12, 13)
  • PRA-T5 Add or justify test follow-up: Missing integration test for MessagingWorkflowPlanner with real channel manifests
  • PRA-T6 Add or justify test follow-up: Add explanatory comment for require.cache snapshot/restore pattern
  • PRA-4 In-scope improvement: Document package-contract test pattern for require.cache isolation in test/package-contract/rebuild-loader-boundary.test.ts:1
  • PRA-5 In-scope improvement: Add explanatory comment for require.cache snapshot/restore pattern in test/package-contract/rebuild-loader-boundary.test.ts:29

Findings index

ID Severity Category Location Required action
PRA-1 Required acceptance src/lib/actions/sandbox/rebuild-flow-helpers.test.ts:1 Coordinate with PR #6211 author before merge; ensure test changes are compatible or sequence merges appropriately.
PRA-2 Resolve/justify tests src/lib/actions/sandbox/rebuild-config-hash-command.ts:1 Add direct unit tests in a new rebuild-config-hash-command.test.ts for exit codes 10, 12, 13 to complement existing integration-style test.
PRA-3 Resolve/justify tests src/lib/actions/sandbox/rebuild-messaging-stage.ts:1 Add an integration-style test in rebuild-messaging-stage.test.ts that uses real createBuiltInChannelManifestRegistry and MessagingWorkflowPlanner to verify end-to-end plan staging for a known agent with configured channels.
PRA-4 Improvement architecture test/package-contract/rebuild-loader-boundary.test.ts:1 Document this pattern in test/package-contract/README.md or CONTRIBUTING.md as the accepted approach for package-contract tests that must verify lazy-loading boundaries in built artifacts.
PRA-5 Improvement tests test/package-contract/rebuild-loader-boundary.test.ts:29 Add a code comment before snapshotRequireCache explaining: 'Package-contract tests load compiled dist/ output via createRequire to verify the actual build artifact. require.cache snapshot/restore isolates these loads from other tests and from each other.'

🚨 Required before merge

Address these before merging unless a maintainer explicitly overrides the advisor with rationale.

PRA-1 Required — Overlapping changes with PR #6211 on rebuild-flow-helpers.test.ts

Review findings by urgency: 1 required fix, 2 items to resolve/justify, 2 in-scope improvements

⚠️ Resolve or justify before merge

Investigate these in the current review; either fix them, explain why they are not applicable, or document the accepted risk.

PRA-2 Resolve/justify — Missing direct unit tests for config hash command edge cases (exit codes 10, 12, 13)

  • Location: src/lib/actions/sandbox/rebuild-config-hash-command.ts:1
  • Category: tests
  • Problem: Extracted buildRefreshMutableOpenClawConfigHashCommand has 5 exit codes: 10 (symlinked config dir), 11 (symlinked config file), 12 (symlinked hash file), 13 (cd failure), 14 (sha256sum failure). Integration test covers happy path, exit 11, and exit 14. No direct unit tests for exits 10, 12, 13.
  • Impact: Reduced confidence that shell injection defenses and symlink checks work in isolation from the executeSandboxCommand wrapper.
  • Recommended action: Add direct unit tests in a new rebuild-config-hash-command.test.ts for exit codes 10, 12, 13 to complement existing integration-style test.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Review rebuild-config-hash.test.ts — it tests happy path, symlinked config file refusal (exit 11), and sha256sum failure (exit 14). Direct unit tests for other exit codes would improve coverage.
  • Missing regression test: Direct unit tests for exit codes 10 (symlinked config dir), 12 (symlinked hash file), 13 (cd failure) in rebuild-config-hash-command.test.ts
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Review rebuild-config-hash.test.ts — it tests happy path, symlinked config file refusal (exit 11), and sha256sum failure (exit 14). Direct unit tests for other exit codes would improve coverage.
  • Evidence: rebuild-config-hash.test.ts has 3 tests; new test covers exit 14; no tests for exits 10, 12, 13

PRA-3 Resolve/justify — Missing integration test for MessagingWorkflowPlanner with real channel manifests

  • Location: src/lib/actions/sandbox/rebuild-messaging-stage.ts:1
  • Category: tests
  • Problem: Extracted stageMessagingManifestPlanForRebuild uses MessagingWorkflowPlanner with createBuiltInChannelManifestRegistry and createBuiltInRenderTemplateResolver. Current tests mock loadAgent and MessagingSetupApplier but do not exercise the full planner integration with real manifests.
  • Impact: Drift between manifest registry and rebuild staging could go undetected until runtime.
  • Recommended action: Add an integration-style test in rebuild-messaging-stage.test.ts that uses real createBuiltInChannelManifestRegistry and MessagingWorkflowPlanner to verify end-to-end plan staging for a known agent with configured channels.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Review rebuild-messaging-stage.test.ts — it mocks loadAgent, MessagingSetupApplier, and verifies clearPlanEnv/writePlanEnv calls. No test uses the real MessagingWorkflowPlanner with built-in manifests.
  • Missing regression test: Integration test using real createBuiltInChannelManifestRegistry and MessagingWorkflowPlanner to verify end-to-end plan staging
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Review rebuild-messaging-stage.test.ts — it mocks loadAgent, MessagingSetupApplier, and verifies clearPlanEnv/writePlanEnv calls. No test uses the real MessagingWorkflowPlanner with built-in manifests.
  • Evidence: rebuild-messaging-stage.test.ts has 3 tests, all using mocks for planner dependencies

💡 In-scope improvements

These are lower-risk, not throwaway. Prefer fixing them in this PR when they are local to changed code; defer only with rationale or a linked follow-up.

PRA-4 Improvement — Document package-contract test pattern for require.cache isolation

  • Location: test/package-contract/rebuild-loader-boundary.test.ts:1
  • Category: architecture
  • Problem: New package-contract test verifies the lazy loading contract for upgradeSandboxesDependencies.rebuildSandbox. The test uses createRequire (CommonJS) to load compiled output and snapshots/restores require.cache for test isolation. This is an appropriate pattern for contract tests but is undocumented.
  • Impact: Future package-contract tests may adopt inconsistent patterns without documented guidance.
  • Suggested action: Document this pattern in test/package-contract/README.md or CONTRIBUTING.md as the accepted approach for package-contract tests that must verify lazy-loading boundaries in built artifacts.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Inspect test/package-contract/ directory — no README.md or pattern documentation exists yet.
  • Missing regression test: Documentation file test/package-contract/README.md describing the accepted require.cache snapshot/restore pattern for compiled contract tests
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: rebuild-loader-boundary.test.ts lines 16-35 implement snapshotRequireCache/restoreRequireCache for test isolation

PRA-5 Improvement — Add explanatory comment for require.cache snapshot/restore pattern

  • Location: test/package-contract/rebuild-loader-boundary.test.ts:29
  • Category: tests
  • Problem: The package-contract test uses require.cache snapshot/restore to isolate compiled module loads between test runs. While the code is clear, an inline comment would help future maintainers understand why this pattern is used instead of Vitest's native isolation.
  • Impact: Minor — future maintainers may misinterpret the pattern as a workaround rather than an intentional contract-test strategy.
  • Suggested action: Add a code comment before snapshotRequireCache explaining: 'Package-contract tests load compiled dist/ output via createRequire to verify the actual build artifact. require.cache snapshot/restore isolates these loads from other tests and from each other.'
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Open test/package-contract/rebuild-loader-boundary.test.ts lines 16-35 — no explanatory comment exists for the require.cache manipulation.
  • Missing regression test: N/A — documentation improvement
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: rebuild-loader-boundary.test.ts lines 16-35 implement snapshotRequireCache/restoreRequireCache without explanatory comment
Test follow-ups to resolve or justify

If these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.

  • PRA-T1 Runtime validation — Direct unit tests for rebuild-config-hash-command exit codes 10 (symlinked config dir), 12 (symlinked hash file), 13 (cd failure). Runtime/sandbox/infrastructure paths need behavioral runtime validation: config hash command (shell execution), messaging planner (manifest integration), upgrade-sandboxes (gateway/recovery orchestration). Current tests are unit/mock-based; integration validation recommended for extracted modules.
  • PRA-T2 Runtime validation — Integration test for MessagingWorkflowPlanner with real createBuiltInChannelManifestRegistry and createBuiltInRenderTemplateResolver to verify end-to-end plan staging. Runtime/sandbox/infrastructure paths need behavioral runtime validation: config hash command (shell execution), messaging planner (manifest integration), upgrade-sandboxes (gateway/recovery orchestration). Current tests are unit/mock-based; integration validation recommended for extracted modules.
  • PRA-T3 Runtime validation — Runtime validation of lazy rebuild loading under actual upgrade-sandboxes execution (beyond compiled contract test). Runtime/sandbox/infrastructure paths need behavioral runtime validation: config hash command (shell execution), messaging planner (manifest integration), upgrade-sandboxes (gateway/recovery orchestration). Current tests are unit/mock-based; integration validation recommended for extracted modules.
  • PRA-T4 Missing direct unit tests for config hash command edge cases (exit codes 10, 12, 13) — Add direct unit tests in a new rebuild-config-hash-command.test.ts for exit codes 10, 12, 13 to complement existing integration-style test.
  • PRA-T5 Missing integration test for MessagingWorkflowPlanner with real channel manifests — Add an integration-style test in rebuild-messaging-stage.test.ts that uses real createBuiltInChannelManifestRegistry and MessagingWorkflowPlanner to verify end-to-end plan staging for a known agent with configured channels.
  • PRA-T6 Add explanatory comment for require.cache snapshot/restore pattern — Add a code comment before snapshotRequireCache explaining: 'Package-contract tests load compiled dist/ output via createRequire to verify the actual build artifact. require.cache snapshot/restore isolates these loads from other tests and from each other.'
Since last review details

Current findings, using the urgency labels above:

PRA-1 Required — Overlapping changes with PR #6211 on rebuild-flow-helpers.test.ts

PRA-2 Resolve/justify — Missing direct unit tests for config hash command edge cases (exit codes 10, 12, 13)

  • Location: src/lib/actions/sandbox/rebuild-config-hash-command.ts:1
  • Category: tests
  • Problem: Extracted buildRefreshMutableOpenClawConfigHashCommand has 5 exit codes: 10 (symlinked config dir), 11 (symlinked config file), 12 (symlinked hash file), 13 (cd failure), 14 (sha256sum failure). Integration test covers happy path, exit 11, and exit 14. No direct unit tests for exits 10, 12, 13.
  • Impact: Reduced confidence that shell injection defenses and symlink checks work in isolation from the executeSandboxCommand wrapper.
  • Recommended action: Add direct unit tests in a new rebuild-config-hash-command.test.ts for exit codes 10, 12, 13 to complement existing integration-style test.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Review rebuild-config-hash.test.ts — it tests happy path, symlinked config file refusal (exit 11), and sha256sum failure (exit 14). Direct unit tests for other exit codes would improve coverage.
  • Missing regression test: Direct unit tests for exit codes 10 (symlinked config dir), 12 (symlinked hash file), 13 (cd failure) in rebuild-config-hash-command.test.ts
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Review rebuild-config-hash.test.ts — it tests happy path, symlinked config file refusal (exit 11), and sha256sum failure (exit 14). Direct unit tests for other exit codes would improve coverage.
  • Evidence: rebuild-config-hash.test.ts has 3 tests; new test covers exit 14; no tests for exits 10, 12, 13

PRA-3 Resolve/justify — Missing integration test for MessagingWorkflowPlanner with real channel manifests

  • Location: src/lib/actions/sandbox/rebuild-messaging-stage.ts:1
  • Category: tests
  • Problem: Extracted stageMessagingManifestPlanForRebuild uses MessagingWorkflowPlanner with createBuiltInChannelManifestRegistry and createBuiltInRenderTemplateResolver. Current tests mock loadAgent and MessagingSetupApplier but do not exercise the full planner integration with real manifests.
  • Impact: Drift between manifest registry and rebuild staging could go undetected until runtime.
  • Recommended action: Add an integration-style test in rebuild-messaging-stage.test.ts that uses real createBuiltInChannelManifestRegistry and MessagingWorkflowPlanner to verify end-to-end plan staging for a known agent with configured channels.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Review rebuild-messaging-stage.test.ts — it mocks loadAgent, MessagingSetupApplier, and verifies clearPlanEnv/writePlanEnv calls. No test uses the real MessagingWorkflowPlanner with built-in manifests.
  • Missing regression test: Integration test using real createBuiltInChannelManifestRegistry and MessagingWorkflowPlanner to verify end-to-end plan staging
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Review rebuild-messaging-stage.test.ts — it mocks loadAgent, MessagingSetupApplier, and verifies clearPlanEnv/writePlanEnv calls. No test uses the real MessagingWorkflowPlanner with built-in manifests.
  • Evidence: rebuild-messaging-stage.test.ts has 3 tests, all using mocks for planner dependencies

PRA-4 Improvement — Document package-contract test pattern for require.cache isolation

  • Location: test/package-contract/rebuild-loader-boundary.test.ts:1
  • Category: architecture
  • Problem: New package-contract test verifies the lazy loading contract for upgradeSandboxesDependencies.rebuildSandbox. The test uses createRequire (CommonJS) to load compiled output and snapshots/restores require.cache for test isolation. This is an appropriate pattern for contract tests but is undocumented.
  • Impact: Future package-contract tests may adopt inconsistent patterns without documented guidance.
  • Suggested action: Document this pattern in test/package-contract/README.md or CONTRIBUTING.md as the accepted approach for package-contract tests that must verify lazy-loading boundaries in built artifacts.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Inspect test/package-contract/ directory — no README.md or pattern documentation exists yet.
  • Missing regression test: Documentation file test/package-contract/README.md describing the accepted require.cache snapshot/restore pattern for compiled contract tests
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: rebuild-loader-boundary.test.ts lines 16-35 implement snapshotRequireCache/restoreRequireCache for test isolation

PRA-5 Improvement — Add explanatory comment for require.cache snapshot/restore pattern

  • Location: test/package-contract/rebuild-loader-boundary.test.ts:29
  • Category: tests
  • Problem: The package-contract test uses require.cache snapshot/restore to isolate compiled module loads between test runs. While the code is clear, an inline comment would help future maintainers understand why this pattern is used instead of Vitest's native isolation.
  • Impact: Minor — future maintainers may misinterpret the pattern as a workaround rather than an intentional contract-test strategy.
  • Suggested action: Add a code comment before snapshotRequireCache explaining: 'Package-contract tests load compiled dist/ output via createRequire to verify the actual build artifact. require.cache snapshot/restore isolates these loads from other tests and from each other.'
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Open test/package-contract/rebuild-loader-boundary.test.ts lines 16-35 — no explanatory comment exists for the require.cache manipulation.
  • Missing regression test: N/A — documentation improvement
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: rebuild-loader-boundary.test.ts lines 16-35 implement snapshotRequireCache/restoreRequireCache without explanatory comment

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: rebuild-openclaw, rebuild-hermes, upgrade-stale-sandbox
Optional E2E: sandbox-rebuild, hermes-discord

Dispatch hint: rebuild-openclaw,rebuild-hermes,upgrade-stale-sandbox

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • rebuild-openclaw (high): Directly exercises the real OpenClaw rebuild path touched by the config-hash and rebuild facade changes, including old sandbox recreation, post-rebuild gateway token rotation, backup hygiene, policy preservation, and a live .config-hash validity check.
  • rebuild-hermes (high): Covers the live rebuild path with a persisted messaging plan and credential placeholder preservation. This is the closest existing E2E guard for the moved stageMessagingManifestPlanForRebuild module and its credential/messaging rebuild contract.
  • upgrade-stale-sandbox (high): Covers the live upgrade-sandboxes --check stale-sandbox detection boundary and the real rebuild lifecycle for a stale OpenClaw sandbox. This is required because upgrade-sandboxes.ts changed selected-gateway dependency handling and the rebuild handoff boundary.

Optional E2E

  • sandbox-rebuild (high): Useful adjacent confidence for the normal current OpenClaw onboard-then-rebuild path, registry refresh, state preservation, and backup credential hygiene. It is less targeted than rebuild-openclaw for the config-hash change.
  • hermes-discord (high): Optional broader messaging confidence for Hermes Discord provider setup, credential isolation, native gateway rewrite, and rebuild credential reuse. Run if reviewers want extra coverage around messaging/credential side effects beyond rebuild-hermes.

New E2E recommendations

  • upgrade-sandboxes automatic rebuild handoff (high): The existing upgrade-stale-sandbox E2E validates upgrade-sandboxes --check and then invokes nemoclaw <sandbox> rebuild --yes directly; it does not appear to execute upgrade-sandboxes in auto/confirmed mode through the new lazy upgradeSandboxesDependencies.rebuildSandbox forwarding path.
    • Suggested test: Add a live upgrade-sandboxes-auto-rebuild E2E that creates a stale sandbox, runs nemoclaw upgrade-sandboxes --yes or the non-interactive equivalent, and verifies the command itself forwards to rebuild and leaves the sandbox upgraded.
  • prepared-backup recovery handoff (medium): The changed upgrade-sandboxes dependency boundary also affects prepared-backup recovery forwarding, but current coverage found here is unit-level. A live destructive recovery path would catch package/loader or selected-gateway issues that unit mocks cannot.
    • Suggested test: Add a live upgrade-prepared-backup-recovery E2E that seeds a validated pre-upgrade rebuild backup for a non-Ready same-gateway sandbox, runs upgrade-sandboxes with restore intent, and verifies the recovered sandbox and state.

Dispatch hint

  • Workflow: .github/workflows/e2e.yaml
  • jobs input: rebuild-openclaw,rebuild-hermes,upgrade-stale-sandbox

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

E2E Target Recommendation

Required E2E targets: rebuild-openclaw, channels-add-remove, upgrade-stale-sandbox
Optional E2E targets: channels-stop-start, sandbox-rebuild

Dispatch required E2E targets:

  • gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=rebuild-openclaw
  • gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=channels-add-remove
  • gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=upgrade-stale-sandbox

Workflow run

Full E2E target advisor summary

E2E Target Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E targets

  • rebuild-openclaw: OpenClaw rebuild code changed, including the post-restore mutable OpenClaw config-hash refresh path and rebuild messaging-plan staging facade. This job runs the real OpenClaw rebuild flow and validates the rebuilt sandbox's .openclaw config hash and restored runtime state.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=rebuild-openclaw
  • channels-add-remove: The rebuild messaging manifest staging implementation was split out and re-exported. This job exercises configured messaging channels across add/remove operations with real rebuilds, covering the changed staging path before Dockerfile/config reapplication.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=channels-add-remove
  • upgrade-stale-sandbox: upgrade-sandboxes changed its gateway-port dependency and lazy rebuild forwarding boundary. This job is the wired live upgrade-sandboxes lane and exercises the stale-sandbox detection path plus the downstream rebuild contract on a real OpenClaw sandbox.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=upgrade-stale-sandbox

Optional E2E targets

  • channels-stop-start: Adjacent messaging rebuild coverage: runs stop/start channel rebuild flows across the job's agent matrix, useful additional evidence for the refactored messaging plan staging path beyond the primary add/remove lane.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=channels-stop-start
  • sandbox-rebuild: Adjacent generic OpenClaw sandbox rebuild coverage that exercises the real nemoclaw <sandbox> rebuild --yes path and backup hygiene, but the more specific rebuild-openclaw job is the primary config-hash target for this PR.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field jobs=sandbox-rebuild

Relevant changed files

  • src/lib/actions/sandbox/rebuild-config-hash-command.ts
  • src/lib/actions/sandbox/rebuild-config-hash.ts
  • src/lib/actions/sandbox/rebuild-messaging-phase.ts
  • src/lib/actions/sandbox/rebuild-messaging-stage.ts
  • src/lib/actions/upgrade-sandboxes.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/lib/actions/sandbox/rebuild-flow-helpers.test.ts (1)

45-54: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Double-cast (as unknown as X) masks a fixture/type mismatch.

makeSandboxEntry's return is force-cast through unknown, which fully bypasses structural type-checking against Parameters<typeof backupSandboxStateForRebuild>[1]. If that parameter type later gains new required fields, this fixture will silently stay incomplete without a compiler error. Consider building a fixture that actually satisfies the type (e.g., via satisfies plus filling in the missing required fields) or using Partial<...> explicitly if a partial fixture is intentional.

🤖 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-flow-helpers.test.ts` around lines 45 - 54,
The double-cast in makeSandboxEntry is hiding a fixture that may no longer match
Parameters<typeof backupSandboxStateForRebuild>[1]. Replace the as unknown as X
pattern with a real value that structurally satisfies the target type, or make
the intent explicit by using Partial<...> if a partial fixture is required. Use
makeSandboxEntry and backupSandboxStateForRebuild as the key references when
updating the test fixture.
🤖 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/rebuild-config-hash-command.ts`:
- Around line 9-23: The shell command built by rebuild-config-hash-command
currently masks failures from writing the new hash because the `sha256sum` step
is followed by a permissive `chmod ... || true` in a `;`-joined chain. Update
the command returned by the config hash builder so the write to `.config-hash`
must succeed before any later step runs, using a fail-fast chain or an explicit
exit path, and keep the existing symlink/ownership checks intact. Make sure
`refreshMutableOpenClawConfigHashAfterPostRestoreWrites` can detect the failure
via `mutableConfigHashRefreshUnverified` rather than seeing a false success.

---

Nitpick comments:
In `@src/lib/actions/sandbox/rebuild-flow-helpers.test.ts`:
- Around line 45-54: The double-cast in makeSandboxEntry is hiding a fixture
that may no longer match Parameters<typeof backupSandboxStateForRebuild>[1].
Replace the as unknown as X pattern with a real value that structurally
satisfies the target type, or make the intent explicit by using Partial<...> if
a partial fixture is required. Use makeSandboxEntry and
backupSandboxStateForRebuild as the key references when updating the test
fixture.
🪄 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: e4471059-1f24-4670-b509-1f01ca66bc09

📥 Commits

Reviewing files that changed from the base of the PR and between 5a6f489 and dd451c9.

📒 Files selected for processing (11)
  • scripts/checks/test-create-require-budget.ts
  • src/lib/actions/sandbox/rebuild-config-hash-command.ts
  • src/lib/actions/sandbox/rebuild-config-hash.test.ts
  • src/lib/actions/sandbox/rebuild-config-hash.ts
  • src/lib/actions/sandbox/rebuild-flow-helpers.test.ts
  • src/lib/actions/sandbox/rebuild-messaging-phase.ts
  • src/lib/actions/sandbox/rebuild-messaging-stage.test.ts
  • src/lib/actions/sandbox/rebuild-messaging-stage.ts
  • src/lib/actions/upgrade-sandboxes-preflight.test.ts
  • src/lib/actions/upgrade-sandboxes-recovery.test.ts
  • src/lib/actions/upgrade-sandboxes.ts
💤 Files with no reviewable changes (1)
  • scripts/checks/test-create-require-budget.ts

Comment thread src/lib/actions/sandbox/rebuild-config-hash-command.ts
@cv

cv commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Automated-review follow-up on final head d388d5cb7:

No docs update is needed: the CLI already reports and remediates the existing incomplete config-hash state, and no user-facing command/config contract changed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
test/package-contract/rebuild-loader-boundary.test.ts (2)

62-62: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicate path literal instead of reusing rebuildPath.

Test 1 already computes rebuildPath via path.join(repoRoot, ...); test 2 hardcodes "../../dist/lib/actions/sandbox/rebuild.js" instead of reusing a shared path derivation, risking drift if the dist layout changes.

♻️ Proposed fix
   it("preserves the public rebuild facade exports (`#6245`)", () => {
-    const rebuild = require("../../dist/lib/actions/sandbox/rebuild.js") as {
+    const rebuildPath = path.join(repoRoot, "dist", "lib", "actions", "sandbox", "rebuild.js");
+    const rebuild = require(rebuildPath) as {
       buildRefreshMutableOpenClawConfigHashCommand?: (configDir?: string) => string;
       stageMessagingManifestPlanForRebuild?: (...args: unknown[]) => Promise<unknown>;
     };
🤖 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/package-contract/rebuild-loader-boundary.test.ts` at line 62, The
rebuild boundary test hardcodes the dist module path in the second test instead
of reusing the already computed rebuildPath, which can drift if the layout
changes. Update the require in rebuild-loader-boundary.test.ts to use the shared
rebuildPath (or the same path derivation logic used in the first test) so both
tests resolve the same target consistently.

22-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Avoid tying this test to Module._load internals. The lazy-load assertion depends on an undocumented Node loader hook, so it’s brittle across Node upgrades. Prefer a public-boundary check, or isolate the loader seam behind an injectable helper if this coverage must stay.

🤖 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/package-contract/rebuild-loader-boundary.test.ts` around lines 22 - 35,
The test is coupled to Node’s internal Module._load loader hook, which is
brittle across Node versions. Update rebuild-loader-boundary.test.ts to verify
the lazy-load behavior through a public boundary instead, or extract the loading
behavior into an injectable helper and test that seam directly. Keep the
assertion centered on the upgradePath/rebuildSandbox flow and remove the direct
Module._load interception.

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 `@src/lib/actions/sandbox/rebuild-config-hash.test.ts`:
- Around line 71-93: Guard the failing hash-command test in
rebuild-config-hash.test.ts against root execution, since
buildRefreshMutableOpenClawConfigHashCommand can short-circuit with a 0 exit
when the config directory owner is root and bypass the injected sha256sum
failure. Update the test around runRefresh and the “reports hash command
failures instead of masking them” case to skip or assert the non-root assumption
when process.getuid?.() === 0 so the expected status 14 is only checked where
the failure path is reachable.

---

Nitpick comments:
In `@test/package-contract/rebuild-loader-boundary.test.ts`:
- Line 62: The rebuild boundary test hardcodes the dist module path in the
second test instead of reusing the already computed rebuildPath, which can drift
if the layout changes. Update the require in rebuild-loader-boundary.test.ts to
use the shared rebuildPath (or the same path derivation logic used in the first
test) so both tests resolve the same target consistently.
- Around line 22-35: The test is coupled to Node’s internal Module._load loader
hook, which is brittle across Node versions. Update
rebuild-loader-boundary.test.ts to verify the lazy-load behavior through a
public boundary instead, or extract the loading behavior into an injectable
helper and test that seam directly. Keep the assertion centered on the
upgradePath/rebuildSandbox flow and remove the direct Module._load interception.
🪄 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: 4d324da9-32ca-44ef-b215-09c69804821e

📥 Commits

Reviewing files that changed from the base of the PR and between dd451c9 and d388d5c.

📒 Files selected for processing (4)
  • src/lib/actions/sandbox/rebuild-config-hash-command.ts
  • src/lib/actions/sandbox/rebuild-config-hash.test.ts
  • src/lib/actions/sandbox/rebuild-flow-helpers.test.ts
  • test/package-contract/rebuild-loader-boundary.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/actions/sandbox/rebuild-config-hash-command.ts

Comment thread src/lib/actions/sandbox/rebuild-config-hash.test.ts Outdated
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

E2E Target Results — ❌ Some jobs failed

Run: 28857240747
Workflow ref: codex/perf-retire-rebuild-create-require
Requested targets: (default — all supported)
Requested jobs: rebuild-openclaw,rebuild-hermes,sandbox-rebuild,upgrade-stale-sandbox,channels-add-remove
Summary: 4 passed, 1 failed, 0 cancelled, 0 skipped

Job Result
channels-add-remove ✅ success
rebuild-hermes ✅ success
rebuild-openclaw ❌ failure
sandbox-rebuild ✅ success
upgrade-stale-sandbox ✅ success

Failed jobs: rebuild-openclaw. Check run artifacts for logs.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

E2E Target Results — ✅ All requested jobs passed

Run: 28857578895
Workflow ref: codex/perf-retire-rebuild-create-require
Requested targets: (default — all supported)
Requested jobs: rebuild-openclaw
Summary: 1 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
rebuild-openclaw ✅ success

@cv

cv commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Final-head validation settled:

  • All 40 PR checks are green, including the five CLI shards, merged coverage, package contracts, CodeQL, and both review advisors.
  • Live E2E passed for rebuild-hermes, sandbox-rebuild, upgrade-stale-sandbox, and channels-add-remove in run 28857240747. That run's OpenClaw target failed during legacy-image setup on an external npm ECONNRESET, before rebuild code ran; the isolated final-head retry passed in run 28857578895.
  • Matched CI collection for the optimized quartet fell from 28.806s to 3.254s: 25.552s / 88.7% less aggregate collection time. This is aggregate file collection, not a one-for-one shard-wall claim.

No unresolved actionable automated-review findings remain.

@cv

cv commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up abce9b744 also addresses CodeRabbit’s package-contract nits: both tests share module-level compiled paths, Module._load interception is gone, the dependency object exposes an explicit lazy loadRebuildModule() seam, and each case snapshots/restores the complete require.cache so the package-contract lane stays order-independent. Targeted CLI/package tests, type-check, build, Biome, normal hooks, and independent review pass.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

E2E Target Results — ✅ All requested jobs passed

Run: 28858495296
Workflow ref: codex/perf-retire-rebuild-create-require
Requested targets: (default — all supported)
Requested jobs: upgrade-stale-sandbox
Summary: 1 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
upgrade-stale-sandbox ✅ success

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

E2E Target Results — ✅ All requested jobs passed

Run: 28858774350
Workflow ref: codex/perf-retire-rebuild-create-require
Requested targets: (default — all supported)
Requested jobs: messaging-providers
Summary: 1 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
messaging-providers ✅ success

@cv

cv commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Final-head follow-up on abce9b744:

  • All 40 PR checks are green. CodeRabbit reports no actionable comments, and there are no unresolved review threads.
  • Matched final-head CI artifacts put the optimized quartet at 3.041s aggregate collection versus 28.806s on the prior merged head: 25.765s / 89.44% less collection work (9.47× faster).
  • Live E2E passed for rebuild-openclaw, rebuild-hermes, sandbox-rebuild, upgrade-stale-sandbox, channels-add-remove, and the broader-advisor messaging-providers target. The isolated final-head upgrade and messaging runs are 28858495296 and 28858774350.
  • Nemotron PRA-1 is resolved by explicit sequencing with fix(sandbox): allow rebuild --force to skip backup when container is unreachable #6211; the contributor coordination is recorded here. perf(test): retire rebuild CommonJS loader seams #6388 lands the native-import shape first, then fix(sandbox): allow rebuild --force to skip backup when container is unreachable #6211 can rebase its force-rebuild assertions onto it.
  • PRA-3 is a false positive: the third messaging-stage test executes the real built-in manifest registry, render resolver, and MessagingWorkflowPlanner; only agent discovery and environment output are observed/mocked.
  • PRA-2 and the cache-pattern documentation suggestions are non-blocking follow-ups. Exit paths 10/12/13 are unchanged shell branches moved intact by the extraction; this PR directly covers the pre-existing refusal path plus the newly fixed exit-14 failure propagation. Expanding into exhaustive legacy-branch and pattern-documentation work would not strengthen the changed performance contract enough to justify another final-head CI restart.

No further code changes are needed for this batch.

@cv
cv merged commit 6f02ede into main Jul 7, 2026
202 checks passed
@cv
cv deleted the codex/perf-retire-rebuild-create-require branch July 7, 2026 15:46
cv added a commit that referenced this pull request Jul 7, 2026
<!-- markdownlint-disable MD041 -->
## Summary
Run the integration project as a bounded four-worker phase during the
canonical local `npm test`, while keeping CI, coverage, focused
integration, and direct Vitest runs serialized. Isolate two onboarding
fixtures from host-global dashboard ports so the parallel suite remains
deterministic. This is the final cumulative #6245 step after the named
onboarding conversions, representative process-contract work, and
sequenced loader cleanup already merged; the final clean-build Node 22
suite passes in 3:52.03.

## Related Issue
Closes #6245.

## Changes
- Replace the dashboard-exhaustion fixture's real host listeners with a
fake `lsof` while retaining the real CLI, preflight, diagnostic, and
non-zero exit contract.
- Give the restore-intent fixture an explicit existing dashboard forward
so unrelated host port occupancy cannot divert the behavior under test.
- Resolve integration scheduling from npm lifecycle, CI, coverage, and
worker-cap inputs: local `npm test` uses at most four workers in group
1, while every safety-sensitive route stays serial.
- Add a behavior matrix covering local, CI, coverage, focused, direct,
and explicit worker-throttle modes.
- Complete the cumulative #6245 acceptance path after #6276/#6336/#6383
converted the named onboarding hotspots, #6285/#6417 retained
representative process contracts, and #6286/#6299/#6388/#6415 sequenced
loader cleanup after process removal.
- Record the final host-specific timings, hotspot disposition, and
retained process-contract inventory in `test/README.md` as an advisory
acceptance snapshot rather than a permanent CI budget.

## Type of Change

- [ ] Code change (feature, bug fix, or refactor)
- [x] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Quality Gates
<!-- Check exactly one tests line and one docs line. Check other lines
when applicable. Add every requested justification or approval
reference. -->
- [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: Test fixtures and local
test-runner scheduling changed; NemoClaw commands, configuration,
runtime behavior, and CI/coverage workflows are unchanged.
- [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 final-diff
review confirmed that the fake `lsof` preserves the real
CLI/preflight/exit contract, the restore-intent assertions remain
intact, and resolved CI/coverage configurations remain serialized.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Verification
<!-- Check each applicable item only when supported by the requested
evidence. Run targeted tests once per relevant change set and rerun
after later edits or hook autofixes that can affect the tested behavior.
Do not rerun hook-covered checks. -->
- [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: Real
CLI exhaustion contract passed; restore-intent passed with all 11
dashboard ports deliberately occupied; scheduling matrix passed 14/14
through the lifecycle-triggered config; `npm run test:projects:check`
reported 1,327 files disjoint across 8 projects.
- [x] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result: Clean-build Node 22 `npm
test -- --reporter=blob` under the normal `umask 022` passed 1,251 files
and 13,879 tests with 39 skipped, 1 todo, and zero failures in 3:52.03,
down 73% from the issue's 14:19.65 baseline despite a larger suite. The
matching diff-scoped routine pre-commit stage passed in 13.95s. #6270
separately removed full coverage from routine pre-commit while
preserving manual and authoritative CI gates.
- [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)

---
<!-- DCO sign-off is required in this PR description, and every commit
must appear as Verified in GitHub. Run: git config user.name && git
config user.email -->
Signed-off-by: Carlos Villela <cvillela@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Integration test runs now use adaptive scheduling to speed up local
execution while keeping CI/focused runs serialized.

* **Bug Fixes**
* Improved reliability of onboarding regression coverage by simulating
dashboard port exhaustion in a hermetic way.
* Updated onboarding-related fixtures to better match the intended
readiness/exit behavior.

* **Tests**
* Added coverage for integration scheduling behavior (local caps,
invalid inputs, and CI/coverage scenarios).

* **Documentation**
* Added test-suite documentation with a local performance snapshot and
key test hotspots.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Reduce cold collection overhead in four rebuild-focused CLI test files
by replacing CommonJS source-loader/cache-invalidation seams with native
source imports and dependency-light production boundaries. This
preserves the existing behavioral coverage while removing incidental
loading of the full rebuild graph.

## Related Issue

Refs NVIDIA#6245
Refs NVIDIA#6237

## Changes

- Extract messaging-plan staging and config-hash command construction
into dependency-light leaf modules while preserving the public rebuild
facade exports.
- Defer loading `sandbox/rebuild` from `upgrade-sandboxes` until a
sandbox actually needs rebuilding, with an explicit dependency seam for
focused tests.
- Convert four CLI suites from `createRequire`, cache deletion, and
loader warmups to native imports and typed spies.
- Tighten the exact-path `createRequire` ratchet from 32 to 28 CLI test
files.
- Preserve all 43 existing assertions in the optimized suites and the
real Bash/filesystem, manifest planner, recovery, and
gateway-classification contracts.
- Add a compiled package-contract test for lazy rebuild loading and
facade exports, and make config-hash refresh propagate `sha256sum`
failures instead of masking them behind best-effort permission repair.

Matched CI evidence: the previous merged head reported 28.806s of
aggregate collection time for these four files. Final-head NVIDIA#6388 CI
reports 3.041s, a reduction of 25.765s (89.44%; 9.47× faster), while
preserving the original assertions and adding the hash-failure
regression. Aggregate collection work overlaps across Vitest shards, so
this is not a claim of equivalent one-for-one shard-wall savings.

## 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 module-boundary and
test-loader refactor only; commands, flags, defaults, configuration,
protocols, and user-visible behavior are unchanged.
- [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: two independent source
reviews found no blocking findings; focused rebuild, recovery,
preflight, messaging, config-hash, and compiled package-contract
coverage passed.
- [ ] 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 — 126/126 focused CLI tests passed
across the optimized suites, upgrade preflight, and the broader rebuild
flow; 2/2 compiled package-contract tests and the ratchet's 8/8
integration tests also passed.
- [x] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — five-shard final-head `CI / Pull Request`
and coverage merge passed; all 40 PR checks are green.
- [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)

Additional local verification:

- `npm run typecheck:cli`
- `npm run build:cli`
- compiled package-contract coverage proves importing
`dist/lib/actions/upgrade-sandboxes.js` does not eagerly load the
rebuild module, forwards the lazy call exactly, and preserves both
extracted rebuild facade exports
- `npx tsx scripts/checks/test-create-require-budget.ts` (28 CLI files,
8 support files)
- `npm run test:projects:check`
- required live E2E passed: `rebuild-openclaw`, `rebuild-hermes`,
`sandbox-rebuild`, `upgrade-stale-sandbox`, and `channels-add-remove`,
and `messaging-providers` (OpenClaw passed on retry after an initial npm
`ECONNRESET` during fixture setup)
- `git diff --check`

---
Signed-off-by: Carlos Villela <cvillela@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added rebuild messaging “recreate contract” planning based on built-in
channel manifests.
* Introduced a safer sandbox config-hash refresh command with stricter
pre-checks before updating the mutable OpenClaw config hash.

* **Bug Fixes**
* Improved restore/recovery and rebuild messaging preparation, including
safer skip conditions when messaging support is unavailable.
* Ensured config-hash refresh failures surface correctly, with stronger
protections against symlinked/mismatched config inputs.

* **Tests**
* Updated and expanded package-contract and rebuild flow tests to
validate loader laziness and expected rebuild entrypoints.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
<!-- markdownlint-disable MD041 -->
## Summary
Run the integration project as a bounded four-worker phase during the
canonical local `npm test`, while keeping CI, coverage, focused
integration, and direct Vitest runs serialized. Isolate two onboarding
fixtures from host-global dashboard ports so the parallel suite remains
deterministic. This is the final cumulative NVIDIA#6245 step after the named
onboarding conversions, representative process-contract work, and
sequenced loader cleanup already merged; the final clean-build Node 22
suite passes in 3:52.03.

## Related Issue
Closes NVIDIA#6245.

## Changes
- Replace the dashboard-exhaustion fixture's real host listeners with a
fake `lsof` while retaining the real CLI, preflight, diagnostic, and
non-zero exit contract.
- Give the restore-intent fixture an explicit existing dashboard forward
so unrelated host port occupancy cannot divert the behavior under test.
- Resolve integration scheduling from npm lifecycle, CI, coverage, and
worker-cap inputs: local `npm test` uses at most four workers in group
1, while every safety-sensitive route stays serial.
- Add a behavior matrix covering local, CI, coverage, focused, direct,
and explicit worker-throttle modes.
- Complete the cumulative NVIDIA#6245 acceptance path after NVIDIA#6276/NVIDIA#6336/NVIDIA#6383
converted the named onboarding hotspots, NVIDIA#6285/NVIDIA#6417 retained
representative process contracts, and NVIDIA#6286/NVIDIA#6299/NVIDIA#6388/NVIDIA#6415 sequenced
loader cleanup after process removal.
- Record the final host-specific timings, hotspot disposition, and
retained process-contract inventory in `test/README.md` as an advisory
acceptance snapshot rather than a permanent CI budget.

## Type of Change

- [ ] Code change (feature, bug fix, or refactor)
- [x] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Quality Gates
<!-- Check exactly one tests line and one docs line. Check other lines
when applicable. Add every requested justification or approval
reference. -->
- [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: Test fixtures and local
test-runner scheduling changed; NemoClaw commands, configuration,
runtime behavior, and CI/coverage workflows are unchanged.
- [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 final-diff
review confirmed that the fake `lsof` preserves the real
CLI/preflight/exit contract, the restore-intent assertions remain
intact, and resolved CI/coverage configurations remain serialized.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Verification
<!-- Check each applicable item only when supported by the requested
evidence. Run targeted tests once per relevant change set and rerun
after later edits or hook autofixes that can affect the tested behavior.
Do not rerun hook-covered checks. -->
- [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: Real
CLI exhaustion contract passed; restore-intent passed with all 11
dashboard ports deliberately occupied; scheduling matrix passed 14/14
through the lifecycle-triggered config; `npm run test:projects:check`
reported 1,327 files disjoint across 8 projects.
- [x] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result: Clean-build Node 22 `npm
test -- --reporter=blob` under the normal `umask 022` passed 1,251 files
and 13,879 tests with 39 skipped, 1 todo, and zero failures in 3:52.03,
down 73% from the issue's 14:19.65 baseline despite a larger suite. The
matching diff-scoped routine pre-commit stage passed in 13.95s. NVIDIA#6270
separately removed full coverage from routine pre-commit while
preserving manual and authoritative CI gates.
- [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)

---
<!-- DCO sign-off is required in this PR description, and every commit
must appear as Verified in GitHub. Run: git config user.name && git
config user.email -->
Signed-off-by: Carlos Villela <cvillela@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Integration test runs now use adaptive scheduling to speed up local
execution while keeping CI/focused runs serialized.

* **Bug Fixes**
* Improved reliability of onboarding regression coverage by simulating
dashboard port exhaustion in a hermetic way.
* Updated onboarding-related fixtures to better match the intended
readiness/exit behavior.

* **Tests**
* Added coverage for integration scheduling behavior (local caps,
invalid inputs, and CI/coverage scenarios).

* **Documentation**
* Added test-suite documentation with a local performance snapshot and
key test hotspots.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output area: performance Latency, throughput, resource use, benchmarks, or scaling labels Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output area: performance Latency, throughput, resource use, benchmarks, or scaling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants