Skip to content

refactor(onboard): extract modules from onboard.ts (WIP)#2087

Closed
ericksoa wants to merge 4 commits into
mainfrom
refactor/onboard-extract-modules
Closed

refactor(onboard): extract modules from onboard.ts (WIP)#2087
ericksoa wants to merge 4 commits into
mainfrom
refactor/onboard-extract-modules

Conversation

@ericksoa

@ericksoa ericksoa commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Rebased onto current main (post-#2441 merge). Steps 1–3 of the original plan:

  • Extract onboard-providers.ts — provider metadata, CRUD, labels, inference config
  • Extract onboard-ollama-proxy.ts — proxy lifecycle, model pull/validate
  • Extract onboard-inference-probes.ts — endpoint validation probes (OpenAI, Anthropic, Gemini)

Reduces onboard.ts by ~1,000 lines. All 3 new modules are under 400 lines. No behavior changes — all existing exports remain accessible via re-exports and thin wrappers.

Step 4 (dashboard extraction) was dropped — main already landed dashboard-contract.ts, dashboard-health.ts, and dashboard-recover.ts (#2398) which supersede that extraction.

Steps 5–10 (gateway, preflight, messaging, policies, inference-setup, sandbox) remain deferred per the original plan.

Downstream: #2306

#2306 (extract rebuild/recreate path + canonicalize credential resolution) builds directly on top of this PR. It imports REMOTE_PROVIDER_CONFIG, upsertProvider, and ensureOllamaAuthProxy from the new extracted modules via onboard.ts re-exports. Merging this PR first gives #2306 a clean module surface to build on.

Rebase notes

  • Ported all main-side refinements into the extracted modules (e.g., startOllamaAuthProxy now returns boolean, getProbeAuthMode always returns undefined)
  • Added type annotations for the CJS require() imports to satisfy strict TypeScript

Test plan

  • npx tsc -p tsconfig.src.json --noEmit compiles cleanly
  • Affected tests pass: gemini-probe-auth, credential-exposure, wsl2-probe-timeout
  • Full npm test (CI)
  • Manual smoke test: nemoclaw onboard completes successfully

Co-authored-by: Aaron Erickson aerickson@nvidia.com
Co-authored-by: jyaunches jyaunches@nvidia.com

Move provider metadata constants (REMOTE_PROVIDER_CONFIG, endpoint URLs,
LOCAL_INFERENCE_PROVIDERS, DISCORD_SNOWFLAKE_RE), lookup helpers
(getEffectiveProviderName, getNonInteractive*, getRequested*Hint),
gateway CRUD (upsertProvider, providerExistsInGateway,
upsertMessagingProviders, buildProviderArgs), and
getSandboxInferenceConfig into a dedicated onboard-providers module.

Add getProviderLabel() to consolidate the scattered if/else provider
name→label chains (used in printDashboard).

Functions that need runOpenshell accept it as a last parameter
(dependency injection) to avoid circular requires. onboard.ts retains
thin wrappers with the original signatures.

Update source-scanning tests to read onboard-providers.ts where the
code now lives.
Move the entire Ollama auth-proxy subsystem into a dedicated module:
token/PID persistence, proxy spawn/kill lifecycle, model prompt/pull,
and the exposure warning.

Zero coupling to other onboard logic — all dependencies (runner, ports,
local-inference, credentials, model-prompts) are imported directly.
Move inference endpoint probe functions (parseJsonObject,
hasResponsesToolCall, shouldRequireResponsesToolCalling,
getProbeAuthMode, getValidationProbeCurlArgs, probeResponsesToolCalling,
probeOpenAiLikeEndpoint, probeAnthropicEndpoint) into a dedicated
module.

All dependencies (http-probe, credentials, platform, validation) are
imported directly — no circular deps. The 4 validate* wrapper functions
remain in onboard.ts for now as they depend on promptValidationRecovery;
they'll consolidate when setupNim moves in a later step.

Update source-scanning tests to read from the new compiled file.
Move dashboard URL management, port forwarding, token retrieval,
access info, guidance lines, and the summary printer into a dedicated
module.

Functions needing runOpenshell/openshellShellCommand accept them as
DI parameters; onboard.ts provides thin wrappers. printDashboard
now uses getProviderLabel() from onboard-providers.
@coderabbitai

coderabbitai Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8068befc-2d62-46b7-8f9d-6a8b58c14fd3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/onboard-extract-modules

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

@jyaunches

Copy link
Copy Markdown
Contributor

Superseded by #2489 — rebased onto current main, dropped Step 4 (dashboard extraction already landed in #2398). Steps 1-3 preserved.

@jyaunches jyaunches closed this Apr 26, 2026
jyaunches added a commit that referenced this pull request Apr 27, 2026
…d) (#2495)

## ⚡ Interim PR — Unblocks #2306

This is an **interim extraction PR** that lands the foundational module
decomposition needed by #2306 (extract rebuild/recreate path +
canonicalize credential resolution). It is intentionally scoped to pure
code movement with no behavior changes.

Rebased onto current main. Supersedes #2087 and #2489.

---

## Summary

Steps 1–3 of the original extraction plan (authored by @ericksoa in
#2087):

- Extract `onboard-providers.ts` — provider metadata, CRUD, labels,
inference config
- Extract `onboard-ollama-proxy.ts` — proxy lifecycle, model
pull/validate
- Extract `onboard-inference-probes.ts` — endpoint validation probes
(OpenAI, Anthropic, Gemini)

Reduces `onboard.ts` by ~1,000 lines. All 3 new modules are under 400
lines. No behavior changes — all existing exports remain accessible via
re-exports and thin wrappers.

**Step 4 (dashboard extraction) was dropped** — main already landed
`dashboard-contract.ts`, `dashboard-health.ts`, and
`dashboard-recover.ts` (#2398) which supersede that extraction.

Steps 5–10 (gateway, preflight, messaging, policies, inference-setup,
sandbox) remain deferred per the original plan.

## Downstream: #2306

`#2306` (extract rebuild/recreate path + canonicalize credential
resolution) builds directly on top of this PR. It imports
`REMOTE_PROVIDER_CONFIG`, `upsertProvider`, and `ensureOllamaAuthProxy`
from the new extracted modules via onboard.ts re-exports. Merging this
PR first gives #2306 a clean module surface to build on.

## CodeRabbit comments

All 6 comments addressed:
- 1 resolved (deleted planning doc)
- 4 are valid improvements on **pre-existing code** that was moved as-is
— intentionally out of scope for a pure extraction PR, flagged as
follow-up material
- 1 is incorrect (`upsertMessagingProviders` was never exported on main)

## Rebase notes

- Ported all main-side refinements into the extracted modules (e.g.,
`startOllamaAuthProxy` now returns `boolean`, `getProbeAuthMode` always
returns `undefined`)
- Added type annotations for the CJS `require()` imports to satisfy
strict TypeScript
- Re-imported endpoint URL constants that `onboard.ts` still references
after extraction

## Test plan

- [x] `npx tsc -p tsconfig.src.json --noEmit` compiles cleanly
- [x] `npx tsc -p tsconfig.cli.json --noEmit` compiles cleanly
(pre-existing failures only, same as main)
- [x] Affected tests pass: gemini-probe-auth, credential-exposure,
wsl2-probe-timeout
- [x] CI: all 15 checks green
- [ ] Manual smoke test: `nemoclaw onboard` completes successfully

Co-authored-by: Aaron Erickson <aerickson@nvidia.com>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Reorganized onboarding logic into modular utilities for improved code
maintainability and separation of concerns.
* Separated provider management, inference endpoint validation, and
Ollama proxy lifecycle into dedicated modules.

* **Tests**
  * Updated tests to reflect new code organization structure.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Aaron Erickson <aerickson@nvidia.com>
DemianHeyGen pushed a commit to DemianHeyGen/NemoClaw that referenced this pull request Apr 30, 2026
…d) (NVIDIA#2495)

## ⚡ Interim PR — Unblocks NVIDIA#2306

This is an **interim extraction PR** that lands the foundational module
decomposition needed by NVIDIA#2306 (extract rebuild/recreate path +
canonicalize credential resolution). It is intentionally scoped to pure
code movement with no behavior changes.

Rebased onto current main. Supersedes NVIDIA#2087 and NVIDIA#2489.

---

## Summary

Steps 1–3 of the original extraction plan (authored by @ericksoa in
NVIDIA#2087):

- Extract `onboard-providers.ts` — provider metadata, CRUD, labels,
inference config
- Extract `onboard-ollama-proxy.ts` — proxy lifecycle, model
pull/validate
- Extract `onboard-inference-probes.ts` — endpoint validation probes
(OpenAI, Anthropic, Gemini)

Reduces `onboard.ts` by ~1,000 lines. All 3 new modules are under 400
lines. No behavior changes — all existing exports remain accessible via
re-exports and thin wrappers.

**Step 4 (dashboard extraction) was dropped** — main already landed
`dashboard-contract.ts`, `dashboard-health.ts`, and
`dashboard-recover.ts` (NVIDIA#2398) which supersede that extraction.

Steps 5–10 (gateway, preflight, messaging, policies, inference-setup,
sandbox) remain deferred per the original plan.

## Downstream: NVIDIA#2306

`NVIDIA#2306` (extract rebuild/recreate path + canonicalize credential
resolution) builds directly on top of this PR. It imports
`REMOTE_PROVIDER_CONFIG`, `upsertProvider`, and `ensureOllamaAuthProxy`
from the new extracted modules via onboard.ts re-exports. Merging this
PR first gives NVIDIA#2306 a clean module surface to build on.

## CodeRabbit comments

All 6 comments addressed:
- 1 resolved (deleted planning doc)
- 4 are valid improvements on **pre-existing code** that was moved as-is
— intentionally out of scope for a pure extraction PR, flagged as
follow-up material
- 1 is incorrect (`upsertMessagingProviders` was never exported on main)

## Rebase notes

- Ported all main-side refinements into the extracted modules (e.g.,
`startOllamaAuthProxy` now returns `boolean`, `getProbeAuthMode` always
returns `undefined`)
- Added type annotations for the CJS `require()` imports to satisfy
strict TypeScript
- Re-imported endpoint URL constants that `onboard.ts` still references
after extraction

## Test plan

- [x] `npx tsc -p tsconfig.src.json --noEmit` compiles cleanly
- [x] `npx tsc -p tsconfig.cli.json --noEmit` compiles cleanly
(pre-existing failures only, same as main)
- [x] Affected tests pass: gemini-probe-auth, credential-exposure,
wsl2-probe-timeout
- [x] CI: all 15 checks green
- [ ] Manual smoke test: `nemoclaw onboard` completes successfully

Co-authored-by: Aaron Erickson <aerickson@nvidia.com>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Reorganized onboarding logic into modular utilities for improved code
maintainability and separation of concerns.
* Separated provider management, inference endpoint validation, and
Ollama proxy lifecycle into dedicated modules.

* **Tests**
  * Updated tests to reflect new code organization structure.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Aaron Erickson <aerickson@nvidia.com>
cv pushed a commit that referenced this pull request May 5, 2026
…fixes (#3052)

## Summary

Adds `nemoclaw-maintainer-pr-comparator`: an autonomous skill that picks
the merge winner among competing PRs targeting the same issue. Runs Tier
0 plumbing gates → Tier 1 correctness checks → Tier 2 quality checks →
Tier 3 deterministic ranking. Degraded mode handles the case where no PR
passes gates.

## Why

When two contributors fix the same issue, deciding which to merge is
judgment-heavy. This skill makes that judgment deterministic,
explainable, and reusable across repos.

## What's clever (catches what CI can't)

- Reads each new test against the pre-fix code to verify the test would
have failed (catches smoke-test fakes)
- Parses issue body **and comments** for acceptance criteria (catches
"and don't break Y while you're at it")
- Refactor-vs-behavior scan flags hidden behavior changes inside what
looks like a rename
- Mocking-purity check catches tests that mock the unit under test
- Public-surface preservation flags content changes (not moves) in
flags/help/errors
- Workaround-vs-root-cause check flags symptom-suppressing try/catch
fixes without follow-up
- Behavior-coverage matrix recommends "merge A, cherry-pick B's tests
for criterion X" when no PR dominates
- Degraded mode picks closest-to-ready when neither passes gates instead
of giving up

## Validation

Backtested against 5 historical NemoClaw cases (#2681, #2947, #893,
#2636, refactor chain #2087/#2489/#2495). Initial v1: 4/5. After patches
(PR-state-OPEN gate, supersession detection, workaround-vs-root-cause
flag): 5/5.

## Skill structure (per Claude best-practices)

Slim SKILL.md (orchestration), tier checks in one-level-deep reference
files, output template extracted, five utility scripts for the
deterministic work, repo-specific assumptions in repo-policy.md for
cross-repo reuse.

```
.agents/skills/nemoclaw-maintainer-pr-comparator/
├── SKILL.md                        # orchestration only
├── repo-policy.md                  # configurable per-repo defaults
├── tiebreakers.md                  # Tier 3 + degraded mode
├── checks/
│   ├── tier-0-gates.md
│   ├── tier-1-correctness.md
│   └── tier-2-quality.md
├── templates/verdict.md
├── validation/backtest.md
└── scripts/
    ├── find-candidates.sh
    ├── collect-gates.sh
    ├── check-coderabbit-threads.sh   # GraphQL on reviewThreads.isResolved
    ├── parse-supersession.sh
    └── render-verdict.py
```

## Test plan

- [x] markdownlint clean
- [x] shellcheck clean
- [x] python compiles
- [x] Backtest 5/5 on historical cases
- [ ] Try the skill on a live duplicate-PR situation when one arises

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a user-invocable PR comparison skill to evaluate competing PRs,
run multi-tier gates, score/rank candidates, and output a recommended
merge verdict with evidence and trace.
* Added CLI helpers for candidate discovery, gate collection,
supersession detection, thread checks, and verdict rendering.

* **Documentation**
* New repo policy, tiered-check rubrics (Tier 0–3), verdict template,
and backtest/validation guides for ongoing tuning.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor PR restructures code without intended behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants