Skip to content

feat(cli): converge readiness checks - #8738

Merged
cv merged 16 commits into
mainfrom
codex/readiness-convergence-7411
Aug 10, 2026
Merged

feat(cli): converge readiness checks#8738
cv merged 16 commits into
mainfrom
codex/readiness-convergence-7411

Conversation

@jyaunches

@jyaunches jyaunches commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Converges host, gateway, onboarding, resume, and rebuild readiness on one canonical report and admission policy. Blocking findings now stop lifecycle effects before credentials, images, gateways, policies, or sandboxes change, while public diagnostics remain observation-only and credential-free.

Related Issue

Fixes #7411

Changes

  • Share stable host and gateway observations, capabilities, findings, evidence, provenance, and exit codes between host probe and onboarding.
  • Resolve one gateway lifecycle authority, validate externally supervised gateways without a standalone fallback, and revalidate live gateway state before resume or rebuild effects.
  • Run readiness subprocesses with a minimal credential-free environment and fail closed on unsupported runtimes, invalid Docker endpoints, missing Jetson NVIDIA runtime support, inconclusive identity, and stale or conflicting gateway state.
  • Preserve current-main platform entries while publishing the complete GPU readiness state contract and the new command and workflow behavior.
  • Route OpenShell resolution through a leaf readiness seam to preserve the zero-cycle source architecture budget; the source-architecture check protects this requirement.

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:
  • 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 read-only code audit found no blocker in readiness admission, lifecycle authority, credential-free subprocesses, or rebuild/resume seams; focused security and lifecycle regressions pass.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Documentation Writer Review

  • Documentation writer subagent reviewed the completed changes
  • Result: docs-updated
  • Evidence: docs/about/how-it-works.mdx, docs/get-started/windows-preparation.mdx, docs/inference/choose-inference-provider.mdx, docs/reference/commands.mdx, docs/reference/platform-support.mdx, docs/reference/system-readiness.mdx
  • Agent: Codex Desktop

DGX Station Hardware Evidence

  • Tested on DGX Station
  • Tested commit:
  • Station profile/scenario:
  • Result:
  • Supporting evidence:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run validate:pr passed after refreshing origin/main when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: focused readiness/onboarding tests passed 284 cases and the single startup-timeout file passed 8/8 on isolated rerun; split preflight/readiness 167/167; reviewer-adjacent gateway/readiness 50/50; post-extraction preflight/gateway tests 159/159; guardrail-linearized fixtures 141/141; architecture/lifecycle integration 48/48; automated-review readiness fixes 81/81; final review-finding closure passed focused CLI 97/97, integration 3/3, installer 94/94, and process-scanning 14/14 with a host-appropriate timeout; managed-image preflight cleanup contract 18/18; MCP policy stress suite 39/39 with an explicit coverage-load budget; rebuild credential preflight process contracts 2/2; Docker runtime 14/14; hermetic preflight 129/129 with four real-listener cases skipped where the earlier sandbox denied listeners.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result: aggregate npm test was attempted locally, but shared macOS parallel temp ownership and Oclif startup contention caused unrelated cross-suite failures; affected [Readiness 5/5] Converge onboarding, gateway diagnostics, and doctor on readiness checks #7411 lanes pass serially and CI will run the aggregate projects in their normal environment.
  • 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) — command/result: passed with 0 errors and 2 Fern warnings.
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Julie Yaunches jyaunches@nvidia.com

@jyaunches jyaunches self-assigned this Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review 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
📝 Walkthrough

Walkthrough

This PR converges host, gateway, onboarding, and rebuild flows on system-readiness reports. It adds read-only gateway probing, readiness admission, persisted gateway-authority checkpoints, stricter rebuild validation, and updated advisory and documentation contracts.

Changes

System readiness and onboarding

Layer / File(s) Summary
System readiness and gateway projection
src/lib/readiness/*
Adds composite host and gateway reports, admission checks, stale-data handling, sanitized evidence, isolated probe environments, and read-only gateway observation.
Readiness-gated onboarding
src/lib/onboard/fatal-runtime-preflight.ts, src/lib/onboard/machine/*, src/lib/onboard/preflight.ts
Replaces direct runtime and CDI gates with readiness admission, refreshes live facts, and defers effectful checks until readiness passes.
Gateway ownership and service validation
src/lib/onboard/gateway-host-runtime.ts, src/lib/onboard/docker-driver-gateway-*.ts, src/lib/onboard.ts
Adds packaged-owner adoption, process identity checks, credential-free probes, external supervision handling, and gateway lifecycle authority wiring.
Rebuild authority handoff
src/lib/actions/sandbox/rebuild-*.ts
Pins the target gateway during readiness, persists checkpointed authority, rejects authority drift, and validates journal state before recreation.
Host probe and contracts
src/commands/host/probe.ts, src/lib/domain/docker-host.ts, src/lib/inference/nim.ts
Updates host:probe to report system readiness and adds structured Docker observations and injectable GPU command transport.
Advisories and documentation
src/lib/advisories/*, docs/*, ci/*, scripts/install.sh
Registers host advisories, removes the unsupported-runtime warning path, updates readiness terminology, and documents gateway-aware readiness behavior.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#7246: Extends gateway lifecycle-authority work across readiness, onboarding, checkpoint, and recovery paths.
  • NVIDIA/NemoClaw#7319: Shares gateway service ownership, lifecycle validation, and readiness integration.
  • NVIDIA/NemoClaw#8682: Shares sandbox gateway recovery, readiness gating, and authority handling.

Suggested labels: area: onboarding, area: architecture, feature

Suggested reviewers: apurvvkumaria, cv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.13% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement the linked issue objectives, including canonical readiness reporting, advisory integration, gateway authority, fail-closed admission, and resume validation.
Out of Scope Changes check ✅ Passed The code, tests, documentation, and configuration changes support the linked readiness convergence objectives without unrelated scope.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: converging readiness checks across the CLI and lifecycle flows.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/readiness-convergence-7411

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

@github-code-quality

github-code-quality Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit 89af2e0 in the codex/readiness-conv... branch remains at 96%, unchanged from commit d097a22 in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit 89af2e0 in the codex/readiness-conv... branch remains at 82%, unchanged from commit d097a22 in the main branch.

Show a code coverage summary of the most impacted files.
File main d097a22 codex/readiness-conv... 89af2e0 +/-
src/lib/policy/...ne-exclusion.ts 92% 87% -5%
src/lib/adapter...ateway-drift.ts 51% 56% +5%
src/lib/onboard...pu-preflight.ts 90% 95% +5%
src/lib/onboard...me-preflight.ts 75% 98% +23%
src/lib/readine...y-production.ts 0% 51% +51%
src/lib/onboard...ay-authority.ts 0% 73% +73%
src/lib/readiness/gateway.ts 0% 89% +89%
src/lib/readiness/probe-env.ts 0% 94% +94%
src/lib/readine...rd-admission.ts 0% 100% +100%
src/lib/readiness/system.ts 0% 100% +100%

Updated August 10, 2026 17:10 UTC

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / low confidence
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions
Status: PR review advisor failed: PR review advisor SDK execution failed: session: scope-risk-map-analysis omitted required analysis; turn: scope-risk-map-analysis: scope-risk-map-analysis omitted required analysis

Model lanes

  • GPT-5.6 Terra (primary): Failed
  • Nemotron 3 Ultra (second opinion): Failed

Second-opinion terminology and E2E selections are advisory. Live E2E does not run automatically for pull requests.

E2E guidance

Advisory only. A maintainer can dispatch the default E2E suite against this exact revision.

Recommended E2E: cloud-inference, cloud-onboard, managed-image-multiarch-startup, managed-image-protected-runtime, security-posture, inference-routing, network-policy, onboard-repair, onboard-resume, rebuild-openclaw, state-backup-restore

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

Comment thread src/lib/onboard/fatal-runtime-preflight.ts Fixed
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
Comment thread src/lib/onboard/fatal-runtime-preflight.ts Fixed
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 19

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/onboard/gateway-host-runtime-https.test.ts (1)

82-101: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Restore OPENSHELL_GATEWAY_AUTH_TOKEN after this test.

Line 83 directly mutates process.env.OPENSHELL_GATEWAY_AUTH_TOKEN. The test restores only OPENSHELL_LOCAL_TLS_DIR. A later test can inherit this token.

Capture and restore the original token, or use a test-scoped environment stub.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/gateway-host-runtime-https.test.ts` around lines 82 - 101,
Restore the environment mutation in the gateway attachment test by capturing the
original OPENSHELL_GATEWAY_AUTH_TOKEN before assigning it and restoring that
value during cleanup, alongside OPENSHELL_LOCAL_TLS_DIR. Keep the existing probe
assertions unchanged and ensure the token cannot leak into later tests.

Source: Coding guidelines

🧹 Nitpick comments (10)
src/lib/readiness/gateway-production.ts (2)

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

Read the gateway binary override from the probe environment.

resolveTrustedGatewayBinary reads process.env.NEMOCLAW_OPENSHELL_GATEWAY_BIN directly. Every other resolution in this module takes the sanitized probeEnv that buildGatewayReadinessProbeEnv produced, including resolveTrustedOpenshellBinary. Accept the environment as a parameter so one environment governs the whole readiness probe and tests can control the override without mutating process.env.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/readiness/gateway-production.ts` around lines 173 - 182, Update
resolveTrustedGatewayBinary to accept the sanitized probeEnv environment and
read NEMOCLAW_OPENSHELL_GATEWAY_BIN from it instead of process.env. Pass the
same probeEnv produced by buildGatewayReadinessProbeEnv through the readiness
probe call chain, matching resolveTrustedOpenshellBinary, so tests can control
the override without mutating process.env.

342-366: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Reuse the OpenShell status outputs instead of probing three more subprocesses.

observeReuseState runs openshell status, openshell gateway info -g <name>, and openshell gateway info. inspectLegacyCluster runs the same three commands again in the same observeManagedGateway pass, and each command carries the full OPENSHELL_PROBE_TIMEOUT_MS budget. On a slow or wedged OpenShell CLI the readiness probe pays that cost twice. Pass the already captured outputs from observeReuseState into inspectLegacyCluster, and keep only the Docker inspections in the legacy path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/readiness/gateway-production.ts` around lines 342 - 366, Update
observeManagedGateway and inspectLegacyCluster to accept and reuse the openshell
status, named gateway info, and active gateway info captured by
observeReuseState. Remove the duplicate captureReadonly subprocess calls from
inspectLegacyCluster, while preserving its existing health and endpoint-binding
checks; retain only the Docker inspections in the legacy path.
src/lib/onboard/gateway-authority-checkpoint.test.ts (1)

104-127: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the unbound-authority rejection.

adoptPackagedGatewayAuthorityAfterTrustedInstall throws "Trusted gateway installation requires a previously bound gateway authority." when the checkpoint decision is not selected. That fail-closed branch has no test. Add a case that calls the function on a fresh session without a prior bindGatewayAuthorityToCheckpoint call, and assert both the thrown message and that session.checkpoint stays unchanged.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/gateway-authority-checkpoint.test.ts` around lines 104 - 127,
Add a test alongside the existing trusted-install cases that creates a fresh
session without calling bindGatewayAuthorityToCheckpoint, snapshots
session.checkpoint, and invokes
adoptPackagedGatewayAuthorityAfterTrustedInstall. Assert it throws the message
“Trusted gateway installation requires a previously bound gateway authority.”
and that the checkpoint remains equal to the snapshot.
src/lib/adapters/openshell/gateway-drift.ts (1)

433-442: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align the installed-version dependency semantics across the three observers.

Line 258 and line 440 now call the injected getter whenever it exists, so an injected null stays null. Line 434 still uses deps.getInstalledOpenshellVersion?.() ?? getInstalledOpenshellVersionOrNull(...), so an injected getter that returns null silently falls back to the production probe. A caller that injects all three getters therefore gets probe execution in getGatewayHostProcessDrift only. Make the resolution rule identical in the three functions.

♻️ Proposed alignment
   const expectedVersion =
-    deps.getInstalledOpenshellVersion?.() ??
-    getInstalledOpenshellVersionOrNull({ timeout: timeoutMs });
+    typeof deps.getInstalledOpenshellVersion === "function"
+      ? deps.getInstalledOpenshellVersion()
+      : getInstalledOpenshellVersionOrNull({ timeout: timeoutMs });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/adapters/openshell/gateway-drift.ts` around lines 433 - 442, Update
the installed-version resolution in getGatewayHostProcessDrift to match the
other observers: when deps.getInstalledOpenshellVersion exists, use its result
directly, including null, and only call getInstalledOpenshellVersionOrNull when
the getter is absent. Preserve the existing expectedVersion check and runtime
resolution behavior.
src/lib/readiness/onboard-admission.ts (1)

268-299: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the shared blocking-finding classification loop.

Lines 275-293 repeat the loop at Lines 256-261. Both iterate findings, skip non-blocking entries, call canWaiveFinding, and split the IDs into waivedFindingIds and findingIds. The only difference is the options value.

A shared helper keeps one implementation of the waiver semantics, so a future waiver change cannot apply to one entry point and miss the other.

♻️ Proposed refactor
+function classifyBlockingFindings(
+  report: OnboardReadinessInput,
+  capabilities: ReadonlyMap<string, ReadinessCapability>,
+  options: Readonly<OnboardReadinessAdmissionOptions>,
+  managedGateway: boolean,
+): { findingIds: string[]; waivedFindingIds: string[] } {
+  const findingIds: string[] = [];
+  const waivedFindingIds: string[] = [];
+  for (const finding of report.findings) {
+    if (!isBlocking(finding)) continue;
+    if (canWaiveFinding(finding, capabilities, options, managedGateway)) {
+      waivedFindingIds.push(finding.id);
+    } else findingIds.push(finding.id);
+  }
+  return { findingIds, waivedFindingIds };
+}
+
+const GATEWAY_CHECKPOINT_OPTIONS: OnboardReadinessAdmissionOptions = {
+  explicitlyOptedOutGpuPassthrough: false,
+  allowUnsupportedRuntime: false,
+  allowStorageRemediation: false,
+};
 export function evaluateOnboardGatewayReadinessAdmission(
   report: OnboardReadinessInput,
 ): OnboardReadinessAdmissionDecision {
   const capabilities = new Map(report.capabilities.map((entry) => [entry.id, entry]));
-  const managedGateway = hasManagedGateway(report);
-  const waivedFindingIds: string[] = [];
-  const findingIds: string[] = [];
-  for (const finding of report.findings) {
-    if (!isBlocking(finding)) continue;
-    if (
-      canWaiveFinding(
-        finding,
-        capabilities,
-        {
-          explicitlyOptedOutGpuPassthrough: false,
-          allowUnsupportedRuntime: false,
-          allowStorageRemediation: false,
-        },
-        managedGateway,
-      )
-    ) {
-      waivedFindingIds.push(finding.id);
-    } else {
-      findingIds.push(finding.id);
-    }
-  }
+  const { findingIds, waivedFindingIds } = classifyBlockingFindings(
+    report,
+    capabilities,
+    GATEWAY_CHECKPOINT_OPTIONS,
+    hasManagedGateway(report),
+  );
   const capabilityIds: string[] = [];
   for (const id of GATEWAY_REQUIRED_CAPABILITIES) {
     addUnknownCapability(capabilityIds, capabilities, id);
   }
   return decisionFor(findingIds, capabilityIds, waivedFindingIds);
 }

Apply the same helper inside evaluateOnboardReadinessAdmission.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/readiness/onboard-admission.ts` around lines 268 - 299, Extract the
repeated blocking-finding classification logic into a shared helper that
iterates findings, skips non-blocking entries, calls canWaiveFinding with
supplied options, and returns waivedFindingIds and findingIds. Update both
evaluateOnboardReadinessAdmission and evaluateOnboardGatewayReadinessAdmission
to use this helper, passing their respective waiver options while preserving the
existing managedGateway behavior.
src/lib/readiness/host.ts (1)

103-112: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Convert adaptHostAssessment to an options object.

The function now takes eight positional parameters. Six are optional and adjacent: hostGpuPlatform, nvidiaGpuCount, nvidiaDriverVersion, platformIdentity, wslDockerDesktopGpuProofPassed, plus the new hasNvidiaGpu. The single call site at Lines 196-214 passes nested ternaries positionally, so a future insertion or reorder is easy to get wrong and hard to catch in review.

A named-field argument removes the ordering dependency and makes the call site readable.

♻️ Proposed refactor sketch
+interface AdaptHostAssessmentInput {
+  architecture: string;
+  hasNvidiaGpu: boolean;
+  hostGpuPlatform?: NvidiaPlatform;
+  nvidiaGpuCount?: number;
+  nvidiaDriverVersion?: string;
+  platformIdentity?: PlatformIdentity;
+  wslDockerDesktopGpuProofPassed?: boolean;
+}
+
 function adaptHostAssessment(
   host: Readonly<HostAssessment>,
-  architecture: string,
-  hasNvidiaGpu: boolean,
-  hostGpuPlatform?: NvidiaPlatform,
-  nvidiaGpuCount?: number,
-  nvidiaDriverVersion?: string,
-  platformIdentity?: PlatformIdentity,
-  wslDockerDesktopGpuProofPassed?: boolean,
+  input: Readonly<AdaptHostAssessmentInput>,
 ): HostObservations {

Also applies to: 196-214

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/readiness/host.ts` around lines 103 - 112, Refactor
adaptHostAssessment to accept a single options object containing host,
architecture, hasNvidiaGpu, and the existing optional GPU/platform fields.
Update its sole call site to pass named properties instead of positional
arguments, preserving the current values and nested-ternary behavior.
src/lib/onboard/runtime-control-flow.ts (1)

122-125: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the transition logic shared by the projection and the commit.

Lines 122-125 build projectedSession, and lines 139-142 repeat the same two steps inside the updateSession mutator. Re-reading current inside the mutator is correct, so the duplication is intentional in structure but not in logic.

The risk is drift. If one copy gains a step, plan.session no longer predicts what commit() persists, and a caller that renders plan.session shows state that is never written. Extract one local function and call it from both places.

♻️ Proposed extraction
+  const applyTransition = (candidate: Session): Session => {
+    const transitioned = resumeAgentChanged
+      ? deps.clearAgentScopedResumeState(candidate, selectedAgentName)
+      : candidate;
+    return updateSessionAgent(transitioned, input.selectedAgentName, deps);
+  };
   const originalSession = structuredClone(input.session);
-  let projectedSession = structuredClone(input.session);
-  if (resumeAgentChanged) {
-    projectedSession = deps.clearAgentScopedResumeState(projectedSession, selectedAgentName);
-  }
-  projectedSession = updateSessionAgent(projectedSession, input.selectedAgentName, deps);
+  const projectedSession = applyTransition(structuredClone(input.session));
   let committed: Promise<Session> | null = null;
-        return deps.updateSession((current) => {
-          const transitioned = resumeAgentChanged
-            ? deps.clearAgentScopedResumeState(current, selectedAgentName)
-            : current;
-          return updateSessionAgent(transitioned, input.selectedAgentName, deps);
-        });
+        return deps.updateSession(applyTransition);

Also applies to: 138-143

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/runtime-control-flow.ts` around lines 122 - 125, Extract the
shared transition steps from the projection and commit paths into one local
helper, covering the resume-state clearing and updateSessionAgent operations.
Use this helper to build projectedSession and inside the updateSession mutator,
passing the mutator’s current session as its input so both plan.session and
committed state apply identical logic.
src/lib/onboard/fatal-runtime-preflight.ts (1)

336-394: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the repeated refresh-admit-compose block.

Lines 342-355 and 384-394 are the same sequence: refresh the gateway projection, admit the gateway, recompute managedGatewayReadiness, compose the composite report, and admit the composite report with an identical options object. The block also reassigns four let bindings across about 50 lines.

The behavior is correct today. The risk is drift: this is a security gate, and a future change applied to only one copy would silently weaken the other. Extract one helper and call it at both points.

♻️ Sketch of the extraction
+async function admitCompositeReadiness(
+  gateway: GatewayReadinessProjection,
+  result: FatalRuntimePreflightResult,
+  options: FatalRuntimePreflightOptions,
+  context: ReadinessGatedRuntimePreflightContext,
+  exitProcess: (code: number) => never,
+): Promise<{
+  gatewayReadiness: GatewayReadinessProjection;
+  managed: boolean;
+  readinessReport: SystemReadinessReport;
+}> {
+  const gatewayReadiness = refreshGatewayReadinessProjection(gateway);
+  assertOnboardGatewayReadiness(gatewayReadiness, exitProcess);
+  const managed = isManagedGatewayReadiness(gatewayReadiness);
+  const readinessReport = composeSystemReadinessReport(result.readinessReport, gatewayReadiness);
+  assertOnboardSystemReadiness(readinessReport, result.host, {
+    explicitlyOptedOutGpuPassthrough:
+      result.sandboxGpuConfig.mode === "0" || options.optedOutGpuPassthrough === true,
+    resuming: context.resuming,
+    allowStorageRemediation: managed,
+    exitProcess,
+  });
+  return { gatewayReadiness, managed, readinessReport };
+}

As per coding guidelines: "Keep function complexity low, follow the Biome configuration".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/fatal-runtime-preflight.ts` around lines 336 - 394, Extract
the repeated gateway and system readiness admission sequence into a helper near
the existing onboarding readiness utilities, accepting the current gateway
readiness, refreshed host result, options, context, and exitProcess dependencies
and returning the updated gateway readiness, managedGatewayReadiness, and
readinessReport values. Replace both post-refresh blocks in the surrounding
preflight flow with calls to this helper, preserving the existing admission
order and identical options, and keep the runtime GPU proof flow’s additional
refresh between those calls unchanged.
src/lib/onboard/openshell-install.ts (1)

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

Document when afterSuccessfulInstall runs.

The callback fires after every version, messaging-feature, and maximum-version gate has passed, not immediately after installOpenshell() returns. The option name alone does not convey that ordering, and the ordering matters for a reconciliation callback. Add a short doc comment on the option.

♻️ Proposed refactor to document the callback timing
 export function ensureOpenshellForOnboard(
   deps: OpenShellInstallDeps,
-  options: { afterSuccessfulInstall?(): void } = {},
+  options: {
+    /**
+     * Runs after an install or upgrade succeeded and after every version and
+     * feature gate passed. Does not run when no install was needed.
+     */
+    afterSuccessfulInstall?(): void;
+  } = {},
 ): OpenShellInstallResult {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/openshell-install.ts` at line 292, Add a concise
documentation comment to the option defining afterSuccessfulInstall, stating
that it runs only after installOpenshell completes and all version,
messaging-feature, and maximum-version gates pass. Keep the callback invocation
in the existing installed-success path unchanged.
src/lib/onboard/machine/handlers/preflight.ts (1)

174-201: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Derive the second explicitlyOptedOutGpuPassthrough from the refreshed config.

Line 175 computes explicitlyOptedOutGpuPassthrough from resumeSandboxGpuConfig.mode === "0". Line 196 hardcodes false after line 188 recomputes the config from the fresh detectGpu() result. The two admissions therefore derive the same flag differently.

The hardcoded value is correct while mode === "0" follows only from an explicit disable flag or env override. If resolveSandboxGpuConfig later resolves the "auto" mode to "0" from a detection outcome, the second admission reports the wrong intent. Use the same expression in both places.

The resolve, gateway-admission, and host-admission triplet also repeats in both passes. A small local helper would keep the two admissions aligned by construction.

♻️ Proposed refactor to align both admissions
       await deps.assertGatewayReadiness();
       const wslDockerDesktopGpuProofPassed = resolvedWslDockerDesktopGpuProof(gpu);
       deps.assertOnboardHostReadiness(resumeHost, gpu, {
-        explicitlyOptedOutGpuPassthrough: false,
+        explicitlyOptedOutGpuPassthrough: resumeSandboxGpuConfig.mode === "0",
         observedAt: hostObservedAt,
         now,
         ...(wslDockerDesktopGpuProofPassed === undefined ? {} : { wslDockerDesktopGpuProofPassed }),
         resuming: true,
       });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/machine/handlers/preflight.ts` around lines 174 - 201, Update
the second deps.assertOnboardHostReadiness call in the resume flow to derive
explicitlyOptedOutGpuPassthrough from the refreshed resumeSandboxGpuConfig using
the same expression as the first admission, rather than hardcoding false. Keep
the refreshed resolve, gateway-readiness, and host-admission sequence aligned
with the initial pass; a small local helper may encapsulate the repeated
admission logic if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/install.sh`:
- Around line 3045-3050: Update the installer gate around assessHost and
planHostAdvisories to use the canonical readiness report and admission policy
for its exit status. Stop deriving blocking status from blockingActions or
remediation actions, and ensure unsupported runtimes are rejected consistently
with the readiness contract while preserving the existing successful path.

In `@src/lib/domain/docker-host.ts`:
- Around line 28-38: Update the Docker plain-text response parsing around
lowered and reachable to fail closed unless the text is a bare version token or
matches the Server Version format. Preserve acceptance of the existing “Podman
Engine” compatibility fixture, while treating permission and HTTP error messages
as unreachable. Add regression tests covering both error cases and the accepted
output forms.

In `@src/lib/onboard/docker-cdi.ts`:
- Around line 312-318: Update the docker CDI directory handling around
reportedDockerCdiSpecDirs and dockerCdiSpecDirs so the default-directory
fallback is used only when CDI support is confirmed. Preserve an unknown or
unsupported CDI state instead of treating an empty CDISpecDirs response as
supported, and ensure missing-spec findings do not recommend CDI generation for
daemons without confirmed CDI support.

In `@src/lib/onboard/docker-driver-gateway-service.ts`:
- Around line 637-641: Update gateway reuse to call the full trusted service
identity API instead of getTrustedActiveOpenShellGatewayUserServicePid, and
require identity.executablePath to be non-null before accepting a matching
listener PID. Remove the PID-only wrapper and its associated tests, preserving
executable validation for Homebrew and systemd paths.

In `@src/lib/onboard/fatal-runtime-preflight.test.ts`:
- Around line 253-256: Update the second assertOnboardHostReadiness test case to
store its exitProcess mock in a named variable, pass that mock into the call
with explicitlyOptedOutGpuPassthrough enabled, and assert the mock was not
called afterward.

In `@src/lib/onboard/gateway-host-runtime.ts`:
- Around line 183-208: Extract the shared trusted-install transition predicate
near sameGatewayOwner and use it in both adoption functions. In
src/lib/onboard/gateway-host-runtime.ts lines 183-208, replace the inline
transition checks in adoptPackagedGatewayOwnerAfterTrustedInstall; in
src/lib/onboard/gateway-authority-checkpoint.ts lines 74-107, replace the
corresponding checks in adoptPackagedGatewayAuthorityAfterTrustedInstall while
preserving the checkpoint-specific error text. Ensure the predicate captures the
complete permitted transition, including the checkpoint’s packaged-service
source assertion.
- Around line 199-203: Use the same “rerun onboarding” spelling in the Error
message constructed by the gateway authority validation flow, matching the
existing wording in the nearby onboarding message and leaving the rest of the
message unchanged.

In `@src/lib/onboard/machine/handlers/preflight.test.ts`:
- Around line 377-402: Retitle the test to describe that cached resume passes
the host observation timestamp to readiness and stops subsequent checks when
readiness rejects. In the assertOnboardHostReadiness mock, explicitly assert
that options.observedAt is present before parsing it, while preserving the
existing stale-age rejection and detectGpu/bridge non-invocation assertions.

In `@src/lib/onboard/preflight.ts`:
- Around line 758-766: Update the installer’s CDI repair import sources so
getNvidiaCdiSpecPath and isWslDockerDesktopRuntime resolve from their current
modules, or add compatibility re-exports from preflight.js. Ensure
scripts/install.sh can invoke CDI repair without its catch silently skipping the
operation.

In `@src/lib/onboard/runtime-control-flow.ts`:
- Around line 102-112: Add a test covering the public onboarding entrypoint that
invokes the branding flow, mock the onboarding layers as needed, and assert it
reaches planSelectedAgentTransition. Ensure the test verifies the public
boundary no longer depends on applySelectedAgentTransition and preserves the
branding call order after planning.

In `@src/lib/readiness/effects.test.ts`:
- Around line 138-139: Remove the unused startGateway and selectGateway spies
and any assertions against them from the createSystemReadinessReport test setup.
Keep the probeAttachment throwing stub and the observeManagedGateway assertions
that verify reachable gateway behavior.

In `@src/lib/readiness/gateway-production.test.ts`:
- Around line 331-335: Move the getTraceCollector() null assertion in the
probeAttachment test to immediately after await
deps.probeAttachment(externalOwner(gatewayPort)) and before
vi.stubEnv(TRACE_FILE_ENV, ""). Keep the subsequent environment reset and
fs.existsSync(tracePath) assertion unchanged.

In `@src/lib/readiness/gateway-production.ts`:
- Around line 577-585: In observePackagedServiceGatewayBinary, move the
executableAfter and generationAfter reads to after the
getTrustedActiveOpenShellGatewayUserServiceIdentity serviceAfter probe. Keep
executableBefore before the probe, so gatewayExecutableSamplesMatchTrustedBinary
compares samples that bracket the complete identity observation.

In `@src/lib/readiness/host.ts`:
- Around line 466-472: Update the capability logic around
host.gpu.container_toolkit_available to distinguish Jetson runtime applicability
from Docker evidence usability: return the Jetson runtime state when the check
is evaluable, return unknown when Jetson applies but dockerEvidenceUsable is
false, and retain the existing non-Jetson containerToolkitApplies behavior.
Apply the same evaluability guard to the related observation and
host.gpu.nvidia_runtime_missing finding so an unevaluable Jetson runtime reports
unknown without emitting an absent finding.

In `@src/lib/readiness/openshell-resolver.ts`:
- Line 4: Update the resolveOpenshell re-export in the readiness resolver module
to include the .js extension, and apply the same extension to the relative
re-export specifiers in the readiness system module. Preserve the existing
exports and paths otherwise.

In `@src/lib/readiness/platform-qualification.ts`:
- Around line 511-521: Align the severity of WSL findings with admission
behavior in the platform qualification flow: either mark reachable native Docker
and inconclusive WSL runtime findings as blocking, or explicitly exclude those
warning states from the host.platform.unsupported fallback so admission remains
advisory. Preserve other unsupported-platform blocking behavior and add coverage
for the selected path.

In `@src/lib/readiness/probe-env.ts`:
- Line 80: Validate controls.gatewayName before assigning it to
OPENSHELL_GATEWAY, using the same NUL, carriage-return, and line-feed rejection
already applied to localTlsDir. Preserve the existing conditional assignment
while returning the established clear readiness failure for invalid values
instead of passing them to the environment.
- Around line 112-118: Update the spawnSync invocation in the readiness probe
executor to provide a bounded default timeout and maxBuffer, while preserving
caller overrides by spreading spawnOptions after the defaults. Keep the existing
encoding, environment, shell, and stdio behavior unchanged.

In `@src/lib/readiness/system.test.ts`:
- Around line 170-178: Update the readiness test assertion around
report.capabilities to first require a non-empty array, then retain the existing
every-state check ensuring all capabilities are "unknown". Use the existing
report.capabilities collection so the stale-report behavior cannot pass when no
capabilities are emitted.

---

Outside diff comments:
In `@src/lib/onboard/gateway-host-runtime-https.test.ts`:
- Around line 82-101: Restore the environment mutation in the gateway attachment
test by capturing the original OPENSHELL_GATEWAY_AUTH_TOKEN before assigning it
and restoring that value during cleanup, alongside OPENSHELL_LOCAL_TLS_DIR. Keep
the existing probe assertions unchanged and ensure the token cannot leak into
later tests.

---

Nitpick comments:
In `@src/lib/adapters/openshell/gateway-drift.ts`:
- Around line 433-442: Update the installed-version resolution in
getGatewayHostProcessDrift to match the other observers: when
deps.getInstalledOpenshellVersion exists, use its result directly, including
null, and only call getInstalledOpenshellVersionOrNull when the getter is
absent. Preserve the existing expectedVersion check and runtime resolution
behavior.

In `@src/lib/onboard/fatal-runtime-preflight.ts`:
- Around line 336-394: Extract the repeated gateway and system readiness
admission sequence into a helper near the existing onboarding readiness
utilities, accepting the current gateway readiness, refreshed host result,
options, context, and exitProcess dependencies and returning the updated gateway
readiness, managedGatewayReadiness, and readinessReport values. Replace both
post-refresh blocks in the surrounding preflight flow with calls to this helper,
preserving the existing admission order and identical options, and keep the
runtime GPU proof flow’s additional refresh between those calls unchanged.

In `@src/lib/onboard/gateway-authority-checkpoint.test.ts`:
- Around line 104-127: Add a test alongside the existing trusted-install cases
that creates a fresh session without calling bindGatewayAuthorityToCheckpoint,
snapshots session.checkpoint, and invokes
adoptPackagedGatewayAuthorityAfterTrustedInstall. Assert it throws the message
“Trusted gateway installation requires a previously bound gateway authority.”
and that the checkpoint remains equal to the snapshot.

In `@src/lib/onboard/machine/handlers/preflight.ts`:
- Around line 174-201: Update the second deps.assertOnboardHostReadiness call in
the resume flow to derive explicitlyOptedOutGpuPassthrough from the refreshed
resumeSandboxGpuConfig using the same expression as the first admission, rather
than hardcoding false. Keep the refreshed resolve, gateway-readiness, and
host-admission sequence aligned with the initial pass; a small local helper may
encapsulate the repeated admission logic if needed.

In `@src/lib/onboard/openshell-install.ts`:
- Line 292: Add a concise documentation comment to the option defining
afterSuccessfulInstall, stating that it runs only after installOpenshell
completes and all version, messaging-feature, and maximum-version gates pass.
Keep the callback invocation in the existing installed-success path unchanged.

In `@src/lib/onboard/runtime-control-flow.ts`:
- Around line 122-125: Extract the shared transition steps from the projection
and commit paths into one local helper, covering the resume-state clearing and
updateSessionAgent operations. Use this helper to build projectedSession and
inside the updateSession mutator, passing the mutator’s current session as its
input so both plan.session and committed state apply identical logic.

In `@src/lib/readiness/gateway-production.ts`:
- Around line 173-182: Update resolveTrustedGatewayBinary to accept the
sanitized probeEnv environment and read NEMOCLAW_OPENSHELL_GATEWAY_BIN from it
instead of process.env. Pass the same probeEnv produced by
buildGatewayReadinessProbeEnv through the readiness probe call chain, matching
resolveTrustedOpenshellBinary, so tests can control the override without
mutating process.env.
- Around line 342-366: Update observeManagedGateway and inspectLegacyCluster to
accept and reuse the openshell status, named gateway info, and active gateway
info captured by observeReuseState. Remove the duplicate captureReadonly
subprocess calls from inspectLegacyCluster, while preserving its existing health
and endpoint-binding checks; retain only the Docker inspections in the legacy
path.

In `@src/lib/readiness/host.ts`:
- Around line 103-112: Refactor adaptHostAssessment to accept a single options
object containing host, architecture, hasNvidiaGpu, and the existing optional
GPU/platform fields. Update its sole call site to pass named properties instead
of positional arguments, preserving the current values and nested-ternary
behavior.

In `@src/lib/readiness/onboard-admission.ts`:
- Around line 268-299: Extract the repeated blocking-finding classification
logic into a shared helper that iterates findings, skips non-blocking entries,
calls canWaiveFinding with supplied options, and returns waivedFindingIds and
findingIds. Update both evaluateOnboardReadinessAdmission and
evaluateOnboardGatewayReadinessAdmission to use this helper, passing their
respective waiver options while preserving the existing managedGateway behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 9f184c47-19e9-4fa0-ab8b-87aaad7cfba9

📥 Commits

Reviewing files that changed from the base of the PR and between acf810d and 7cf47be.

📒 Files selected for processing (105)
  • ci/platform-matrix.json
  • ci/source-architecture-budget.json
  • ci/source-shape-test-budget.json
  • ci/test-file-size-budget.json
  • docs/about/how-it-works.mdx
  • docs/inference/choose-inference-provider.mdx
  • docs/reference/commands.mdx
  • docs/reference/platform-support.mdx
  • docs/reference/system-readiness.mdx
  • scripts/install.sh
  • src/commands/host/probe.test.ts
  • src/commands/host/probe.ts
  • src/lib/actions/sandbox/gateway-target.ts
  • src/lib/actions/sandbox/rebuild-destroy-phase.test.ts
  • src/lib/actions/sandbox/rebuild-gpu-opt-out.ts
  • src/lib/actions/sandbox/rebuild-hermes-accepted-target.test.ts
  • src/lib/actions/sandbox/rebuild-onboard-dependencies.ts
  • src/lib/actions/sandbox/rebuild-pipeline.ts
  • src/lib/actions/sandbox/rebuild-preflight-target-phase.test.ts
  • src/lib/actions/sandbox/rebuild-preflight-target-phase.ts
  • src/lib/actions/sandbox/rebuild-recreate-journal.test.ts
  • src/lib/actions/sandbox/rebuild-recreate-journal.ts
  • src/lib/actions/sandbox/rebuild-recreate-observability.test.ts
  • src/lib/actions/sandbox/rebuild-recreate-phase.ts
  • src/lib/actions/sandbox/rebuild-recreate-reasoning.test.ts
  • src/lib/actions/sandbox/rebuild-resume-snapshot.test.ts
  • src/lib/actions/sandbox/rebuild-shields-finally.test.ts
  • src/lib/actions/sandbox/rebuild-target-runtime.ts
  • src/lib/adapters/openshell/gateway-drift.test.ts
  • src/lib/adapters/openshell/gateway-drift.ts
  • src/lib/advisories/checks/host/docker.test.ts
  • src/lib/advisories/checks/host/docker.ts
  • src/lib/advisories/checks/host/index.test.ts
  • src/lib/advisories/checks/host/runtime.test.ts
  • src/lib/advisories/checks/host/runtime.ts
  • src/lib/advisories/registry.test.ts
  • src/lib/advisories/registry.ts
  • src/lib/domain/docker-host.test.ts
  • src/lib/domain/docker-host.ts
  • src/lib/inference/nim.ts
  • src/lib/onboard.ts
  • src/lib/onboard/authoritative-rebuild-target.test.ts
  • src/lib/onboard/authoritative-rebuild-target.ts
  • src/lib/onboard/bridge-dns-preflight.ts
  • src/lib/onboard/docker-cdi.ts
  • src/lib/onboard/docker-driver-gateway-env.ts
  • src/lib/onboard/docker-driver-gateway-process-identity.test.ts
  • src/lib/onboard/docker-driver-gateway-process-identity.ts
  • src/lib/onboard/docker-driver-gateway-runtime.ts
  • src/lib/onboard/docker-driver-gateway-service-version-gate.test.ts
  • src/lib/onboard/docker-driver-gateway-service.test.ts
  • src/lib/onboard/docker-driver-gateway-service.ts
  • src/lib/onboard/fatal-runtime-preflight.test.ts
  • src/lib/onboard/fatal-runtime-preflight.ts
  • src/lib/onboard/gateway-authority-checkpoint.test.ts
  • src/lib/onboard/gateway-authority-checkpoint.ts
  • src/lib/onboard/gateway-host-runtime-https.test.ts
  • src/lib/onboard/gateway-host-runtime.test.ts
  • src/lib/onboard/gateway-host-runtime.ts
  • src/lib/onboard/gateway-http-readiness.ts
  • src/lib/onboard/machine/handlers/preflight.test.ts
  • src/lib/onboard/machine/handlers/preflight.ts
  • src/lib/onboard/machine/initial-flow-phases.test.ts
  • src/lib/onboard/machine/initial-flow-phases.ts
  • src/lib/onboard/openshell-cli.ts
  • src/lib/onboard/openshell-install.test.ts
  • src/lib/onboard/openshell-install.ts
  • src/lib/onboard/preflight-cdi.test.ts
  • src/lib/onboard/preflight-docker-host.test.ts
  • src/lib/onboard/preflight-messages.test.ts
  • src/lib/onboard/preflight-messages.ts
  • src/lib/onboard/preflight-readiness.test.ts
  • src/lib/onboard/preflight.test.ts
  • src/lib/onboard/preflight.ts
  • src/lib/onboard/remediation.ts
  • src/lib/onboard/runtime-control-flow.test.ts
  • src/lib/onboard/runtime-control-flow.ts
  • src/lib/onboard/runtime-provider/docker.test.ts
  • src/lib/onboard/runtime-provider/docker.ts
  • src/lib/onboard/sandbox-gpu-preflight.ts
  • src/lib/readiness/effects.test.ts
  • src/lib/readiness/gateway-production.test.ts
  • src/lib/readiness/gateway-production.ts
  • src/lib/readiness/gateway.test.ts
  • src/lib/readiness/gateway.ts
  • src/lib/readiness/host-production.test.ts
  • src/lib/readiness/host.test.ts
  • src/lib/readiness/host.ts
  • src/lib/readiness/index.ts
  • src/lib/readiness/onboard-admission.test.ts
  • src/lib/readiness/onboard-admission.ts
  • src/lib/readiness/openshell-resolver.ts
  • src/lib/readiness/platform-qualification.test.ts
  • src/lib/readiness/platform-qualification.ts
  • src/lib/readiness/presentation.test.ts
  • src/lib/readiness/presentation.ts
  • src/lib/readiness/probe-env.test.ts
  • src/lib/readiness/probe-env.ts
  • src/lib/readiness/sanitize.ts
  • src/lib/readiness/system.test.ts
  • src/lib/readiness/system.ts
  • test/helpers/rebuild-flow-harness.ts
  • test/helpers/rebuild-flow-test-harness.ts
  • test/install-preflight.test.ts
  • test/mcp-destroy-lifecycle.test.ts

Comment thread scripts/install.sh
Comment thread src/lib/domain/docker-host.ts
Comment thread src/lib/onboard/docker-cdi.ts
Comment thread src/lib/onboard/docker-driver-gateway-service.ts
Comment thread src/lib/onboard/fatal-runtime-preflight.test.ts
Comment thread src/lib/readiness/openshell-resolver.ts Outdated
Comment thread src/lib/readiness/platform-qualification.ts
Comment thread src/lib/readiness/probe-env.ts Outdated
Comment thread src/lib/readiness/probe-env.ts
Comment thread src/lib/readiness/system.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/onboard.ts`:
- Around line 1405-1406: Remove the duplicate collectOnboardGatewayReadiness
declarations in src/lib/onboard.ts, retaining exactly one implementation that
delegates to preflightGatewayAuthority.collectOnboardGatewayReadiness with the
existing gatewayName, gatewayPort, resolveOwner, and probeAttachment arguments.

In `@src/lib/onboard/machine/preflight-gateway-authority.ts`:
- Around line 59-71: Apply the canonical gateway-readiness admission to the
refreshed gateway projection before computing externallySupervised or invoking
failFastOnForeignGatewayPortConflict in the preflight flow. Ensure blocking,
conflicting, or inconclusive refreshed states fail closed and prevent reuse and
lifecycle handling. Add coverage verifying a blocking refreshed projection stops
processing before those operations run.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a38ddd7d-b4e4-46b9-9628-a602039d1fd5

📥 Commits

Reviewing files that changed from the base of the PR and between 7cf47be and 1de4e7b.

📒 Files selected for processing (9)
  • src/lib/actions/sandbox/rebuild-preflight-target-phase.test.ts
  • src/lib/onboard.ts
  • src/lib/onboard/docker-driver-gateway-service.test.ts
  • src/lib/onboard/fatal-runtime-preflight.test.ts
  • src/lib/onboard/machine/handlers/preflight.test.ts
  • src/lib/onboard/machine/initial-flow-phases.test.ts
  • src/lib/onboard/machine/preflight-gateway-authority.ts
  • src/lib/onboard/runtime-provider/docker.test.ts
  • src/lib/readiness/gateway-production.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/lib/actions/sandbox/rebuild-preflight-target-phase.test.ts
  • src/lib/onboard/runtime-provider/docker.test.ts
  • src/lib/onboard/machine/initial-flow-phases.test.ts
  • src/lib/onboard/docker-driver-gateway-service.test.ts

Comment thread src/lib/onboard.ts
Comment thread src/lib/onboard/machine/preflight-gateway-authority.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/lib/onboard/fatal-runtime-preflight.ts (1)

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

Extract the repeated refresh-and-admit block.

Lines 342-355 and Lines 384-394 repeat the same five steps: refresh the gateway projection, assert gateway admission, recompute managedGatewayReadiness, compose the system report, and assert system admission. One helper that takes the current gatewayReadiness and refreshedResult and returns the composed report plus the managed flag would remove the duplication and keep the two gates identical if the policy changes.

Also applies to: 384-394

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/fatal-runtime-preflight.ts` around lines 342 - 355, The
refresh-and-admit sequence is duplicated in the onboarding flow. Extract a
helper near the existing readiness logic that accepts the current
gatewayReadiness and refreshedResult, performs
refreshGatewayReadinessProjection, assertOnboardGatewayReadiness, managed
readiness calculation, composeSystemReadinessReport, and
assertOnboardSystemReadiness, then returns the composed report and
managedGatewayReadiness; replace both blocks around the current and resumed
paths with this helper while preserving their existing options and context.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/lib/onboard/fatal-runtime-preflight.ts`:
- Around line 342-355: The refresh-and-admit sequence is duplicated in the
onboarding flow. Extract a helper near the existing readiness logic that accepts
the current gatewayReadiness and refreshedResult, performs
refreshGatewayReadinessProjection, assertOnboardGatewayReadiness, managed
readiness calculation, composeSystemReadinessReport, and
assertOnboardSystemReadiness, then returns the composed report and
managedGatewayReadiness; replace both blocks around the current and resumed
paths with this helper while preserving their existing options and context.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fee0bb32-8dd8-4dac-b485-3534710f3d26

📥 Commits

Reviewing files that changed from the base of the PR and between acf810d and 1de4e7b.

📒 Files selected for processing (106)
  • ci/platform-matrix.json
  • ci/source-architecture-budget.json
  • ci/source-shape-test-budget.json
  • ci/test-file-size-budget.json
  • docs/about/how-it-works.mdx
  • docs/inference/choose-inference-provider.mdx
  • docs/reference/commands.mdx
  • docs/reference/platform-support.mdx
  • docs/reference/system-readiness.mdx
  • scripts/install.sh
  • src/commands/host/probe.test.ts
  • src/commands/host/probe.ts
  • src/lib/actions/sandbox/gateway-target.ts
  • src/lib/actions/sandbox/rebuild-destroy-phase.test.ts
  • src/lib/actions/sandbox/rebuild-gpu-opt-out.ts
  • src/lib/actions/sandbox/rebuild-hermes-accepted-target.test.ts
  • src/lib/actions/sandbox/rebuild-onboard-dependencies.ts
  • src/lib/actions/sandbox/rebuild-pipeline.ts
  • src/lib/actions/sandbox/rebuild-preflight-target-phase.test.ts
  • src/lib/actions/sandbox/rebuild-preflight-target-phase.ts
  • src/lib/actions/sandbox/rebuild-recreate-journal.test.ts
  • src/lib/actions/sandbox/rebuild-recreate-journal.ts
  • src/lib/actions/sandbox/rebuild-recreate-observability.test.ts
  • src/lib/actions/sandbox/rebuild-recreate-phase.ts
  • src/lib/actions/sandbox/rebuild-recreate-reasoning.test.ts
  • src/lib/actions/sandbox/rebuild-resume-snapshot.test.ts
  • src/lib/actions/sandbox/rebuild-shields-finally.test.ts
  • src/lib/actions/sandbox/rebuild-target-runtime.ts
  • src/lib/adapters/openshell/gateway-drift.test.ts
  • src/lib/adapters/openshell/gateway-drift.ts
  • src/lib/advisories/checks/host/docker.test.ts
  • src/lib/advisories/checks/host/docker.ts
  • src/lib/advisories/checks/host/index.test.ts
  • src/lib/advisories/checks/host/runtime.test.ts
  • src/lib/advisories/checks/host/runtime.ts
  • src/lib/advisories/registry.test.ts
  • src/lib/advisories/registry.ts
  • src/lib/domain/docker-host.test.ts
  • src/lib/domain/docker-host.ts
  • src/lib/inference/nim.ts
  • src/lib/onboard.ts
  • src/lib/onboard/authoritative-rebuild-target.test.ts
  • src/lib/onboard/authoritative-rebuild-target.ts
  • src/lib/onboard/bridge-dns-preflight.ts
  • src/lib/onboard/docker-cdi.ts
  • src/lib/onboard/docker-driver-gateway-env.ts
  • src/lib/onboard/docker-driver-gateway-process-identity.test.ts
  • src/lib/onboard/docker-driver-gateway-process-identity.ts
  • src/lib/onboard/docker-driver-gateway-runtime.ts
  • src/lib/onboard/docker-driver-gateway-service-version-gate.test.ts
  • src/lib/onboard/docker-driver-gateway-service.test.ts
  • src/lib/onboard/docker-driver-gateway-service.ts
  • src/lib/onboard/fatal-runtime-preflight.test.ts
  • src/lib/onboard/fatal-runtime-preflight.ts
  • src/lib/onboard/gateway-authority-checkpoint.test.ts
  • src/lib/onboard/gateway-authority-checkpoint.ts
  • src/lib/onboard/gateway-host-runtime-https.test.ts
  • src/lib/onboard/gateway-host-runtime.test.ts
  • src/lib/onboard/gateway-host-runtime.ts
  • src/lib/onboard/gateway-http-readiness.ts
  • src/lib/onboard/machine/handlers/preflight.test.ts
  • src/lib/onboard/machine/handlers/preflight.ts
  • src/lib/onboard/machine/initial-flow-phases.test.ts
  • src/lib/onboard/machine/initial-flow-phases.ts
  • src/lib/onboard/machine/preflight-gateway-authority.ts
  • src/lib/onboard/openshell-cli.ts
  • src/lib/onboard/openshell-install.test.ts
  • src/lib/onboard/openshell-install.ts
  • src/lib/onboard/preflight-cdi.test.ts
  • src/lib/onboard/preflight-docker-host.test.ts
  • src/lib/onboard/preflight-messages.test.ts
  • src/lib/onboard/preflight-messages.ts
  • src/lib/onboard/preflight-readiness.test.ts
  • src/lib/onboard/preflight.test.ts
  • src/lib/onboard/preflight.ts
  • src/lib/onboard/remediation.ts
  • src/lib/onboard/runtime-control-flow.test.ts
  • src/lib/onboard/runtime-control-flow.ts
  • src/lib/onboard/runtime-provider/docker.test.ts
  • src/lib/onboard/runtime-provider/docker.ts
  • src/lib/onboard/sandbox-gpu-preflight.ts
  • src/lib/readiness/effects.test.ts
  • src/lib/readiness/gateway-production.test.ts
  • src/lib/readiness/gateway-production.ts
  • src/lib/readiness/gateway.test.ts
  • src/lib/readiness/gateway.ts
  • src/lib/readiness/host-production.test.ts
  • src/lib/readiness/host.test.ts
  • src/lib/readiness/host.ts
  • src/lib/readiness/index.ts
  • src/lib/readiness/onboard-admission.test.ts
  • src/lib/readiness/onboard-admission.ts
  • src/lib/readiness/openshell-resolver.ts
  • src/lib/readiness/platform-qualification.test.ts
  • src/lib/readiness/platform-qualification.ts
  • src/lib/readiness/presentation.test.ts
  • src/lib/readiness/presentation.ts
  • src/lib/readiness/probe-env.test.ts
  • src/lib/readiness/probe-env.ts
  • src/lib/readiness/sanitize.ts
  • src/lib/readiness/system.test.ts
  • src/lib/readiness/system.ts
  • test/helpers/rebuild-flow-harness.ts
  • test/helpers/rebuild-flow-test-harness.ts
  • test/install-preflight.test.ts
  • test/mcp-destroy-lifecycle.test.ts
🚧 Files skipped from review as they are similar to previous changes (99)
  • src/lib/onboard/bridge-dns-preflight.ts
  • src/lib/onboard/openshell-install.test.ts
  • src/lib/advisories/checks/host/docker.test.ts
  • scripts/install.sh
  • ci/source-shape-test-budget.json
  • docs/reference/commands.mdx
  • src/lib/actions/sandbox/rebuild-shields-finally.test.ts
  • src/lib/readiness/presentation.test.ts
  • src/lib/advisories/checks/host/docker.ts
  • src/lib/onboard/docker-driver-gateway-env.ts
  • src/lib/actions/sandbox/gateway-target.ts
  • src/lib/onboard/preflight-messages.ts
  • src/lib/onboard/gateway-host-runtime.test.ts
  • src/lib/advisories/checks/host/index.test.ts
  • src/lib/readiness/probe-env.test.ts
  • src/lib/onboard/preflight-messages.test.ts
  • src/lib/onboard/remediation.ts
  • src/lib/actions/sandbox/rebuild-gpu-opt-out.ts
  • src/lib/onboard/docker-cdi.ts
  • docs/about/how-it-works.mdx
  • src/lib/actions/sandbox/rebuild-preflight-target-phase.test.ts
  • src/commands/host/probe.ts
  • src/lib/onboard/openshell-cli.ts
  • src/lib/readiness/host-production.test.ts
  • ci/test-file-size-budget.json
  • src/lib/readiness/effects.test.ts
  • src/lib/domain/docker-host.test.ts
  • src/lib/actions/sandbox/rebuild-target-runtime.ts
  • src/lib/onboard/machine/handlers/preflight.test.ts
  • src/lib/actions/sandbox/rebuild-recreate-journal.test.ts
  • src/lib/onboard/docker-driver-gateway-service.test.ts
  • src/lib/actions/sandbox/rebuild-onboard-dependencies.ts
  • src/lib/readiness/index.ts
  • src/lib/actions/sandbox/rebuild-pipeline.ts
  • src/lib/onboard/runtime-provider/docker.test.ts
  • src/lib/actions/sandbox/rebuild-recreate-observability.test.ts
  • src/lib/onboard/authoritative-rebuild-target.ts
  • src/lib/onboard/runtime-control-flow.test.ts
  • src/lib/actions/sandbox/rebuild-hermes-accepted-target.test.ts
  • test/mcp-destroy-lifecycle.test.ts
  • docs/inference/choose-inference-provider.mdx
  • src/lib/onboard/docker-driver-gateway-service-version-gate.test.ts
  • src/lib/onboard/preflight-docker-host.test.ts
  • src/lib/onboard/machine/handlers/preflight.ts
  • src/lib/actions/sandbox/rebuild-preflight-target-phase.ts
  • src/lib/readiness/openshell-resolver.ts
  • src/lib/onboard/runtime-control-flow.ts
  • src/lib/advisories/checks/host/runtime.test.ts
  • src/lib/onboard/preflight-cdi.test.ts
  • src/lib/advisories/registry.test.ts
  • src/lib/onboard/docker-driver-gateway-service.ts
  • src/lib/actions/sandbox/rebuild-recreate-journal.ts
  • src/lib/readiness/onboard-admission.ts
  • test/install-preflight.test.ts
  • src/lib/actions/sandbox/rebuild-recreate-reasoning.test.ts
  • src/lib/readiness/sanitize.ts
  • src/lib/onboard/gateway-host-runtime.ts
  • src/lib/advisories/registry.ts
  • src/lib/actions/sandbox/rebuild-resume-snapshot.test.ts
  • src/lib/readiness/gateway-production.test.ts
  • src/lib/readiness/gateway.ts
  • src/lib/onboard/gateway-authority-checkpoint.test.ts
  • src/lib/onboard/machine/preflight-gateway-authority.ts
  • src/lib/inference/nim.ts
  • src/lib/readiness/platform-qualification.ts
  • src/lib/actions/sandbox/rebuild-destroy-phase.test.ts
  • src/commands/host/probe.test.ts
  • src/lib/onboard/openshell-install.ts
  • src/lib/onboard/docker-driver-gateway-runtime.ts
  • src/lib/readiness/host.test.ts
  • src/lib/onboard/docker-driver-gateway-process-identity.test.ts
  • src/lib/readiness/platform-qualification.test.ts
  • src/lib/onboard/authoritative-rebuild-target.test.ts
  • src/lib/readiness/gateway.test.ts
  • src/lib/onboard/gateway-authority-checkpoint.ts
  • src/lib/onboard/machine/initial-flow-phases.ts
  • src/lib/onboard/fatal-runtime-preflight.test.ts
  • src/lib/onboard/runtime-provider/docker.ts
  • src/lib/onboard/gateway-http-readiness.ts
  • docs/reference/platform-support.mdx
  • src/lib/advisories/checks/host/runtime.ts
  • src/lib/onboard/machine/initial-flow-phases.test.ts
  • src/lib/onboard/preflight.test.ts
  • src/lib/readiness/presentation.ts
  • ci/source-architecture-budget.json
  • src/lib/onboard/preflight.ts
  • src/lib/adapters/openshell/gateway-drift.test.ts
  • src/lib/actions/sandbox/rebuild-recreate-phase.ts
  • src/lib/onboard/gateway-host-runtime-https.test.ts
  • src/lib/onboard/preflight-readiness.test.ts
  • src/lib/readiness/host.ts
  • test/helpers/rebuild-flow-test-harness.ts
  • src/lib/onboard.ts
  • ci/platform-matrix.json
  • src/lib/adapters/openshell/gateway-drift.ts
  • src/lib/onboard/sandbox-gpu-preflight.ts
  • test/helpers/rebuild-flow-harness.ts
  • src/lib/readiness/system.ts
  • src/lib/domain/docker-host.ts

Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/rebuild-credential-preflight.test.ts`:
- Around line 54-55: Update the gateway startup flow in the rebuild credential
preflight test to request an operating-system-assigned port by starting the
child with port 0. Read the assigned port from the readiness marker, then derive
gatewayName, registry data, and command mocks from that assigned port instead of
process.pid and gatewayPortSequence.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7bb6119c-08bd-49f8-9221-fd5d7b0a727b

📥 Commits

Reviewing files that changed from the base of the PR and between 1de4e7b and fed4590.

📒 Files selected for processing (1)
  • test/rebuild-credential-preflight.test.ts

Comment thread test/rebuild-credential-preflight.test.ts Outdated
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
Comment thread test/rebuild-credential-preflight.test.ts Fixed
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>
Signed-off-by: Julie Yaunches <jyaunches@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/lib/onboard/machine/preflight-gateway-authority.ts (1)

39-43: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Tie gatewayPort to GatewayOwner.

The current caller passes the same value to both parameters, but the contract permits divergence. Derive the port from the resolved owner to make this invariant explicit, and test that the conflict check uses owner.gatewayPort.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/onboard/machine/preflight-gateway-authority.ts` around lines 39 - 43,
Update EarlyGatewayPortConflictDeps and its conflict-check flow to derive the
port from resolveOwner()’s returned GatewayOwner instead of accepting a separate
gatewayPort value. Use owner.gatewayPort when invoking the conflict check,
remove the redundant dependency field, and add coverage verifying the owner’s
port is used.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/onboard/machine/preflight-gateway-authority.ts`:
- Around line 45-54: Remove the legacy early port fast-fail helper
failFastOnEarlyGatewayPortConflict and its duplicate invocation from
preparePreflightGatewayAuthority, allowing collectOnboardGatewayReadiness to
perform canonical admission and emit structured gateway findings. Do not retain
the readiness-path exit unless a bounded compatibility window, retirement issue,
and exit criteria are explicitly documented.

In `@test/gateway-state-reconcile-2276.test.ts`:
- Line 294: Update the gateway fixture setup around gatewayPort and the listener
binding to use an ephemeral port (0), then read the listener’s assigned port and
consistently pass that value to the registry, gateway fixtures, and Docker
inspection response instead of hard-coding 8080.
- Around line 290-299: Update the docker inspect stub in the inspect branch to
parse the requested container target, accept only the expected gateway
container, and reject unexpected targets. Also validate the requested format
before returning each mocked gateway value, preserving the existing responses
only for recognized target-and-format combinations.

---

Nitpick comments:
In `@src/lib/onboard/machine/preflight-gateway-authority.ts`:
- Around line 39-43: Update EarlyGatewayPortConflictDeps and its conflict-check
flow to derive the port from resolveOwner()’s returned GatewayOwner instead of
accepting a separate gatewayPort value. Use owner.gatewayPort when invoking the
conflict check, remove the redundant dependency field, and add coverage
verifying the owner’s port is used.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6b4a3a98-7b02-42ff-973f-37463151c789

📥 Commits

Reviewing files that changed from the base of the PR and between 8c18ba6 and 9d3cc5c.

📒 Files selected for processing (6)
  • src/lib/actions/sandbox/rebuild-recreate-observability.test.ts
  • src/lib/onboard.ts
  • src/lib/onboard/machine/preflight-gateway-authority.ts
  • test/exit-code-user-error-surfaces.test.ts
  • test/gateway-state-reconcile-2276.test.ts
  • test/onboard-inference-reconciliation.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/lib/actions/sandbox/rebuild-recreate-observability.test.ts
  • src/lib/onboard.ts

Comment thread src/lib/onboard/machine/preflight-gateway-authority.ts Outdated
Comment thread test/gateway-state-reconcile-2276.test.ts Outdated
Comment thread test/gateway-state-reconcile-2276.test.ts Outdated
@cv
cv merged commit f042117 into main Aug 10, 2026
75 of 79 checks passed
@cv
cv deleted the codex/readiness-convergence-7411 branch August 10, 2026 17:44
@github-actions github-actions Bot added the v0.0.106 Release target label Aug 10, 2026
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output area: networking DNS, proxy, TLS, ports, host aliases, or connectivity area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery area: security Security controls, permissions, secrets, or hardening feature PR adds or expands user-visible functionality platform: container Affects Docker, containerd, Podman, or images platform: jetson Affects Jetson AGX Thor or Orin labels Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output area: networking DNS, proxy, TLS, ports, host aliases, or connectivity area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery area: security Security controls, permissions, secrets, or hardening feature PR adds or expands user-visible functionality platform: container Affects Docker, containerd, Podman, or images platform: jetson Affects Jetson AGX Thor or Orin v0.0.106 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Readiness 5/5] Converge onboarding, gateway diagnostics, and doctor on readiness checks

4 participants