Skip to content

feat(orchestration): reject a worker-start --model the host's CLI does not list - #19937

Open
brennanb2025 wants to merge 8 commits into
mainfrom
brennanb2025/reject-unknown-model-at-worker-start
Open

brennanb2025 wants to merge 8 commits into
mainfrom
brennanb2025/reject-unknown-model-at-worker-start

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Before Orca creates a Claude worker, it now asks the machine that will run that worker which model IDs its installed Claude CLI accepts. A typo is rejected with the accepted IDs instead of allocating a worker terminal that immediately dies.

What Changed

  • Added a pre-allocation model-authority check for local, WSL, SSH, folder-workspace, explicit-repository, inherited-coordinator, and federated worker placement.
  • Accepts the CLI's listed IDs, resolved full IDs, stable Claude aliases, and the valid default launch alias.
  • Rejects only when the executing host returns a complete live catalog. Failed/unavailable discovery, customized terminal args/env, and non-authoritative catalogs remain pass-through so the provider CLI owns the verdict.
  • Uses one 10-second dispatch budget for host resolution plus discovery, with success-only three-minute caching and in-flight probe coalescing.
  • Scopes cached Claude catalogs to the agent, execution host, configured command, active account, and re-auth timestamp; a result is discarded if the account changes during discovery.
  • Keeps resolvedModel optional for mixed-version compatibility and leaves existing effort validation unchanged.

Why

The failure mechanism was an unchecked model string reaching irreversible worker allocation. Validation now lives at the execution-owner boundary and runs before database, worktree, or terminal effects. This also prevents local discovery from being treated as authority for a remote worker.

Linked Issue

Supersedes #19682. There is no separate issue for this focused extraction.

Visual Proof

The first image shows the final merged branch rejecting an unknown model and worker-list reporting zero allocated workers. The next two cover acceptance of a stable alias and a resolved full model ID.

Electron validation

Unknown model rejected before allocation Stable alias accepted
Unknown model rejected before allocation Stable alias accepted
Resolved full model ID accepted
Resolved full model ID accepted

Testing

  • Hidden/background Electron validation through Playwright CDP on macOS: unknown Claude ID returned invalid_argument, named the executing host's accepted IDs, and left worker-list empty; the renderer logged zero errors.
  • Accepted Claude alias and resolved-model regression flows exercised with the installed provider CLI; disposable workers were stopped and released.
  • Worker suite: 337 tests across 39 files.
  • Focused cross-layer integration: 64 tests across 6 files.
  • Final readiness run: 236 tests across 14 files.
  • pnpm tc, changed-code quality, git diff --check, CLI build, and relay build.
  • Live Windows/WSL execution was not run locally; CI and focused platform/routing tests cover those paths.
  • A disposable Ubuntu SSH relay connected, but the desktop connect call did not settle, so this review does not claim an end-to-end SSH worker rejection run.

AI Disclosure

Review

Independent same-model review/fix/re-review completed clean on the final merged commit. The review explicitly covered root cause, placement ownership, account/cache isolation, failure behavior, resource cleanup, mixed versions, cross-platform/remoting, and performance bounds.

Agent skill upstream boundary

  • Not applicable; this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • No mobile-facing code, state, routes, or contracts changed; mobile emulator QA is not applicable.
  • No new dependency, persistence schema, polling loop, platform-specific process API, or required wire field was added.
  • The public model set is intentionally broader than picker rows because valid launch-only aliases and resolved full IDs must remain accepted.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • Targeted lint/code-quality, typecheck, tests, and relevant builds pass; CI covers the repository-wide matrix

…s not list

`worker-start --model <id>` previously passed any id straight to the agent
launch, so a typo or a retired id produced a terminal that died on startup with
no explanation from Orca.

Ask the host that will actually run the worker. `resolveWorkerLaunchModelAuthority`
reuses the probe the native chat model picker already uses
(`discoverRuntimeCommitMessageModels`), which routes local / WSL / SSH from the
worktree selector, so the set `worker-start` accepts is the set the picker lists.

Three limits keep the gate honest:

