Skip to content

perf(test): retire rebuild gateway loader seam - #6415

Merged
cv merged 1 commit into
mainfrom
codex/perf-native-rebuild-gateway-drift
Jul 7, 2026
Merged

perf(test): retire rebuild gateway loader seam#6415
cv merged 1 commit into
mainfrom
codex/perf-native-rebuild-gateway-drift

Conversation

@cv

@cv cv commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replace the remaining CommonJS full-rebuild loader seam in the gateway-drift suite with native, focused source tests. Preserve the rebuild-specific fail-closed ordering through a dependency-light schema/intent composition boundary while keeping production behavior unchanged.

Related Issue

Refs #6245
Refs #6237

Changes

  • Rewrite all six rebuild-gateway-drift.test.ts cases against native gateway-schema and live-state seams instead of loading and mocking the complete rebuildSandbox graph through createRequire.
  • Keep the real [Ubuntu 24.04][Sandbox] stale sandbox recovery removes registry entry before rebuild can recover #4497 named-gateway classifier matrix for both default and persisted non-default gateway mismatches.
  • Route rebuild preflight through an ordered schema/intent helper so gateway drift still aborts before version confirmation, liveness, locking, or destructive phases.
  • Preserve real CLI/process contracts in the existing gateway-drift and stale-recovery integration suites.
  • Tighten the exact-path createRequire ratchet from 28 to 27 CLI test files; support paths remain at 8.
  • Reduce matched CI file time from 22,348.070ms on the exact main base to 2,744.496ms on the final head (87.72% lower, 8.14× faster), while preserving all 6/6 cases; collection fell 80.26% and test bodies fell 99.70%.

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 test-loader and preflight composition refactor only; CLI commands, output, errors, flags, defaults, DCode handling, state, and recovery 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: independent final-diff review verified the fail-closed schema-before-confirmation ordering, real wrong-gateway classifier coverage, mock isolation, unchanged DCode short-circuit semantics, and retained process/destructive-boundary contracts; no actionable findings remain.
  • 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 — 135/135 focused CLI tests passed across gateway classification, sandbox-list recovery, rebuild preflight, DCode, and the broader rebuild flow; 14/14 integration/process-contract tests passed for stale recovery, real gateway drift, and the loader ratchet; CLI typecheck passed.
  • Required focused live E2Es passed — gateway-drift-preflight and sandbox-rebuild both passed in run 28887907635; the typed DCode target separately validated the changed no-mutation rejection but encountered post-lifecycle inference-route instability on two attempts, documented in the final PR comment.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result: final-head five-shard CI, merged coverage, static/type checks, package lanes, and aggregate checks passed in run 28887585117.
  • 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)

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

Summary by CodeRabbit

  • Bug Fixes
    • Rebuild preflight now more reliably checks gateway state before continuing, helping prevent unsafe confirmation flows.
    • Rebuild recovery handling was tightened so stale or mismatched sandbox states are handled more consistently, with clearer failure behavior when checks cannot be completed.
  • Tests
    • Updated coverage for rebuild preflight and recovery scenarios to reflect the new flow and edge cases.

@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 a runRebuildGatewayIntentPreflight helper that gates intent confirmation on a gateway schema check, wires it into runRebuildPreflightPhase, migrates the rebuild-gateway-drift.test.ts suite from CommonJS createRequire to ESM imports with new unit tests, and removes that test file from the createRequire whitelist.

Changes

Gateway intent preflight refactor

Layer / File(s) Summary
New gateway intent preflight helper
src/lib/actions/sandbox/rebuild-preflight-guards.ts
Adds runRebuildGatewayIntentPreflight<T> which returns null if checkGatewaySchema() is false, otherwise returns the result of confirmIntent().
Wire helper into rebuild preflight phase
src/lib/actions/sandbox/rebuild-preflight-phase.ts
Replaces inline gateway schema check and confirmRebuildIntent call with a delegated call to runRebuildGatewayIntentPreflight, passing schema-check and intent-confirm callbacks.
Drift test suite migration to ESM and new preflight tests
src/lib/actions/sandbox/rebuild-gateway-drift.test.ts
Converts test setup from createRequire-based module loading to direct ESM imports, adds makeSandboxEntry, bail, recoveryStates test utilities, reworks beforeEach mocks, and adds a test validating preflight rejection on gateway schema mismatch.
resolveRebuildLiveState stale recovery tests
src/lib/actions/sandbox/rebuild-gateway-drift.test.ts
Replaces old rebuildSandbox-based stale recovery tests with direct resolveRebuildLiveState tests covering active gateway refusal, successful recovery, and generic query error handling.
Remove drift test from createRequire whitelist
scripts/checks/test-create-require-budget.ts
Removes rebuild-gateway-drift.test.ts from the allowed CLI_CREATE_REQUIRE_FILES list.

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

