Skip to content

refactor(onboard): centralize readiness authority wiring - #8909

Merged
cv merged 5 commits into
mainfrom
codex/audit-8738-onboard-growth
Aug 12, 2026
Merged

refactor(onboard): centralize readiness authority wiring#8909
cv merged 5 commits into
mainfrom
codex/audit-8738-onboard-growth

Conversation

@cjagwani

@cjagwani cjagwani commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

This refactor removes five formatter exemptions that survived the entrypoint-budget work in #8738. It moves the default OpenShell installation and readiness/gateway-authority dependency assembly into the existing modules that own those contracts.

The install, trusted authority checkpoint, readiness, port-conflict, and gateway-reuse order is unchanged. src/lib/onboard.ts becomes one line smaller, its measured fan-out falls from 211 to 210, and no configuration or supported behavior changes.

Changes

  • Add a typed OpenShell onboarding binding for the existing install and binary-presence paths.
  • Add a typed preflight gateway-authority binding for the existing readiness, authority, port-conflict, and reuse paths.
  • Preserve the existing readiness-collector override seam through explicit dependency injection.
  • Replace compressed onboard.ts wiring with formatted calls and remove five growth-guardrail formatter suppressions.
  • Add focused tests for lazy dependency resolution, trusted-owner persistence, dynamic gateway values, custom rebuild exit handling, and the preserved preflight event order.
  • Route authoritative rebuild through the same readiness-authority seam instead of retaining a parallel fatal-preflight call.

The current consumers are the standard onboarding preflight and authoritative rebuild readiness paths. Existing owner modules now assemble their canonical dependencies; no new extension or configuration surface is introduced.

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: No flag, environment variable, default, output, public API, persistence schema, lifecycle effect, or failure order changes.
  • 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: Codex Desktop completed the exact-head nine-category review with PASS in every category and no findings: refactor(onboard): centralize readiness authority wiring #8909 (comment)
  • 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: no-docs-needed
  • Evidence: Existing system-readiness, command-reference, recovery, and troubleshooting pages already document the preserved install, authority-recording, readiness, port-conflict, and reuse order; the follow-up only completes the internal readiness-authority cutover.
  • 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 — 82 focused assertions passed across OpenShell install, gateway-authority preflight, fatal readiness, readiness presentation, gateway sequence, checkpoint, and host-runtime contracts; the exact-head authority unit test passes 2/2 and proves the rebuild exit handler reaches the canonical preflight context; npm run build:cli, npm run typecheck:cli, source architecture, source shape, and test-size checks passed. The existing macOS integration test advances past the readiness-collector regression and then encounters an unrelated host Homebrew trust probe; the Linux CI rerun is authoritative.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result: Not applicable to this focused internal dependency-wiring refactor.
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

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

Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Aug 12, 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.

@cjagwani

Copy link
Copy Markdown
Collaborator Author

Sensitive-path security review (exact head 864f434): PASS with no findings. Reviewed the complete diff across all nine required categories: (1) input validation and trust boundaries—the same gateway name, port, owner, options, and readiness inputs are passed through typed bindings; (2) credentials and secrets—no credential source, value, storage, or logging changes; (3) network exposure and SSRF—the same local gateway readiness and port-conflict functions execute with dynamic current values; (4) command execution and injection—the same OpenShell install dependency set and process-exit callback are used, with no new command or interpolation; (5) permissions and privilege boundaries—no privilege or ownership rule changes; (6) sandbox isolation—the same fail-closed gateway authority and reuse lifecycle remains; (7) injection classes—no shell, URL, parser, SQL, HTML, or template sink changes; (8) dependencies and supply chain—no package, image, pin, or artifact changes; (9) data exposure and logging—no output or persisted data changes. Focused tests explicitly prove lazy install dependencies, trusted-owner persistence, dynamic gateway values, and the preserved install → checkpoint → readiness → port-check → reuse order.

@cjagwani
cjagwani marked this pull request as ready for review August 12, 2026 16:06
@github-code-quality