- It refuses only when the authority's `source` is `live` — the host's CLI
  actually answered. A seed fallback (probe failed, timed out, or fell back to
  Orca's own list) accepts the id and lets the agent CLI report: loss of contact
  is never evidence that a model does not exist there
  (`docs/reference/ssh-execution-boundary.md`).
- Strictness follows `discoveredModelsReplaceSeed`. Claude and
  `discoveredModelsAreAuthoritative` catalogs replace the seed, so their lists
  are complete and may refuse. Codex, Gemini and Cursor only extend the seed —
  their lists depend on the account and are not exhaustive — so they are not
  probed at all and refuse nothing.
- Effort validation stays the catalog's, unchanged. A probe reports membership
  only, so its generic level list can never narrow a seeded model's menu.

The probe is cached per executing host (`local` / `wsl:<distro>` / `ssh:<id>`)
rather than per caller, since one machine's CLI list is one fact; failures are
never cached, and a dispatch that gives up on its 10s budget leaves the probe
running to fill the cache for the next one.

The rejection names the agent, the refused id, and the sorted ids the host
listed — never a built-in list presented as authoritative.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Reviewed the full diff (16 files, 1 commit) end to end.

  • Worker-start model authority gate — worker-start --model now probes the agent CLI on the executing host and rejects an id that host does not list, naming the accepted ids in the error.
  • Shared replace-vs-extend policy — discoveredModelsReplaceSeed and resolveDiscoveredCatalogModels are extracted so the native-chat picker and the worker-start gate read the same catalog policy; only live answers (claude + authoritative catalogs) may reject.
  • Host-keyed discovery cache — probe results are cached per executing host (local / wsl:<distro> / ssh:<id>) with a 3-minute TTL, no failure caching, and in-flight dedup; a dispatch that exhausts its 10s budget leaves the probe running to fill the cache.
  • Runtime git surface — a new resolveRuntimeCommitMessageDiscoveryHostKey method, plus prepareLocalWorkerStart / prepareFederationAttachmentWorkerStart become async; the resolved callerWorktreeId is reused so a --model dispatch pays one showTerminal round trip instead of two.
  • Tests — worker-launch-model-authority.test.ts and worker-start-validation.test.ts pin the authority/cache semantics and the placement → selector mapping.

I verified the resolveDiscoveredCatalogModels extraction is behavior-preserving against the original inline branch in native-chat-session-option-enrichment.ts (claude replaces, authoritative merges, otherwise unions), discoveredModelsReplaceSeed matches the picker's discovery gate exactly, and the catalogOrigin === 'probe' guard correctly distinguishes a live CLI answer from a spec fallback. The tests use exact assertions and would fail with the gate removed or loosened.

ℹ️ Cold-start probe latency (mergeable as-is)

The first worker-start --model on a host now awaits a foreground CLI probe before creating the worker, bounded at 10s. The renderer picker's separate enrichmentByAgentHost cache does not warm the new cachedByHost map, so a cold host pays a full listModels round trip on the first dispatch (and a slow WSL/SSH host can stall for the full budget). This is a deliberate, documented tradeoff and the fallback is safe — noting it only for awareness, not as a blocker.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview 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

The change adds host-specific model discovery targets and host-key resolution for local, remote, repository, and folder-workspace launches. Worker-start validation now applies live model authority, resolved model IDs, aliases, account-aware caching, shared discovery deadlines, and seed fallbacks. Local and federated preparation now awaits asynchronous validation. Claude model metadata carries resolved IDs, and catalog reconciliation is centralized. Tests cover discovery, caching, placement, validation, and dispatch behavior.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 82eeb

A single hung model-discovery request can cause later worker starts on that host to skip live model validation until restart. Fix this before merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 30 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the primary change: rejecting worker-start model IDs that the executing host's CLI does not list.
Description check ✅ Passed The description covers the required sections, explains the change and rationale, documents testing and limitations, provides visual proof, and addresses platform and compatibility considerations. It l…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: e8b8359f-4ca9-4f32-a148-439308547b96

📥 Commits

Reviewing files that changed from the base of the PR and between fb85f88 and 46dfcb7.

📒 Files selected for processing (16)
  • src/cli/specs/orchestration-worker-specs.ts
  • src/main/runtime/orca-runtime-git.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation.ts
  • src/main/runtime/rpc/methods/orchestration/worker/composed-workers.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/local-worker-start.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-model-authority.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-model-authority.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-preferences.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-preferences.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-validation.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-validation.ts
  • src/main/runtime/rpc/methods/orchestration/worker/workers-new-worktree.test.ts
  • src/main/runtime/runtime-git-command-surface.ts
  • src/main/runtime/runtime-git-generation-commands.ts
  • src/renderer/src/components/native-chat/native-chat-session-option-enrichment.ts
  • src/shared/agent-session-option-catalog.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Reviewed the incremental delta of 81405ed over the previously reviewed 36015ff.

  • Stable CLI aliases accepted alongside the live list — the reject gate now admits the four seeded Claude aliases (fable / opus / sonnet / haiku) when the host lists them or a bracket-qualified variant, plus each listed model's resolvedModel full id, so a valid --model opus is no longer refused when the CLI only lists opus[1m].
  • Destination-repo probing — WorkerLaunchModelDiscoveryTarget now also accepts { repoSelector }, so new-child / new-top-level placements (local and federated) probe the host that will actually create the worktree instead of the coordinator's host or none.
  • Unified discovery budget — the single 10s deadline now covers host-key resolution and the CLI probe together, closing the previously unbounded host-resolve window.
  • resolveRuntimeModelDiscoveryTarget — a new optional host seam resolves cwd + executionHostId from a repo or folder workspace, decoupling model discovery from an existing Git worktree.

Verified the alias matcher cannot over-admit (the [...] prefix guard prevents family-name prefix collisions, and a non-family id such as claude-opus-5 is still refused against the resolved claude-opus-5[1m]), that only Claude reaches the live gate (grok is authoritative but lacks supportsWorkerLaunchPreferences, so it throws "does not support launch-time model selection" first), and that { repoSelector } never crosses the RPC wire (git.discoverCommitMessageModels still takes a string params.worktree); the new resolvedModel field is additive on non-strict settings schemas. Tests use exact assertions and would fail with the gate loosened.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Reviewed the incremental delta of 9a09d30 over the previously approved 81405ed (316c5f2 was a pure base merge).

  • Command override threaded into the probe — resolveWorkerLaunchModelAuthority now forwards settings.agentCmdOverrides?.[agent] as agentCmdOverrides to discoverRuntimeCommitMessageModels, so the gate queries the CLI invocation that will actually run rather than the stock binary.
  • Terminal-only customization skips rejection — when getClientSettings() is unavailable or hasExplicitTuiLaunchCustomization flags default args/env the probe cannot see, the gate is skipped and the id is accepted, since a probe answer that omits that customization is not evidence about the actual launch.
  • default admitted as a launch alias — the Claude catalog gains launchModelAliases: ['default'], because list_models publishes default but picker discovery drops the mirror row; --model default is no longer wrongly refused.
  • Cache scope widened — the discovery cache is now keyed by (agent, host, command override) instead of (agent, host), so two different overrides on one host no longer share a single CLI fact.

Verified the empty-override path is safe (planAgentBinary treats '' as "no override", and the ?? fallback in discoverRuntimeCommitMessageModels is bypassed only with the same value the caller already read from the shared settings store), that the common no-customization case still probes (default args/env resolve to {}/undefined, so hasExplicitTuiLaunchCustomization returns false), and that default is only admitted for Claude (it is the sole catalog setting launchModelAliases). Tests pin the override threading, the terminal-customization skip, the distinct-per-override cache, and the default membership.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@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.

Caution

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

⚠️ Outside diff range comments (1)
src/main/runtime/rpc/methods/orchestration/worker/worker-launch-model-authority.ts (1)

242-242: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Evict timed-out discovery promises.

When withDiscoveryDeadline(pending, deadlineAt) returns DISCOVERY_BUDGET_EXPIRED, inFlightByScope still points to pending. A later launch with the same scope reuses that promise, returns seed authority after its own deadline, and never starts a new probe. Because resolveWorkerLaunchPreferences rejects only live authority, those launches skip host model validation.

Remove the entry when the deadline expires, but only if it still maps to pending. Also guard the settlement handler before deleting or caching, so a late completion cannot remove or overwrite a replacement. Add a regression test with a first probe that never settles and a second probe that succeeds.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 2e65ba9a-9f63-4785-81a4-4bc221ea2072

📥 Commits

Reviewing files that changed from the base of the PR and between 7417b6c and 82eeb06.

📒 Files selected for processing (3)
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-model-authority-account-cache.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-model-authority.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-model-authority.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/runtime/rpc/methods/orchestration/worker/worker-launch-model-authority.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Reviewed the incremental delta of d2f7168 over the previously approved 9a09d30 (the two Merge origin/main commits in between carry no PR-owned changes).

  • Discovery cache scoped to Claude account identity — the probe cache key now includes an auth scope derived from getAccountsSnapshot().claude: the active account id plus its updatedAt (re-auth bumps updatedAt, so it invalidates membership too), resolved per executing host (activeAccountId for local, activeAccountIdsByRuntime.wsl[distro] for WSL). SSH hosts and non-Claude agents are not account-scoped, since local managed-account state does not govern an SSH host's CLI. When the account identity is unavailable the answer still rejects for the current launch but is not persisted.
  • Mid-flight account switch discards the answer — the post-probe scope is recomputed and compared against the pre-probe scope; if an account switch or re-auth landed while the probe ran, the answer is dropped and the launch seeds, so a stale list from account A is never applied to account B.
  • Account-cache test suite — worker-launch-model-authority-account-cache.test.ts pins account switch, re-auth, WSL distro selection, SSH isolation, unavailable-identity no-persistence, and the mid-flight-switch discard.

Verified resolveDiscoveryAuthScope's host-key handling matches the account subsystem (snapshot().activeAccountId is normalizeClaudeRuntimeSelection().host, so local and .host agree; WSL keys are bare distro names and hostKey.slice(4) strips wsl:), the getAccountsSnapshot().claude shape (accounts carries updatedAt, activeAccountIdsByRuntime models host/wsl only), and that resolveRuntimeCommitMessageDiscoveryHostKey produces the same wsl:<distro> / ssh:<id> vocabulary. The tests use exact assertions and would fail with the scoping removed.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review complete on 82eeb06f907382e3c538f8719365f8e9f21b3747 (including main through fb9ba4b681512adc00052b97e1b36c05dc8c58bc). Status: clean and mergeable.

Meaningful review fixes now in the branch:

  • Validate against the actual execution owner for existing/folder/explicit-repository/federated launches, with one 10-second budget covering host resolution and discovery.
  • Accept valid Claude aliases, default, and resolved full model IDs while rejecting only from complete live catalogs.
  • Fail open when discovery cannot represent customized launch args/env or the provider catalog is incomplete/unavailable.
  • Scope successful discovery caching by agent, execution host, configured command, active Claude account, and re-auth timestamp; discard an in-flight result if the account changes.
  • Keep rejection before database, worktree, terminal, or worker allocation effects.

Validation:

  • Independent same-model review/fix/re-review loop: clean.
  • Initial and final readiness audits: pass, no P0/P1/P2 findings.
  • 337 worker tests across 39 files; 64 focused cross-layer tests across 6 files; final readiness run covered 236 tests across 14 files.
  • pnpm tc, changed-code quality, CLI/relay builds, and git diff --check: pass.
  • Final-head CI: all applicable checks green, including all eight test shards, typecheck, static analysis, macOS/Ubuntu/Windows native smoke, and macOS/Windows packaging.
  • Hidden Electron/CDP validation on the final branch: an unknown Claude model returned invalid_argument, listed the executing host's accepted IDs, and worker-list remained empty. Stable alias and resolved-full-ID acceptance were also exercised. Screenshots are attached in the PR description. Renderer console: zero errors.
  • No mobile-facing behavior changed; emulator QA is not applicable.

Remaining QA gaps:

  • The requested Grok orchestration worker was started with the exact Grok agent, but its weekly quota was exhausted before QA began. It was stopped and released; the orchestration run has no active or reclaimable worker resources. The Electron evidence was completed locally instead.
  • A disposable Ubuntu SSH host accepted the key and Orca relay, but the desktop connect call did not settle, so I am not claiming a live end-to-end SSH worker-start rejection. SSH/federated ownership is covered by focused tests and independent review.
  • No manual WSL run was performed; platform behavior is covered by focused tests and the final-head Windows/Ubuntu CI smoke and packaging jobs.

This branch has not been deployed

No deployments
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.

1 participant