Repository navigation
Extract attemptGatewayStart helper from startGatewayWithOptions for caller-level testability #5113
Description
Context
PR #5109 retired test/e2e/test-docker-unreachable-gateway-start.sh (originally protecting #2347 — the gateway-start fallback when Docker/Colima is unreachable). The replacement Vitest integration test at src/lib/onboard/gateway-start-failure-integration.test.ts covers everything reachable through already-exported helpers (printDockerDaemonRecovery, handleFinalGatewayStartFailure, reportLegacyGatewayStartResultFailure, classifyGatewayStartFailure) plus a composition test of the call-site sequence, but it leaves three caller-level contracts as it.todo placeholders because they cannot be proven without driving startGatewayWithOptions past its ~200 lines of preamble (gateway-reuse / ssh-keygen / known_hosts / docker-driver-detect).
What's missing
The three documented it.todo contracts in call-site contracts (caller-level coverage gap):
startGateway aborts via pRetry.AbortError without entering health-poll loop on docker-unreachable streamGatewayStart outputstartGateway never invokes openshellstatusorgateway infoafter docker-unreachable streamGatewayStart outputstartGateway forwards dockerUnreachable=true to handleFinalGatewayStartFailure (no doctor logs collection, no destroyGateway cleanup) when streamGatewayStart returns docker-unreachable signature
Proposed fix
Extract the inner pRetry async body of startGatewayWithOptions (lines ~2310–2370 of src/lib/onboard.ts) into an exported helper that takes streamGatewayStart as a DI parameter, e.g.:
export async function attemptGatewayStart(
streamGatewayStartFn: typeof streamGatewayStart,
args: { command: string; env: NodeJS.ProcessEnv; healthPollCount: number; healthPollInterval: number; ... },
emitWaitingForHealth: () => void,
runStatusProbe: () => string,
runGatewayInfoProbe: (named: boolean) => string,
// ... other DI seams
): Promise<{ outcome: "healthy" | "unknown_failure"; dockerUnreachable: boolean }> { /* ... */ }Then startGatewayWithOptions wraps attemptGatewayStart inside its existing try/catch + handleFinalGatewayStartFailure plumbing, and the test drives attemptGatewayStart directly with a mocked streamGatewayStartFn that returns the docker-unreachable signature.
Acceptance
- The three
it.todoentries ingateway-start-failure-integration.test.tsconvert to realit()blocks and assert exactly what they claim. startGatewayWithOptionsbehavior onmainis unchanged (regression-test it the same way you'd test any refactor).
Refs
- PR test(onboard): add helper-level Vitest coverage for docker-unreachable gateway-start abort (#4355) #5109 (the retirement PR; introduced this gap)
- [NemoClaw][macOS][Onboard] nemoclaw onboard does not auto-restart Docker (Colima) when daemon is stopped — hangs indefinitely at gateway health #2347 (original regression the legacy script protected)
- Phase 9: Rebuild, Upgrade, Installer Version, and Runtime Edge Audit Coverage (E2E audit-coverage) #4355 (owning migration issue)
Activity
fix(test): align retiredReason + TODO link with actual coverage shape
revert: defer full retirement of test-docker-unreachable-gateway-star…
test(onboard): add helper-level Vitest coverage for docker-unreachabl…
jyaunches commentedon Jun 10, 2026
Re-scoping after PR #5109 merged: I missed prior art when I filed this issue.
test/onboard.test.ts:357(it("fast-fails gateway start before health polling when Docker is unreachable (#2347)", ...)) already proves two of the three caller-level contracts I listed:"Waiting for gateway health"(covers contract 1)HEALTH POLL REACHEDin stdout, i.e. no openshellstatus/gateway infoprobes after gateway-start failure (covers contract 2)"Cleaning up failed gateway state..."— the only signal that distinguishesdockerUnreachable=trueforwarding from other exit-1 paths throughstartGatewayWithOptions(contract 3 only)Re-scoped goal: rather than the full
attemptGatewayStartextraction, the smallest change that closes the actual remaining gap is to add one assertion to the existingtest/onboard.test.ts:357test:The seam-extraction refactor is still defensible if a future PR has a stronger reason for it (e.g. wanting to test additional
startGatewayWithOptionsbranches without spawning a child process), but it shouldn't be gated on this issue.Follow-up PR #5118 corrects the documentation in
gateway-start-failure-integration.test.tsand the inventory note that landed in #5109.cv commentedon Jun 10, 2026
Cross-linking the broader migration guidance from #5098: #5098 (comment)
For this issue/#5119, the useful policy is narrower than the current inventory machinery: when a legacy E2E script is retired, the PR should show the replacement Vitest coverage or explicit retirement rationale. We should avoid making
legacy-inventory.jsona long-lived progress ledger; it will drift faster than the issues/PRs.test(e2e): retire docker-unreachable gateway script (#5119)