github-code-quality Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in commit a1dad11 in the codex/audit-8738-onb... branch remains at 96%, unchanged from commit 419de9d in the main branch.

TypeScript / code-coverage/cli

The overall coverage in commit a1dad11 in the codex/audit-8738-onb... branch remains at 82%, unchanged from commit 250d4ab in the main branch.

Show a code coverage summary of the most impacted files.
File main 250d4ab codex/audit-8738-onb... a1dad11 +/-
src/lib/cua/bounded-file.ts 94% 84% -10%
src/lib/cua/run...ime-manifest.ts 91% 84% -7%
src/lib/cua/contract.ts 87% 80% -7%
src/lib/messagi.../ilink-login.ts 96% 89% -7%
src/lib/trace.ts 94% 90% -4%
src/lib/state/o...d-checkpoint.ts 90% 87% -3%
src/lib/onboard.ts 32% 32% 0%
src/lib/onboard...press-resume.ts 78% 82% +4%
src/lib/securit...ntial-filter.ts 91% 95% +4%
src/lib/onboard...der/snapshot.ts 75% 83% +8%

Updated August 12, 2026 17:23 UTC

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bc3e3d75-ae22-48bc-8bc4-70be0fb9e366

📥 Commits

Reviewing files that changed from the base of the PR and between 5d8243e and a1dad11.

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

📝 Walkthrough

Walkthrough

OpenShell installation now uses factory-created bindings with gateway-owner persistence. Gateway-authority preflight is composed once and reused by runtime, rebuild, and initial readiness flows. Namespaced checkpoint APIs and focused factory tests were added.

Changes

Onboarding gateway authority

Layer / File(s) Summary
OpenShell installation bindings
src/lib/onboard/openshell-install.ts, src/lib/onboard/openshell-install.test.ts
The factory creates lazy installation bindings, forwards callbacks, checks Docker driver binaries, and preserves installation results.
Gateway-authority preflight factory
src/lib/onboard/machine/preflight-gateway-authority.ts, src/lib/onboard/machine/preflight-gateway-authority.test.ts
The factory wires readiness collection, runtime preflight, OpenShell setup, ownership persistence, port checks, and gateway reuse operations. Tests verify dependency wiring and operation order.
Onboarding flow integration
src/lib/onboard.ts
Runtime, rebuild, and initial readiness checks use the composed authority. Gateway checkpoint access uses the namespaced checkpoint module.

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

Sequence Diagram(s)

sequenceDiagram
  participant OnboardFlow
  participant OnboardPreflightGatewayAuthority
  participant ReadinessCollector
  participant GatewayAuthorityPreparation
  OnboardFlow->>OnboardPreflightGatewayAuthority: request gateway readiness
  OnboardPreflightGatewayAuthority->>ReadinessCollector: collect readiness
  OnboardPreflightGatewayAuthority->>GatewayAuthorityPreparation: prepare gateway authority
  GatewayAuthorityPreparation-->>OnboardFlow: return prepared authority
Loading

Possibly related PRs

Suggested labels: refactor, area: onboarding

Suggested reviewers: cv, senthilr-nv, jyaunches

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: centralizing onboarding readiness and gateway-authority dependency wiring.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/audit-8738-onboard-growth

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

@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 `@src/lib/onboard/machine/preflight-gateway-authority.ts`:
- Around line 76-82: Extend onboard/machine/preflight-gateway-authority.ts in
runRuntimePreflight to accept and forward a narrow exitProcess override to
fatalRuntimePreflight.runReadinessGatedRuntimePreflight. In src/lib/onboard.ts
lines 3686-3701, replace the direct fatal-runtime-preflight invocation with
onboardPreflightGatewayAuthority.runRuntimePreflight so rebuild uses the
authoritative path. In
src/lib/onboard/machine/preflight-gateway-authority.test.ts lines 19-131, add
coverage confirming the override reaches the runtime-preflight context.
🪄 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: 4eb97322-75d0-4efc-911c-0475a80efa7a

📥 Commits

Reviewing files that changed from the base of the PR and between 971811c and 864f434.

