Skip to content

perf(test): avoid cold gateway dependency load - #11316

Merged
cv merged 5 commits into
mainfrom
codex/6237-gateway-loader-slice
Sep 10, 2026
Merged

perf(test): avoid cold gateway dependency load#11316
cv merged 5 commits into
mainfrom
codex/6237-gateway-loader-slice

Conversation

@cjagwani

@cjagwani cjagwani commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Outcome

Remove the cold source dependency load from the gateway-port laziness unit test while preserving the production lazy resolver. A cold run on baseline commit f72e8ff359 timed out after 15 seconds and took 24.69 seconds wall time; the focused change passed five cold runs with a 2.04-second median and passed a cold coverage run in 2.56 seconds.

Reason

#6237 tracks source-loader contention and hook timeouts in CLI coverage shards. This test needs to verify that the latest gateway port reaches the network environment resolver, but it does not need the resolver's production dependency graph.

Related issues

Part of #6237.

Changes

  • Allow GatewayHostRuntimeDeps to provide the existing gateway network environment resolver.
  • Keep the lazy production require as the default for callers that do not provide the resolver; a direct import would break the environment-reload contract documented at the call site.
  • Have the gateway host runtime unit test provide the narrow resolver and assert that it receives the latest port.

Verification

  • Cold baseline at f72e8ff359: npx vitest run --project cli src/lib/onboard/gateway-host-runtime.test.ts --coverage=false — reproduced the 15-second test timeout; 24.69 seconds wall time.
  • Five cold patched runs of the same test — 5/5 passed; 2.04 seconds median wall time.
  • Cold patched coverage run of the same test — 38/38 passed; 2.56 seconds wall time.
  • Focused run after syncing current main — 38/38 passed; 839 ms Vitest duration.
  • npx vitest run --project integration test/agents/openclaw/openclaw-integrity-pin-contract.test.ts --coverage=false — 8/8 passed against the current cache-seed manifest.
  • npx vitest run --project cli src/lib/onboard/gateway-host-runtime-https.test.ts --coverage=false — 3/3 passed.
  • npx vitest run --project integration test/automation/pull-requests/growth-guardrails.test.ts — 45/45 passed.
  • npm --prefix nemoclaw run build — passed.
  • npm run typecheck:cli — passed.
  • npm run check:diff — passed, including the secret scan and diff-scoped pre-commit, commit-message, and pre-push checks.
  • CI / Pull Request — all 12 CLI shards, merged coverage, static checks, compilation, plugin tests, installer integration, and final aggregate gate passed on the latest PR commit.
  • Documentation review — no documentation change is needed because production behavior and user-facing contracts are unchanged.
  • Diff inspection — no secrets, API keys, or credentials.
  • Latest PR commit 5e31b610f3867cbc2fc9f1aac181a05eb7011f06 appears as Verified in GitHub.

Review notes

This recreates only the two-file runtime-loader seam authored by @prekshivyas in #11098. It does not restore that PR's workflow, shard-count, timing-table, cache, or test-splitting changes. Production callers continue to use the existing lazy resolver.


Signed-off-by: Charan Jagwani cjagwani@nvidia.com

Summary by CodeRabbit

  • Refactor

    • Improved gateway startup environment resolution while preserving existing port and image configuration behavior.
    • Added support for providing a custom startup environment resolver.
  • Tests

    • Expanded coverage to verify that startup environment resolution receives the runtime-assigned gateway port.
    • Confirmed lazy gateway startup behavior remains unchanged.

Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
@cjagwani cjagwani self-assigned this Sep 9, 2026
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5592e072-4ef1-4f92-a9ad-695a8061c094

📥 Commits

Reviewing files that changed from the base of the PR and between 0df4ecf and de71bc1.

📒 Files selected for processing (2)
  • src/lib/onboard/gateway-host-runtime.test.ts
  • src/lib/onboard/gateway-host-runtime.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/lib/onboard/gateway-host-runtime.test.ts
  • src/lib/onboard/gateway-host-runtime.ts

Included review availability: Your plan provides up to 12 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The gateway runtime now accepts an optional network environment resolver. It uses the injected resolver with the lazily resolved gateway port and retains the dynamic module fallback. The test verifies the resolver call and resulting environment.

Changes

Gateway runtime environment resolution

Layer / File(s) Summary
Inject and validate the network environment resolver
src/lib/onboard/gateway-host-runtime.ts, src/lib/onboard/gateway-host-runtime.test.ts
GatewayHostRuntimeDeps adds an optional getGatewayStartNetworkEnv resolver. getGatewayStartEnv uses the injected resolver when available and otherwise loads the existing module resolver. The test verifies that the resolver receives port 9443 and returns the expected environment value.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to de71b

The gateway runtime can now receive an injected network-environment resolver for testing while existing callers retain lazy production resolution. No current merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: avoiding the cold gateway dependency load in the test.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/6237-gateway-loader-slice

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

@github-code-quality

github-code-quality Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall line coverage in commit de71bc1 in the codex/6237-gateway-l... branch remains at 96%, unchanged from commit 0df4ecf in the main branch.


Updated September 10, 2026 01:27 UTC

Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
@cjagwani
cjagwani requested review from cv and prekshivyas September 9, 2026 17:36
@cjagwani

cjagwani commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

CI status for latest PR commit 3d701c1: all completed non-CLI checks pass. CLI attempts 1 through 3 failed before dependency installation or tests because apt-get received a Google Chrome repository Hash Sum mismatch. Attempt 3 ran after a 10-minute cooldown and reproduced the same external failure. No code or workflow change was made to mask it; the PR is waiting for repository metadata to settle before another retry.

@cjagwani

cjagwani commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

CI follow-up on latest commit 3d701c1: after the hosted APT metadata settled, retry attempt 4 ran the full CLI suite. Eleven of twelve shards passed. Shard 6 failed only on the current-main plugin cache-seed digest regression, with the same expected/received hashes reproduced on unrelated PR #11319. The focused one-line fix is PR #11315, so I am not duplicating that unrelated generated-metadata change here. The previously failed managed-image MCP discovery retry passed. Once #11315 lands, I will merge current main and rerun the required checks.

Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor finished for commit 5e31b61. Include the Advisor findings in the complete PR feedback collection. Verify and group valid findings before repair.

All previous runs

@cjagwani

cjagwani commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

Automated-review disposition for latest commit 5e31b61:

  • CodeRabbit completed with no actionable comments and minimal merge risk. Its docstring-coverage item is advisory; this two-file internal test seam follows the repository's existing TypeScript style and all required quality/coverage gates pass.
  • PR Review Advisor completed all nine specialists. Eight reported no defect. The reduction specialist suggested removing the injected resolver, but that would restore the measured cold dependency load this PR exists to eliminate (24.69 s wall time and a 15 s timeout on the baseline versus a 2.04 s patched cold median). The dependency object is internal, production callers retain the single existing lazy resolver path, and the other ownership, behavior, security, verification, operability, migration, documentation, and delivery specialists confirmed no defect.
  • No unresolved review threads remain.

No automated finding requires a code change.

@wscurran wscurran added area: ci CI workflows, checks, release automation, or GitHub Actions area: cli Command line interface, flags, terminal UX, or output chore Build, CI, dependency, or tooling maintenance labels Sep 9, 2026
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@cv
cv enabled auto-merge (squash) September 10, 2026 01:26
@cv
cv merged commit 5e5dc8f into main Sep 10, 2026
59 checks passed
@cv
cv deleted the codex/6237-gateway-loader-slice branch September 10, 2026 01:27
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: cli Command line interface, flags, terminal UX, or output chore Build, CI, dependency, or tooling maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants