Skip to content

refactor(agent-launch): retire the duplicate worker-start mode decision - #20911

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/retire-duplicate-worker-start-mode
Sep 16, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/retire-duplicate-worker-start-mode

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 0
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39 $\color{#cf222e}{\Huge{\mathbf{−}}}$​175 $\color{#cf222e}{\Huge{\mathbf{−}}}$​136

What this does

main currently ships two implementations of one decision:

They are parallel twins — WorkerStartMode/AgentLaunchMode, WorkerStartModeReason/AgentLaunchModeReason, WorkerStartModeReceipt/AgentLaunchModeReceipt, decideWorkerStartMode/decideAgentLaunchMode, downgradeWorkerStartModeForHost/downgradeAgentLaunchModeForHost, readWorkerStartModeSettings/readAgentLaunchModeSettings — with the same ten-member reason vocabulary in the same order, and nothing enforcing that they agree.

This reduces the orchestration module to an 82-line adapter over the shared one. It keeps WORKER_START_VOCABULARY so orchestration's receipts read exactly as they do today.

This recovers a cutover that was already written: commit f34d08a452 ("refactor(agent-launch): make the launch-mode decision surface-neutral"). A later merge resolved that file in favour of main's side, so the deletion half was dropped while the two added files survived. The adapter committed here is byte-identical to the blob from that commit (9cd9f51e0ac6) — verified by git hash-object.

What I verified

API compatibility. Every import the adapter names still exists on the shared module with a compatible signature: decideAgentLaunchMode({placement, settings, vocabulary?}), resolveAgentLaunchModeOnHost(runtime, receipt, worktreeId, agent, vocabulary?), downgradeAgentLaunchModeForHost(receipt, support, vocabulary?), readAgentLaunchModeSettings(runtime), plus the exported types AgentLaunchMode, AgentLaunchModeReason, AgentLaunchModeReceipt, AgentLaunchModeSettings, AgentLaunchModeVocabulary. No adaptation was needed; the shared module is unchanged by this PR.

No behavioural divergence. I diffed the two implementations with the type renames normalized. The reason union (all ten members, same order), BLOCKER_REASON, HOST_SUPPORT_REASON, and every branch of the control flow are identical. The only substantive differences are the vocabulary parameterization and two DOWNGRADE_DETAIL strings:

reason orchestration shared default restored by
remote_execution_host this worker runs on a remote execution host this launch runs on a remote execution host detailOverrides
reused_terminal --terminal reuses a running terminal agent it reuses a running terminal agent detailOverrides

WORKER_START_VOCABULARY overrides exactly those two, and supplies the worker nouns. The other seven downgrade details were already identical.

Consumers. All importers of the orchestration module type-check unchanged:

  • src/main/runtime/rpc/methods/orchestration/worker/workers.ts — decideWorkerStartMode, readWorkerStartModeSettings
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-agent-placement.ts — resolveWorkerStartModeOnHost, WorkerStartModeReceipt
  • src/main/runtime/rpc/methods/orchestration/worker/local-worker-start.ts — resolveWorkerStartModeOnHost, WorkerStartModeReceipt
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-receipt.ts — WorkerStartModeReceipt
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-readiness-settlement.ts — WorkerStartModeReceipt
  • orchestration-worker-start-mode.test.ts, orchestration-worker-start-receipt-wording.test.ts, orchestration-worker-support-unknown.test.ts
  • tests/e2e/structured-native-chat-routing-authority.unit.test.ts — decideWorkerStartMode

The one type the adapter stops declaring, WorkerStartModeSettings, was never exported and has no consumer outside the module.

Wording pin. orchestration-worker-start-receipt-wording.test.ts passes unchanged in its assertions — every sentence in a dispatch receipt is identical to what main produces today.

Ablation. With the adapter in place, corrupting WORKER_START_VOCABULARY one field at a time. Each edit asserts it matched exactly once, so a substitution that silently matched nothing cannot pass as an arm.

arm wording test
control (pristine adapter) 11 passed (11)
A — structured noun corrupted 1 failed, 10 passed
B — terminal noun corrupted 9 failed, 2 passed
C — remote_execution_host override dropped 2 failed, 9 passed
D — reused_terminal override dropped 1 failed, 10 passed

Arms C and D are the load-bearing ones: they show that if the adapter had simply taken the shared module's default wording, the pin catches it.

Typecheck. pnpm tc exits 0. I confirmed the gate actually covers this file rather than reporting a vacuous pass: injecting export const TYPECHECK_CANARY: number = "not a number" produced error TS2322 under tsconfig.node.json and exit 1.

Tests. src/main/runtime/rpc/methods/orchestration + src/main/agent-launch + the four worker-start suites + the e2e routing-authority unit test: 87 files, 799 tests, 0 failing, 0 skipped. The six directly-affected suites were 69/69 before this change and 69/69 after.

Quality gates. pnpm run check:code-quality:changed — 0 new findings across 3 changed files (code quality, casting, type-aware, React Doctor, design system, casting SAFETY rationale). oxlint clean. No max-lines disable added; the module shrinks 217 → 82 lines.

Comment updates

Two comments on main assert the duplication still exists and become false with this change. Prose only — no test assertion was touched:

  • agent-launch-executor.ts said the mode decision "is duplicated rather than shared … with nothing enforcing agreement between them. That cutover is later stack work too."
  • The wording test's header said "This pins orchestration's own module, which this PR leaves in place … nothing yet enforces that the two agree." It now records that the shared default wording differs for the remote-host and reused-terminal downgrades and that only WORKER_START_VOCABULARY restores it.

`orchestration-worker-start-mode` becomes a thin adapter over
`agent-launch/agent-launch-mode`, which already owns the same decision.
Orchestration keeps its receipt vocabulary via WORKER_START_VOCABULARY, so
every sentence a dispatch receipt prints is unchanged.

Recovers the cutover written in f34d08a, which a later merge resolved in
favour of main's side; the two added files survived, the deletion half did not.
@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 46770061-9555-4dfa-b904-c7f8b7cd42db

📥 Commits

Reviewing files that changed from the base of the PR and between 6da7238 and 0462795.

📒 Files selected for processing (3)
  • src/main/agent-launch/agent-launch-executor.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-mode.ts
  • src/main/runtime/rpc/methods/orchestration-worker-start-receipt-wording.test.ts

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


📝 Walkthrough

Walkthrough

orchestration-worker-start-mode now uses the shared agent-launch-mode types, decision functions, host handlers, and settings reader. It supplies WORKER_START_VOCABULARY for orchestration-specific receipt wording. The previous local feasibility logic, support helper, reason maps, and settings type were removed. Related module and test comments now describe the adapter structure.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to f1f3c

No actionable regression is established in the worker launch-mode adapter; the change is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the implementation, compatibility, wording preservation, and verification results in detail. However, it omits several required template sections, including ELI5, Linked Issue… Update the description to follow the repository template. Add an ELI5 section, a Why section, the required Linked Issue with an issue reference, Visual Proof with exactly N/A and a reason because this is not a UI change, Testing checklist s…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: retiring the duplicate worker-start mode decision implementation.
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.
Full details: Description check

Explanation

The description explains the implementation, compatibility, wording preservation, and verification results in detail. However, it omits several required template sections, including ELI5, Linked Issue, Visual Proof with N/A justification, Review, Agent skill upstream boundary, Notes, and the required checklist items.

Resolution

Update the description to follow the repository template. Add an ELI5 section, a Why section, the required Linked Issue with an issue reference, Visual Proof with exactly N/A and a reason because this is not a UI change, Testing checklist status, AI Disclosure if applicable, Review, Agent skill upstream boundary, Notes, and the remaining checklist items.

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

@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

  • Orchestration now delegates the mode decision — orchestration-worker-start-mode.ts shrinks 217 → 82 lines, with decideWorkerStartMode, resolveWorkerStartModeOnHost, downgradeWorkerStartModeForHost and readWorkerStartModeSettings forwarding to the shared agent-launch/agent-launch-mode.
  • WORKER_START_VOCABULARY restores the exact receipt wording — supplies the worker nouns plus detailOverrides for remote_execution_host and reused_terminal, the only two downgrade strings where the shared default differs.
  • Types become aliases — WorkerStartMode / WorkerStartModeReason / WorkerStartModeReceipt alias the shared AgentLaunchMode* types; the never-exported WorkerStartModeSettings is dropped in favour of the structurally identical AgentLaunchModeSettings.
  • Two stale “duplication still exists” comments corrected — in agent-launch-executor.ts and the receipt-wording test header. No assertion changed; agent-launch-mode itself is untouched.

I independently confirmed the load-bearing claims: the adapter file hashes to 9cd9f51e0ac63d0c411951bee9979ca15772f80f (the byte-identical recovered blob), the old and new reason union / BLOCKER_REASON / HOST_SUPPORT_REASON / control flow and all nine downgrade strings match under the vocabulary overrides, and the four affected suites pass (47/47). Consumers across the workers path remain type-compatible.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron proof (review-only, isolated profile)

Launched this PR worktree with ORCA_BACKGROUND_LAUNCH=1, isolated ORCA_DEV_USER_DATA_PATH, and CDP 9333. Identity via window.api.app.getIdentity(): Orca: brennanb2025/retire-duplicate-worker-start-mode-2 (isDev: true, branch brennanb2025/retire-duplicate-worker-start-mode-2).

Visible surface: Settings → Experimental. Configured the disposable structured-chat preference through the app UI:

  • Chat UI on
  • Default view = Chat UI
  • Use updated structured native chat on

Store confirmed experimentalNativeChat, openAgentTabsInChatByDefault, and experimentalStructuredNativeChat are all true. The running main bundle source map contains WORKER_START_VOCABULARY and the worker-specific receipt strings (a structured chat session worker, this worker runs on a remote execution host, --terminal reuses a running terminal agent).

Gap: orchestration.workerStart itself was not exercised. The isolated profile has no projects; adding one via the UI requires a native folder picker, and starting a routine worker still needs a coordinator terminal bound to a Task Run, which would spawn a live agent. Orchestration settings only expose skill coverage and nested-worker depth, not a dispatch receipt.

pr20911-structured-chat-preference.png

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: LAND

The review/fix loop completed clean in one full round, followed by an independent re-audit and start/end readiness passes. No proven P0, P1, or P2 issue remains, and no production or test change was warranted.

Architecture and correctness

  • agent-launch-mode is now the single owner of the launch-mode decision.
  • orchestration-worker-start-mode is a compatibility adapter that preserves orchestration's public types and worker-specific receipt vocabulary.
  • Settings fallback, every blocker/reason mapping, the id: host-support lookup, unknown/refused host behavior, no-worktree short-circuit, and exact receipt wording remain equivalent to the pre-refactor implementation.
  • The latest origin/main advanced during review, but no new upstream commit touched these files. The refactor merge gate reports zero unexplained deletions, extra residue, or unrelated files.

Reliability and compatibility

  • Invariant: worker launch mode, reason, detail, and host fallback remain identical while policy has one owner.
  • Oracle: exact wording pins plus mode, placement, host-support, executor, federation, and structured-start tests.
  • Remote/WSL refusal reasons remain covered; there is no mobile-facing wire, persisted-state, schema, dependency, path, shell, or provider contract change.
  • The performance audit found no added polling, timers, listeners, retries, subprocesses, render work, caches, or retained resources.
  • Dispatch receipts retain reason and detail, preserving the existing diagnostic surface.

Validation

  • Start readiness: 10 affected test files, 89 tests passed.
  • Closing readiness: 4 focused files, 46 tests passed.
  • Independent reviewers reran focused 50-, 63-, and 37-test selections.
  • pnpm tc, pnpm tc:node, pnpm run check:code-quality:changed, and git diff --check passed.
  • GitHub CI is green, including the Windows package job and all eight test shards.
  • The merge validation script reports unexplainedDeletions: 0, extra: [], and unrelatedFiles: [].

Electron proof

An isolated background Electron run verified the exact PR worktree identity, enabled the real structured-chat preference through Settings → Experimental, confirmed the compiled worker vocabulary, and found no relevant console/app errors.

pr20911-structured-chat-preference.png

Residual validation gap: the disposable profile did not execute orchestration.workerStart itself because doing so required adding a project and spawning a live agent. The deterministic launch-mode and host-settlement suites cover that behavior; this is an evidence gap rather than a proven defect.

No review fix was necessary, so the PR head remains f1f3cc875f.

@brennanb2025
brennanb2025 merged commit 357c978 into main Sep 16, 2026
28 checks passed
brennanb2025 added a commit that referenced this pull request Sep 16, 2026
#20911 retired the duplicated launch-mode policy, so main now describes
`agent-launch-mode` as the single owner with `orchestration-worker-start-mode`
as a thin adapter over it.

The executor did NOT conflict. Main's only change there is the module header
prose (lines 3-12); every change this branch makes to that file starts at line
81, so the two auto-merged cleanly. Verified both halves survived rather than
assuming: main's "shared, not copied" wording is present, the stale "duplicated
rather than shared" wording is gone, and combineLaunchWarnings is intact.

Fifteen mobile RPC goldens conflicted, all on recorderSha256/adapterSha256 plus
value-pool entries. Both sides had legitimately re-recorded them - this branch
for the getAgentLaunchSupport adapter, main for its own new recordings - so
NEITHER side's hashes are correct for the merged source and picking a side is
wrong in both directions. Resolved by re-recording instead.

Seeded from main's side deliberately, so a re-record that failed to run would
drop this branch's agentLaunch fields and fail loudly rather than silently
keeping stale local values.

The re-record touched 16 files, not the whole corpus: the 15 conflicted plus
tw-capabilities-cutover-retried.json, which auto-merged but still needed its
hash refreshed. Proven behaviour-preserving by comparing added and removed
content lines as multisets, with pool keys and hash fields normalised out:

  added 127 / removed 119 content lines
  net added:   8x  "agentLaunch": false
  net removed: none

So every value main recorded is preserved, and the only semantic delta is this
branch's own adapter field. Goldens then re-validated in normal (non-record)
mode: 17 files, 793 passed.
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…on (stablyai#20911)

`orchestration-worker-start-mode` becomes a thin adapter over
`agent-launch/agent-launch-mode`, which already owns the same decision.
Orchestration keeps its receipt vocabulary via WORKER_START_VOCABULARY, so
every sentence a dispatch receipt prints is unchanged.

Recovers the cutover written in f34d08a, which a later merge resolved in
favour of main's side; the two added files survived, the deletion half did not.
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