📒 Files selected for processing (5)
  • src/lib/onboard.ts
  • src/lib/onboard/machine/preflight-gateway-authority.test.ts
  • src/lib/onboard/machine/preflight-gateway-authority.ts
  • src/lib/onboard/openshell-install.test.ts
  • src/lib/onboard/openshell-install.ts

Comment thread src/lib/onboard/machine/preflight-gateway-authority.ts
Signed-off-by: Charan Jagwani <cjagwani@nvidia.com>
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings reported

Advisor assessment: No blocking advisor findings reported
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Skipped

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

1 semantic terminology decision

Terminology decisions are advisory. They affect the assessment only when a separate finding identifies concrete semantic impact.

  • replace — trusted owner at src/lib/onboard/openshell-install.test.ts:52: Use "gateway-authority persistence" in the test title.

E2E guidance

Advisory only. A maintainer can dispatch the default E2E suite for the commit under review.

Recommended E2E: managed-image-protected-runtime

Manual-only E2E: cloud-onboard, managed-image-multiarch-startup, onboard-repair, onboard-resume
The manual PR workflow does not run these selectors for the commit under review. Run them from reviewed code on main.

2 optional E2E recommendations
  • openshell-gateway-upgrade
  • gateway-guard-recovery

Workflow run details

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

@cjagwani

Copy link
Copy Markdown
Collaborator Author

Sensitive-path security review (exact head 54eb045): PASS with no findings. Reviewed the complete diff across all nine required categories: (1) input validation and trust boundaries—the same gateway name, port, owner, options, readiness inputs, and collector implementation cross the typed binding; (2) credentials and secrets—no credential source, value, storage, or logging changes; (3) network exposure and SSRF—the same local gateway readiness and port-conflict functions execute with dynamic current values; (4) command execution and injection—the same OpenShell install dependency set and process-exit callback are used, with no new command or interpolation; (5) permissions and privilege boundaries—no privilege or ownership rule changes; (6) sandbox isolation—the same fail-closed gateway authority and reuse lifecycle remains; (7) injection classes—no shell, URL, parser, SQL, HTML, or template sink changes; (8) dependencies and supply chain—no package, image, pin, or artifact changes; (9) data exposure and logging—no output or persisted data changes. The follow-up explicitly injects the pre-existing readiness collector so tests and callers retain the same override seam; focused tests cover lazy dependency resolution, trusted-owner persistence, dynamic gateway values, and the preserved install → checkpoint → readiness → port-check → reuse order.

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

Copy link
Copy Markdown
Collaborator Author

Sensitive-path security review (exact head 5d8243e): PASS with no findings. The only delta since the prior full nine-category PASS at 54eb045 is a focused unit-test assertion that runtime preflight receives the current interaction mode and the exact factory readiness collector. It changes no production code, input boundary, credential or secret handling, network or SSRF behavior, command execution, privilege model, sandbox isolation, injection sink, dependency, persisted data, or logging. The complete PR therefore retains the prior PASS across all nine required categories, with stronger coverage for the fail-closed readiness binding.

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

Copy link
Copy Markdown
Collaborator Author

Sensitive-path security review (exact head a1dad11): PASS with no findings. Independent nine-category review covered the complete five-file diff plus adjacent fatal-runtime-preflight and authoritative-rebuild enforcement. No credential, input, dependency, crypto, persisted-data, or logging boundary changes. The authoritative rebuild path sets NON_INTERACTIVE=true before invoking the central authority; runRuntimePreflight resolves that value at invocation time, uses the canonical readiness collector, and forwards the exact throwing exit handler into runReadinessGatedRuntimePreflight. Failed readiness therefore rejects the rebuild and reaches the enclosing finally restoration; fatal assertions retain post-exit throw backstops. Focused verification passed 49 assertions across four CLI test files plus CLI TypeScript, and commit a1dad11 has a good ED25519 signature.

@cv
cv merged commit 1664611 into main Aug 12, 2026
106 of 115 checks passed
@cv
cv deleted the codex/audit-8738-onboard-growth branch August 12, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants