Skip to content

fix(onboard): wait for routed gateway before native restart - #13481

Merged
deepujain merged 1 commit into
mainfrom
fix/13465-routed-gateway-readiness
Oct 19, 2026
Merged

deepujain merged 1 commit into
mainfrom
fix/13465-routed-gateway-readiness

Conversation

@deepujain

@deepujain deepujain commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Outcome

Fresh Model Router onboarding waits for OpenClaw to accept connections before requesting its native gateway restart. A gateway that is still starting can finish within the existing startup window instead of immediately failing step 7/8 with ECONNREFUSED.

Reason

Sandbox creation can finish before the OpenClaw listener starts. Routed setup previously configured and restarted the gateway without waiting; the restart command failed before its own post-restart readiness check could run. Existing setup tests assumed the restart succeeded and missed this ordering gap.

Related issues

Fixes #13465.

Changes

Reuse the bounded native startup check before routed setup restarts the selected gateway. Require positive readiness, revalidate sandbox identity after waiting, and retain native restart failure reporting. Custom-image pairing and ordinary-provider setup keep their existing paths.

Regression tests cover initial connection refusal followed by readiness, the selected gateway and port, deadline exhaustion, late readiness, inconclusive transport, and identity changes.

Verification

  • npx vitest run --project cli src/lib/onboard/openclaw-setup.test.ts src/lib/onboard/machine/final-flow-phases.test.ts src/lib/onboard/machine/final-flow-phases.runtime.test.ts src/lib/onboard/machine/final-flow-composition.test.ts src/lib/onboard/machine/finalization-deps.test.ts --maxWorkers 2: 141 tests passed across five files. The initial regression failed before the fix because setup performed zero readiness probes.
  • npx vitest run --project integration test/automation/pull-requests/growth-guardrails.test.ts: seven growth guardrails passed.
  • NODE_OPTIONS=--max-old-space-size=8192 npm run typecheck:cli and npm run build:cli: passed. Changed-file formatting and lint passed.
  • src/lib/actions/sandbox/gateway-restart.test.ts: 10 passed; 26 failed before reaching their test action because this environment denies the host lifecycle lock write.
  • Not run: Ubuntu 26.04 fresh CPU/GPU Model Router onboarding, resume, and an NVIDIA Endpoints control. The available Docker runtime has less than the required 8 GiB memory.
  • Normal pre-commit, commit-message, and pre-push hooks passed, including repository checks, source-shape and growth guards, and secret scanning.
  • The diff contains no secrets, API keys, or credentials.

Review notes

Decision: Accept this focused bug fix despite the pending triage label. Reason: the reported race remains on current main. Placement: readiness coordination stays in NemoClaw onboarding; OpenClaw owns gateway lifecycle. Accountable maintainer: @deepujain, who supplied this direction for the implementation. Validation plan: the deterministic regression and failure cases above, with the Ubuntu journeys still requiring platform validation.

Self-review of NVIDIA/NemoClaw commit 748fd98 covers the sensitive files src/lib/onboard.ts, src/lib/onboard/openclaw-setup.ts, and src/lib/onboard/openclaw-setup.test.ts. Source inspection and focused tests found no change to pairing, credentials, or native restart ownership. Independent maintainer review remains pending.


Signed-off-by: Deepak Jain [email protected]

Summary by CodeRabbit

  • Bug Fixes
    • Routed OpenClaw setup now waits for the selected gateway to report ready before restarting it. Setup stops if startup times out, readiness cannot be confirmed, or the sandbox changes while startup is being checked, helping prevent restarts against an unavailable or incorrect gateway.

Wait for the selected OpenClaw gateway to accept connections before
restarting it during routed setup. Keep the existing bounded startup
checks and native restart failure handling.

Signed-off-by: Deepak Jain <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/NemoClaw/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: e80871dd-7c03-4cbc-91cf-ef207a3cb8a4
📥 Commits

Reviewing files that changed from the base of the PR and between b01bb7f and 748fd98.

📒 Files selected for processing: 3
  • src/lib/onboard.ts
  • src/lib/onboard/openclaw-setup.test.ts
  • src/lib/onboard/openclaw-setup.ts

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

📝 Walkthrough

Routed OpenClaw setup now waits for gateway startup readiness before restarting the selected native gateway. Setup revalidates sandbox identity around the wait. Tests cover readiness failures, late readiness, identity changes, and gateway-name routing.

Changes: Routed gateway setup

Layer / File(s) Summary
Startup wait and routed restart
src/lib/onboard/openclaw-setup.ts, src/lib/onboard.ts, src/lib/onboard/openclaw-setup.test.ts
Setup requires a gateway name for routed restarts and proceeds only when the startup waiter returns true. It revalidates sandbox identity before and after waiting, then passes the gateway name to the restart operation. Tests cover startup outcomes, identity changes, restart routing, and setup fixtures.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant OpenclawSetup
  participant GatewayStartupWaiter
  participant NativeGateway
  OpenclawSetup->>GatewayStartupWaiter: wait for selected gateway startup
  GatewayStartupWaiter-->>OpenclawSetup: readiness result
  OpenclawSetup->>NativeGateway: restart selected gateway when ready
Loading

Suggested reviewers: rsliter

Merge Risk: ⚪ Minimal · up to 748fd

The routed onboarding startup sequence is ready to merge after normal checks; no actionable issue remains identified.

Pre-merge checks: Passed 4 · Failed 1

Failed 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 1 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed 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: waiting for the routed gateway before performing the native restart.
Linked Issues check Passed Issue #13465 requires fresh routed Model Router onboarding to avoid the startup race before the native gateway restart. src/lib/onboard.ts wires waitForStartedOpenclawGatewayProcess into setup. `s…
Out of Scope Changes check Passed The changes stay within issue #13465. src/lib/onboard.ts only wires the existing startup wait operation. src/lib/onboard/openclaw-setup.ts adds the routed gateway wait and preserves separate paths…
Full details: Linked Issues check

Explanation

Issue #13465 requires fresh routed Model Router onboarding to avoid the startup race before the native gateway restart. src/lib/onboard.ts wires waitForStartedOpenclawGatewayProcess into setup. src/lib/onboard/openclaw-setup.ts waits after configuration, requires readiness to be exactly true, revalidates sandbox identity before and after the wait, then passes the selected gateway name to the native restart. Existing restart failure reporting remains active. Tests cover refusal followed by readiness, the selected gateway and port, deadline exhaustion, inconclusive transport, late readiness, and identity changes.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #13465. src/lib/onboard.ts only wires the existing startup wait operation. src/lib/onboard/openclaw-setup.ts adds the routed gateway wait and preserves separate paths for custom-image pairing and ordinary providers. The added tests verify the affected setup behavior and its failure cases. No unrelated production behavior is demonstrated.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-code-quality

github-code-quality Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage/plugin

main 63002cd fix/13465-routed-gat... 748fd98 +/-
96% 97% +1%
View coverage of the 10 most impacted files.
File main 63002cd fix/13465-routed-gat... 748fd98 +/-
nemoclaw/src/onboard/config.ts 98% 96% -2%
nemoclaw/src/index.ts 94% 93% -1%
nemoclaw/src/bl...print/runner.ts 95% 95% 0%
nemoclaw/src/bl...ime-identity.ts 97% 97% 0%
nemoclaw/src/bl...t-management.ts 100% 100% 0%
nemoclaw/src/co.../config-show.ts 100% 100% 0%
nemoclaw/src/commands/slash.ts 100% 100% 0%
nemoclaw/src/ru...time-context.ts 100% 100% 0%
nemoclaw/src/sh...er-boundary.cts 100% 100% 0%
nemoclaw/src/on...native-route.ts 0% 100% +100%

TypeScript / code-coverage/cli

main 63002cd fix/13465-routed-gat... 748fd98 +/-
84% 86% +2%
View coverage of the 10 most impacted files.
File main 63002cd fix/13465-routed-gat... 748fd98 +/-
src/lib/onboard.ts 62% 50% -12%
src/lib/actions...ess-recovery.ts 65% 81% +16%
src/lib/state/l...diness-lease.ts 66% 83% +17%
src/lib/inferen...ollama/proxy.ts 41% 61% +20%
src/lib/onboard.../application.ts 55% 84% +29%
src/lib/domain/...y/dimensions.ts 0% 71% +71%
src/lib/inferen...er/lifecycle.ts 0% 72% +72%
src/lib/actions...ry/operation.ts 0% 76% +76%
src/lib/actions...try/snapshot.ts 0% 78% +78%
src/lib/inferen...ovider/index.ts 0% 88% +88%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 19, 2026 16:24 UTC

@github-actions

Copy link
Copy Markdown
Contributor

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

Request review only when Require no Advisor blockers is green.

All previous runs

@deepujain
deepujain marked this pull request as ready for review October 19, 2026 20:18
@deepujain
deepujain requested review from ericksoa and rsliter October 19, 2026 22:15

@rsliter rsliter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed commit 748fd98 against base b01bb7f. No blocking defect found.

The accepted issue scope matches this focused fix. The routed path now reuses the bounded native-gateway readiness check before restart, fails closed on false or inconclusive readiness, revalidates sandbox identity around the wait, and restarts the selected named gateway. Regression coverage exercises refusal followed by readiness, timeout, inconclusive and late results, identity drift, restart failure, and unaffected provider paths. Required checks pass.

Security review: PASS across secrets, input handling, authorization, dependencies, error handling, cryptography and data handling, configuration, testing, and system-security boundaries.

PR Review Advisor recommendation for this exact commit: model-router-provider-routed-inference. Result: passed on 748fd98 in https://github.com/NVIDIA/NemoClaw/actions/runs/39319813417 (job https://github.com/NVIDIA/NemoClaw/actions/runs/39319813417/job/118292797796). The retained evidence manifest records the same candidate SHA and a successful job.

@deepujain
deepujain merged commit d087dbc into main Oct 19, 2026
@deepujain
deepujain deleted the fix/13465-routed-gateway-readiness branch October 19, 2026 23:04
rsliter added a commit that referenced this pull request Oct 20, 2026
## Release target

This maintainer-owned documentation patch prepares `v0.0.136` from
changes merged after `v0.0.135` through
`6d76a7e9aa5aca641df360670aa00394411c302a` on `main`. The signed merge
commit `372e7aaccf863736b8bb6ba6cd17fdc235c7c261` records that boundary.
The PR diff against current `main` changes documentation only.

The canonical release entry is `docs/changelog/2026-10-19.mdx`. This
refresh includes the six PRs merged after the prior docs cutoff: hosted
Super VL image inputs (#13371), routed OpenClaw gateway startup
(#13481), ordinary operation telemetry (#13494), and the internal fixes
#13486, #13498, and #13500. The owning docs now describe the hosted
model, routed startup, TEST receiver, and telemetry opt-out before
direct install commands and in the generated starter prompt. The PR also
carries the previously reviewed Deep Agents, sandbox recovery, and Spark
Super VL documentation.

## Local verification

- `npm run docs`: passed, 125 routes, zero errors, two existing
warnings.
- `npm run validate:pr`: passed, including repository checks, commit
message, builds, and pre-push checks.
- Independent documentation review of the exact signed commit against
`origin/main`: no blockers.
- Changed paths against `main`: `docs/**` only. No secrets, API keys, or
credentials added.
- The hosted Super VL scope decision is recorded on PR #13371, the local
Spark scope and physical smoke on PR #13357, and ordinary telemetry
scope on PR #13494.

The release plan and tag remain gated on this PR merging into `main`,
candidate image and E2E evidence, and the maintainer's explicit tag
confirmation.

Follow [Post-Merge Documentation
Catch-Up](https://github.com/NVIDIA/NemoClaw/blob/main/docs/AUTOMATION.md#post-merge-documentation-catch-up)
for the managed workflow and release cutoff.

Signed-off-by: Rebecca Sliter <[email protected]>

---------

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: Rebecca Sliter <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Rebecca Sliter <[email protected]>
@wscurran wscurran added area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior labels Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior

Projects

None yet

3 participants