Sequence Diagram(s)

sequenceDiagram
  participant RebuildPreflightPhase
  participant RunRebuildGatewayIntentPreflight
  participant CheckRebuildGatewaySchemaPreflight
  participant ConfirmRebuildIntent

  RebuildPreflightPhase->>RunRebuildGatewayIntentPreflight: checkGatewaySchema, confirmIntent
  RunRebuildGatewayIntentPreflight->>CheckRebuildGatewaySchemaPreflight: checkGatewaySchema()
  alt schema check fails
    RunRebuildGatewayIntentPreflight-->>RebuildPreflightPhase: null
  else schema check passes
    RunRebuildGatewayIntentPreflight->>ConfirmRebuildIntent: confirmIntent()
    ConfirmRebuildIntent-->>RunRebuildGatewayIntentPreflight: versionCheck result
    RunRebuildGatewayIntentPreflight-->>RebuildPreflightPhase: versionCheck result
  end
Loading

Suggested labels: refactor

Suggested reviewers: jyaunches, prekshivyas

🚥 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 clearly matches the main change: retiring the rebuild gateway loader seam in 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-native-rebuild-gateway-drift

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-native-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-native-re... fd0b2d9 +/-
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-native-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-native-re... fd0b2d9 +/-
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 18:09 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

E2E Advisor Recommendation

Required E2E: gateway-drift-preflight, sandbox-rebuild
Optional E2E: rebuild-openclaw, gateway-guard-recovery

Dispatch hint: gateway-drift-preflight,sandbox-rebuild

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • gateway-drift-preflight (low): Required because the PR changes the gateway schema/drift preflight path for rebuild. This existing job validates the fail-closed OpenShell gateway drift boundary with the real CLI and PATH-resolved OpenShell/Docker shims before unsafe sandbox state mutation.
  • sandbox-rebuild (high): Required because rebuild preflight ordering is part of the user-visible sandbox lifecycle. This job runs a real onboarded sandbox through nemoclaw <sandbox> rebuild --yes and verifies state preservation, registry refresh, and backup hygiene after the changed preflight phase.

Optional E2E

  • rebuild-openclaw (high): Useful adjacent confidence because the changed preflight phase is shared by OpenClaw rebuilds and this job exercises an old OpenClaw sandbox rebuild with real OpenShell gateway state, registry/session seeding, state preservation, and gateway-token rotation.
  • gateway-guard-recovery (medium): Optional coverage for adjacent named-gateway recovery behavior, since the touched rebuild tests cover recovery states and stale/connected-other gateway handling around rebuild live-state resolution.

New E2E recommendations

  • rebuild gateway drift confirmation ordering (medium): Existing gateway-drift-preflight coverage validates fail-closed drift behavior for state mutation commands, and unit tests cover the rebuild helper. A dedicated E2E/regression target for nemoclaw <sandbox> rebuild with a drifted gateway would directly prove the changed contract: drift is reported before prompting/confirmation and before lock acquisition or destructive rebuild work.
    • Suggested test: Add a selective integration/E2E test that seeds a registry sandbox, simulates gateway image/schema drift, runs nemoclaw <sandbox> rebuild without --yes, and asserts no confirmation prompt or live-state mutation occurs.

Dispatch hint

  • Workflow: .github/workflows/e2e.yaml
  • jobs input: gateway-drift-preflight,sandbox-rebuild

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

E2E Target Recommendation

Required E2E targets: ubuntu-repo-cloud-langchain-deepagents-code
Optional E2E targets: None

Dispatch required E2E targets:

  • gh workflow run e2e.yaml --ref <pr-head-ref> --field targets=ubuntu-repo-cloud-langchain-deepagents-code

Workflow run

Full E2E target advisor summary

E2E Target Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E targets

  • ubuntu-repo-cloud-langchain-deepagents-code: The PR changes rebuild preflight ordering and gateway schema/intent gating. This is the smallest live-supported typed target on the trusted registry that executes a live nemoclaw <sandbox> rebuild --yes --verbose path via the dcode-rebuild-invalid-credential lifecycle.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field targets=ubuntu-repo-cloud-langchain-deepagents-code

Optional E2E targets

  • None.

Relevant changed files

  • src/lib/actions/sandbox/rebuild-preflight-guards.ts
  • src/lib/actions/sandbox/rebuild-preflight-phase.ts

@wscurran wscurran added area: ci CI workflows, checks, release automation, or GitHub Actions area: e2e End-to-end tests, nightly failures, or validation infrastructure chore Build, CI, dependency, or tooling maintenance labels Jul 7, 2026
@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: Resolve or justify PRA-1: Source-of-truth review needed: src/lib/actions/sandbox/rebuild-flow-helpers.ts:127-135.
Open items: 0 required · 2 warnings · 2 suggestions · 4 test follow-ups
Since last review: 0 prior items resolved · 0 still apply · 0 new items found

Action checklist

  • PRA-1 Resolve or justify: Source-of-truth review needed: src/lib/actions/sandbox/rebuild-flow-helpers.ts:127-135
  • PRA-2 Resolve or justify: Test coverage regression risk from CommonJS-to-ESM conversion in src/lib/actions/sandbox/rebuild-gateway-drift.test.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: Test coverage regression risk from CommonJS-to-ESM conversion
  • PRA-T4 Add or justify test follow-up: src/lib/actions/sandbox/rebuild-flow-helpers.ts:127-135
  • PRA-3 In-scope improvement: Dual gateway validation paths for DCode vs non-DCode rebuilds in src/lib/actions/sandbox/rebuild-preflight-phase.ts:122
  • PRA-4 In-scope improvement: Stale-recovery workaround relies on local registry as source of truth in src/lib/actions/sandbox/rebuild-flow-helpers.ts:130

Findings index

ID Severity Category Location Required action
PRA-1 Resolve/justify architecture Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
PRA-2 Resolve/justify tests src/lib/actions/sandbox/rebuild-gateway-drift.test.ts:1 Run the test suite and verify coverage for: (1) gateway image drift rejection before version/liveness RPCs, (2) stale recovery when different gateway is active (#4497), (3) named gateway recovery and retry before stale recovery, (4) non-default gateway (nemoclaw-<port>) recovery, (5) generic sandbox list failure without retry. If any scenario is not covered, add tests or document why it's covered elsewhere.
PRA-3 Improvement security src/lib/actions/sandbox/rebuild-preflight-phase.ts:122 Add a code comment in rebuild-preflight-phase.ts explaining that DCode's gateway validation occurs in rebuild-dcode-preflight.ts:ensureDcodeRebuildTargetGatewaySelected and during prepareDcodeReplacementBeforeMutation/revalidateDcodeReplacementAtMutationEdge. Consider extracting a shared gateway validation helper to avoid drift.
PRA-4 Improvement correctness src/lib/actions/sandbox/rebuild-flow-helpers.ts:130 No action needed in this PR. Track as technical debt. When OpenShell adds atomic recreate-from-registry, remove the workaround and add regression test that the old path is gone.
Review findings by urgency: 0 required fixes, 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-1 Resolve/justify — Source-of-truth review needed: src/lib/actions/sandbox/rebuild-flow-helpers.ts:127-135

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: Future test that fails if workaround remains after OpenShell adds the API
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: Comment at rebuild-flow-helpers.ts:127-135 explicitly documents workaround and removal condition

PRA-2 Resolve/justify — Test coverage regression risk from CommonJS-to-ESM conversion

  • Location: src/lib/actions/sandbox/rebuild-gateway-drift.test.ts:1
  • Category: tests
  • Problem: Test file reduced from 426 to 248 lines (-178). Old tests exercised end-to-end rebuildSandbox flow with extensive mocking of registry, onboard, agent, gateway, and drift detection. New tests focus on runRebuildGatewayIntentPreflight and resolveRebuildLiveState units. Need to confirm the stale-recovery, gateway-drift, and wrong-gateway-active scenarios from the old tests are fully covered by the new test suite or by other test files.
  • Impact: If stale-recovery, gateway-drift, or wrong-gateway-active branches are not covered, a regression could silently allow sandbox recreation on drifted gateway or with wrong gateway active, violating fail-closed guarantees.
  • Recommended action: Run the test suite and verify coverage for: (1) gateway image drift rejection before version/liveness RPCs, (2) stale recovery when different gateway is active ([Ubuntu 24.04][Sandbox] stale sandbox recovery removes registry entry before rebuild can recover #4497), (3) named gateway recovery and retry before stale recovery, (4) non-default gateway (nemoclaw-<port>) recovery, (5) generic sandbox list failure without retry. If any scenario is not covered, add tests or document why it's covered elsewhere.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Run `vitest run src/lib/actions/sandbox/rebuild-gateway-drift.test.ts` and check all 4 test cases pass. Compare with `vitest run --coverage` to verify branch coverage on resolveRebuildLiveState and runRebuildGatewayIntentPreflight.
  • Missing regression test: Automated test confirming gateway image drift is rejected before confirmIntent is called (covered by new test 'rejects gateway image drift before confirming rebuild intent'). Automated test confirming stale recovery is refused when wrong gateway is active (covered by it.each 'refuses stale recovery'). Automated test confirming gateway recovery retry before stale recovery (covered by it.each 'recovers $gatewayName and returns stale state').
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Run `vitest run src/lib/actions/sandbox/rebuild-gateway-drift.test.ts` and check all 4 test cases pass. Compare with `vitest run --coverage` to verify branch coverage on resolveRebuildLiveState and runRebuildGatewayIntentPreflight.
  • Evidence: Old test file used createRequire to load full rebuild graph; new file uses static imports and tests extracted functions directly. Three it.each cases cover the [Ubuntu 24.04][Sandbox] stale sandbox recovery removes registry entry before rebuild can recover #4497 scenarios but integration test for full rebuildSandbox flow is gone.

💡 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-3 Improvement — Dual gateway validation paths for DCode vs non-DCode rebuilds

  • Location: src/lib/actions/sandbox/rebuild-preflight-phase.ts:122
  • Category: security
  • Problem: DCode rebuild agents bypass the main preflight gateway schema check via short-circuit: `isDcodeRebuildAgent(rebuildAgent) || checkRebuildGatewaySchemaPreflight(...)`. DCode performs its own gateway validation in ensureDcodeRebuildTargetGatewaySelected and checkGatewaySchema during preparation/revalidation. This is architecturally sound but creates two validation paths that must stay in sync.
  • Impact: If DCode's gateway validation diverges from the main path, a gateway drift could be missed for DCode sandboxes while caught for others, creating inconsistent fail-closed behavior.
  • Suggested action: Add a code comment in rebuild-preflight-phase.ts explaining that DCode's gateway validation occurs in rebuild-dcode-preflight.ts:ensureDcodeRebuildTargetGatewaySelected and during prepareDcodeReplacementBeforeMutation/revalidateDcodeReplacementAtMutationEdge. Consider extracting a shared gateway validation helper to avoid drift.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Read rebuild-dcode-preflight.ts lines 130-160 (ensureDcodeRebuildTargetGatewaySelected) and lines 260-290 (prepareDcodeReplacementBeforeMutation calls checkGatewaySchema). Confirm both paths validate gateway health and schema.
  • Missing regression test: Test that DCode rebuild fails when gateway schema drift exists (should be covered by DCode preflight tests in rebuild-dcode-preflight.test.ts).
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: rebuild-preflight-phase.ts:122 short-circuits for DCode; rebuild-dcode-preflight.ts:182 and :280 call checkGatewaySchema during preparation and revalidation.

PRA-4 Improvement — Stale-recovery workaround relies on local registry as source of truth

  • Location: src/lib/actions/sandbox/rebuild-flow-helpers.ts:130
  • Category: correctness
  • Problem: Comment acknowledges workaround: 'Keep until OpenShell exposes an atomic recreate-from-registry recovery API.' The stale recovery path returns registry snapshot and skips backup, trusting local registry as source of truth when OpenShell reports sandbox missing on healthy gateway. This is a known gap, not introduced by this PR.
  • Impact: If local registry diverges from intended sandbox state (e.g., manual edits, corruption), stale recovery could recreate a sandbox with incorrect configuration. No data loss occurs but sandbox may not match user expectations.
  • Suggested action: No action needed in this PR. Track as technical debt. When OpenShell adds atomic recreate-from-registry, remove the workaround and add regression test that the old path is gone.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Search for 'atomic recreate-from-registry' in codebase to track when this workaround can be removed.
  • Missing regression test: Regression test that would fail if the stale-recovery workaround is still present after OpenShell adds the API (future work).
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: rebuild-flow-helpers.ts:127-135 comment explicitly documents the workaround and its removal condition.
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 vitest coverage on resolveRebuildLiveState and runRebuildGatewayIntentPreflight includes all branches for stale recovery, gateway drift, wrong gateway active, generic error. Runtime/sandbox/infrastructure paths need behavioral runtime validation: scripts/checks/test-create-require-budget.ts, src/lib/actions/sandbox/rebuild-preflight-guards.ts, src/lib/actions/sandbox/rebuild-preflight-phase.ts.
  • PRA-T2 Runtime validation — Confirm DCode rebuild gateway drift rejection is tested in rebuild-dcode-preflight.test.ts. Runtime/sandbox/infrastructure paths need behavioral runtime validation: scripts/checks/test-create-require-budget.ts, src/lib/actions/sandbox/rebuild-preflight-guards.ts, src/lib/actions/sandbox/rebuild-preflight-phase.ts.
  • PRA-T3 Test coverage regression risk from CommonJS-to-ESM conversion — Run the test suite and verify coverage for: (1) gateway image drift rejection before version/liveness RPCs, (2) stale recovery when different gateway is active ([Ubuntu 24.04][Sandbox] stale sandbox recovery removes registry entry before rebuild can recover #4497), (3) named gateway recovery and retry before stale recovery, (4) non-default gateway (nemoclaw-<port>) recovery, (5) generic sandbox list failure without retry. If any scenario is not covered, add tests or document why it's covered elsewhere.
  • PRA-T4 src/lib/actions/sandbox/rebuild-flow-helpers.ts:127-135 — Future test that fails if workaround remains after OpenShell adds the API. Comment at rebuild-flow-helpers.ts:127-135 explicitly documents workaround and removal condition
Since last review details

Current findings, using the urgency labels above:

PRA-1 Resolve/justify — Source-of-truth review needed: src/lib/actions/sandbox/rebuild-flow-helpers.ts:127-135

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: Future test that fails if workaround remains after OpenShell adds the API
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: Comment at rebuild-flow-helpers.ts:127-135 explicitly documents workaround and removal condition

PRA-2 Resolve/justify — Test coverage regression risk from CommonJS-to-ESM conversion

  • Location: src/lib/actions/sandbox/rebuild-gateway-drift.test.ts:1
  • Category: tests
  • Problem: Test file reduced from 426 to 248 lines (-178). Old tests exercised end-to-end rebuildSandbox flow with extensive mocking of registry, onboard, agent, gateway, and drift detection. New tests focus on runRebuildGatewayIntentPreflight and resolveRebuildLiveState units. Need to confirm the stale-recovery, gateway-drift, and wrong-gateway-active scenarios from the old tests are fully covered by the new test suite or by other test files.
  • Impact: If stale-recovery, gateway-drift, or wrong-gateway-active branches are not covered, a regression could silently allow sandbox recreation on drifted gateway or with wrong gateway active, violating fail-closed guarantees.
  • Recommended action: Run the test suite and verify coverage for: (1) gateway image drift rejection before version/liveness RPCs, (2) stale recovery when different gateway is active ([Ubuntu 24.04][Sandbox] stale sandbox recovery removes registry entry before rebuild can recover #4497), (3) named gateway recovery and retry before stale recovery, (4) non-default gateway (nemoclaw-<port>) recovery, (5) generic sandbox list failure without retry. If any scenario is not covered, add tests or document why it's covered elsewhere.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Run `vitest run src/lib/actions/sandbox/rebuild-gateway-drift.test.ts` and check all 4 test cases pass. Compare with `vitest run --coverage` to verify branch coverage on resolveRebuildLiveState and runRebuildGatewayIntentPreflight.
  • Missing regression test: Automated test confirming gateway image drift is rejected before confirmIntent is called (covered by new test 'rejects gateway image drift before confirming rebuild intent'). Automated test confirming stale recovery is refused when wrong gateway is active (covered by it.each 'refuses stale recovery'). Automated test confirming gateway recovery retry before stale recovery (covered by it.each 'recovers $gatewayName and returns stale state').
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Run `vitest run src/lib/actions/sandbox/rebuild-gateway-drift.test.ts` and check all 4 test cases pass. Compare with `vitest run --coverage` to verify branch coverage on resolveRebuildLiveState and runRebuildGatewayIntentPreflight.
  • Evidence: Old test file used createRequire to load full rebuild graph; new file uses static imports and tests extracted functions directly. Three it.each cases cover the [Ubuntu 24.04][Sandbox] stale sandbox recovery removes registry entry before rebuild can recover #4497 scenarios but integration test for full rebuildSandbox flow is gone.

PRA-3 Improvement — Dual gateway validation paths for DCode vs non-DCode rebuilds

  • Location: src/lib/actions/sandbox/rebuild-preflight-phase.ts:122
  • Category: security
  • Problem: DCode rebuild agents bypass the main preflight gateway schema check via short-circuit: `isDcodeRebuildAgent(rebuildAgent) || checkRebuildGatewaySchemaPreflight(...)`. DCode performs its own gateway validation in ensureDcodeRebuildTargetGatewaySelected and checkGatewaySchema during preparation/revalidation. This is architecturally sound but creates two validation paths that must stay in sync.
  • Impact: If DCode's gateway validation diverges from the main path, a gateway drift could be missed for DCode sandboxes while caught for others, creating inconsistent fail-closed behavior.
  • Suggested action: Add a code comment in rebuild-preflight-phase.ts explaining that DCode's gateway validation occurs in rebuild-dcode-preflight.ts:ensureDcodeRebuildTargetGatewaySelected and during prepareDcodeReplacementBeforeMutation/revalidateDcodeReplacementAtMutationEdge. Consider extracting a shared gateway validation helper to avoid drift.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Read rebuild-dcode-preflight.ts lines 130-160 (ensureDcodeRebuildTargetGatewaySelected) and lines 260-290 (prepareDcodeReplacementBeforeMutation calls checkGatewaySchema). Confirm both paths validate gateway health and schema.
  • Missing regression test: Test that DCode rebuild fails when gateway schema drift exists (should be covered by DCode preflight tests in rebuild-dcode-preflight.test.ts).
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: rebuild-preflight-phase.ts:122 short-circuits for DCode; rebuild-dcode-preflight.ts:182 and :280 call checkGatewaySchema during preparation and revalidation.

PRA-4 Improvement — Stale-recovery workaround relies on local registry as source of truth

  • Location: src/lib/actions/sandbox/rebuild-flow-helpers.ts:130
  • Category: correctness
  • Problem: Comment acknowledges workaround: 'Keep until OpenShell exposes an atomic recreate-from-registry recovery API.' The stale recovery path returns registry snapshot and skips backup, trusting local registry as source of truth when OpenShell reports sandbox missing on healthy gateway. This is a known gap, not introduced by this PR.
  • Impact: If local registry diverges from intended sandbox state (e.g., manual edits, corruption), stale recovery could recreate a sandbox with incorrect configuration. No data loss occurs but sandbox may not match user expectations.
  • Suggested action: No action needed in this PR. Track as technical debt. When OpenShell adds atomic recreate-from-registry, remove the workaround and add regression test that the old path is gone.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Search for 'atomic recreate-from-registry' in codebase to track when this workaround can be removed.
  • Missing regression test: Regression test that would fail if the stale-recovery workaround is still present after OpenShell adds the API (future work).
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: rebuild-flow-helpers.ts:127-135 comment explicitly documents the workaround and its removal condition.

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 Target Results — ✅ All requested jobs passed

Run: 28887907635
Workflow ref: codex/perf-native-rebuild-gateway-drift
Requested targets: (default — all supported)
Requested jobs: gateway-drift-preflight,sandbox-rebuild
Summary: 2 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
gateway-drift-preflight ✅ success
sandbox-rebuild ✅ success

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

E2E Target Results — ❌ Some jobs failed

Run: 28887907494
Workflow ref: codex/perf-native-rebuild-gateway-drift
Requested targets: ubuntu-repo-cloud-langchain-deepagents-code
Requested jobs: (default — all default-enabled free-standing jobs; explicit-only jobs openshell-gateway-auth-contract, mcp-bridge-dev, hermes-gpu-startup, sandbox-rlimits-connect, and jetson-nvmap-gpu are skipped unless selected)
Summary: 0 passed, 1 failed, 0 cancelled, 0 skipped

Job Result
live ❌ failure

Failed jobs: live. Check run artifacts for logs.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Merge posture: Informational / low confidence
Primary next action: Resolve or justify PRA-1: PR review advisor unavailable.
Open items: 0 required · 1 warning · 0 suggestions · 1 test follow-up
Top item: PR review advisor unavailable

Action checklist

  • PRA-1 Resolve or justify: PR review advisor unavailable
  • PRA-T1 Add or justify test follow-up: Runtime validation

Findings index

ID Severity Category Location Required action
PRA-1 Resolve/justify correctness Re-run the PR Review Advisor or perform a manual review.
Review findings by urgency: 0 required fixes, 1 item to resolve/justify, 0 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-1 Resolve/justify — PR review advisor unavailable

  • Location: not file-specific
  • Category: correctness
  • Problem: The automated advisor could not complete: timed out after 900000 ms
  • Impact: Automated review evidence is incomplete, so human review must cover the changed code manually.
  • Recommended action: Re-run the PR Review Advisor or perform a manual review.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the workflow logs and raw advisor artifact for the execution failure.
  • Missing regression test: No regression test recommendation is available because the advisor did not complete.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the workflow logs and raw advisor artifact for the execution failure.
  • Evidence: timed out after 900000 ms

💡 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.

  • None.
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 — Add or identify targeted runtime/integration validation for the changed behavior; do not report external E2E job pass/fail here.. Runtime/sandbox/infrastructure paths need behavioral runtime validation: scripts/checks/test-create-require-budget.ts, src/lib/actions/sandbox/rebuild-preflight-guards.ts, src/lib/actions/sandbox/rebuild-preflight-phase.ts.

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 Target Results — ❌ Some jobs failed

Run: 28888526048
Workflow ref: codex/perf-native-rebuild-gateway-drift
Requested targets: ubuntu-repo-cloud-langchain-deepagents-code
Requested jobs: (default — all default-enabled free-standing jobs; explicit-only jobs openshell-gateway-auth-contract, mcp-bridge-dev, hermes-gpu-startup, sandbox-rlimits-connect, and jetson-nvmap-gpu are skipped unless selected)
Summary: 0 passed, 1 failed, 0 cancelled, 0 skipped

Job Result
live ❌ failure

Failed jobs: live. Check run artifacts for logs.

@cv

cv commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Final-head verification for fd0b2d910 is complete.

Performance:

  • Exact matched base: 22,348.070ms total (13,770.862ms collection + 8,577.208ms tests).
  • Final head: 2,744.496ms total (2,718.539ms collection + 25.957ms tests), 6/6 passed.
  • Improvement: 87.72% lower, 8.14× faster. Collection fell 80.26%; test bodies fell 99.70%.
  • Source: final-head CI run 28887585117, shard-3 artifact 8147036751.

Validation:

  • All 41 PR checks passed; five CLI coverage shards, merged coverage, static/type checks, package lanes, CodeQL, and aggregate checks are green.
  • Local focused validation passed 135/135 CLI tests and 14/14 integration/process-contract tests; the exact createRequire guard is now 27 CLI paths / 8 support paths.
  • Required focused live jobs gateway-drift-preflight and sandbox-rebuild passed in run 28887907635.

DCode target disposition:

  • The first advisor-selected target run 28887907494 verified the changed contract: invalid credentials produced HTTP 401, rebuild aborted before mutation with the sandbox untouched, provider restoration succeeded, and the sandbox remained Ready. Its restored inference route returned HTTP 200 once but timed out on seven surrounding probes.
  • The single retry 28888526048 progressed past the changed rebuild lifecycle; managed dcode -n and connect --probe-only succeeded, then unrelated headless checks saw HTTP 000 from /v1/models and a second direct invocation timeout.
  • The two different post-lifecycle failures indicate external inference-route instability rather than a branch regression. No code change or further retry is warranted.

Automated-review disposition:

  • CodeRabbit produced no findings or inline comments.
  • GPT-5.5 timed out without a code finding; independent final-diff review covered the changed code and found no remaining correctness, security, typing, isolation, or destructive-ordering issue.
  • Nemotron PRA-2/PRA-T1/PRA-T3 are satisfied by the six direct cases, retained real classifier matrix, focused coverage, full-flow stale-recovery tests, and live rebuild jobs.
  • PRA-1/PRA-4/PRA-T4 describe the unchanged stale-registry source boundary; the existing source comment already identifies ownership, the missing atomic OpenShell API, and the removal condition.
  • PRA-3/PRA-T2 describe the pre-existing intentional DCode split. DCode still performs schema validation during preparation and again at the mutation edge; focused DCode flows passed, and both live attempts exercised the expected no-mutation rejection.

Documentation review found no user-facing change; existing rebuild documentation remains accurate.

@cv
cv merged commit fa73ac3 into main Jul 7, 2026
285 of 287 checks passed
@cv
cv deleted the codex/perf-native-rebuild-gateway-drift branch July 7, 2026 18:40
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
Replace the remaining CommonJS full-rebuild loader seam in the
gateway-drift suite with native, focused source tests. Preserve the
rebuild-specific fail-closed ordering through a dependency-light
schema/intent composition boundary while keeping production behavior
unchanged.

## Related Issue
Refs NVIDIA#6245
Refs NVIDIA#6237

## Changes
- Rewrite all six `rebuild-gateway-drift.test.ts` cases against native
gateway-schema and live-state seams instead of loading and mocking the
complete `rebuildSandbox` graph through `createRequire`.
- Keep the real NVIDIA#4497 named-gateway classifier matrix for both default
and persisted non-default gateway mismatches.
- Route rebuild preflight through an ordered schema/intent helper so
gateway drift still aborts before version confirmation, liveness,
locking, or destructive phases.
- Preserve real CLI/process contracts in the existing gateway-drift and
stale-recovery integration suites.
- Tighten the exact-path `createRequire` ratchet from 28 to 27 CLI test
files; support paths remain at 8.
- Reduce matched CI file time from 22,348.070ms on the exact main base
to 2,744.496ms on the final head (87.72% lower, 8.14× faster), while
preserving all 6/6 cases; collection fell 80.26% and test bodies fell
99.70%.

## 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
<!-- 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: internal test-loader and
preflight composition refactor only; CLI commands, output, errors,
flags, defaults, DCode handling, state, and recovery 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: independent final-diff
review verified the fail-closed schema-before-confirmation ordering,
real wrong-gateway classifier coverage, mock isolation, unchanged DCode
short-circuit semantics, and retained process/destructive-boundary
contracts; no actionable findings remain.
- [ ] 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 that 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 — 135/135 focused CLI tests passed
across gateway classification, sandbox-list recovery, rebuild preflight,
DCode, and the broader rebuild flow; 14/14 integration/process-contract
tests passed for stale recovery, real gateway drift, and the loader
ratchet; CLI typecheck passed.
- [x] Required focused live E2Es passed — `gateway-drift-preflight` and
`sandbox-rebuild` both passed in run 28887907635; the typed DCode target
separately validated the changed no-mutation rejection but encountered
post-lifecycle inference-route instability on two attempts, documented
in the final PR comment.
- [x] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result: final-head five-shard CI,
merged coverage, static/type checks, package lanes, and aggregate checks
passed in run 28887585117.
- [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

* **Bug Fixes**
* Rebuild preflight now more reliably checks gateway state before
continuing, helping prevent unsafe confirmation flows.
* Rebuild recovery handling was tightened so stale or mismatched sandbox
states are handled more consistently, with clearer failure behavior when
checks cannot be completed.
* **Tests**
* Updated coverage for rebuild preflight and recovery scenarios to
reflect the new flow and edge cases.

<!-- 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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI workflows, checks, release automation, or GitHub Actions area: e2e End-to-end tests, nightly failures, or validation infrastructure chore Build, CI, dependency, or tooling maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants