Repository navigation
feat(codex): pin accounts for native worker and worktree launches - #25762
treze13013-pixel wants to merge 8 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (13)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds explicit Codex account selection to worker-start and worktree creation. Requests validate the selector and runtime capability, then resolve an account and prepare its native Codex home for a fresh terminal launch. Account pins flow into terminal and worktree startup, pane records, and launch receipts. The change also adds placement restrictions, account-aware replay validation, CLI documentation, and tests for selection, launch, and replay behavior. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No actionable account-pinning issue remains in the reviewed evidence. Merge after the normal checks; installed-runtime launch validation remains unperformed. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change includes controls that confine account selection to fresh local launches and prevent replay from changing account intent. No introduced security defect was established. Interrupted-launch recovery and deployed compatibility behavior remain partially verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
94d26307-b868-4a2d-9abe-3d7216a5b647
📒 Files selected for processing (78)
docs/reference/codex-launch-account-pinning.mdsrc/cli/handlers/codex-launch-account-cli.test.tssrc/cli/handlers/codex-launch-account-flag.tssrc/cli/handlers/orchestration/worker-launch-handler.tssrc/cli/handlers/worktree.tssrc/cli/specs/core.tssrc/cli/specs/orchestration-worker-specs.tssrc/main/agent-launch/agent-launch-executor.tssrc/main/agent-launch/agent-launch-mode.tssrc/main/agent-launch/agent-launch-surface-factories.tssrc/main/codex-accounts/codex-launch-account.test.tssrc/main/codex-accounts/codex-launch-account.tssrc/main/codex-accounts/runtime-home-pinned-launch.test.tssrc/main/codex-accounts/runtime-home-service-launch.tssrc/main/codex-accounts/runtime-home-service-managed-home.tssrc/main/codex/codex-pane-account-registry-mutations.tssrc/main/codex/codex-pane-account-registry-types.tssrc/main/codex/codex-pane-account-registry.tssrc/main/codex/codex-pane-launch-account.tssrc/main/codex/codex-stale-pane-accounts.test.tssrc/main/codex/codex-stale-pane-accounts.tssrc/main/ipc/pty-runtime-codex-account-pin.test.tssrc/main/ipc/pty/host-env/codex-home.tssrc/main/ipc/pty/host-env/types.tssrc/main/ipc/pty/ipc/spawn-preflight.tssrc/main/ipc/pty/ipc/spawn-types.tssrc/main/ipc/pty/runtime/spawn-codex-home-selection.tssrc/main/ipc/pty/runtime/spawn-commit.tssrc/main/ipc/pty/runtime/spawn-options.tssrc/main/ipc/pty/runtime/spawn-preflight.tssrc/main/ipc/pty/runtime/spawn-state.tssrc/main/ipc/pty/runtime/spawn.tssrc/main/runtime/orca-runtime-create-managed-worktree.tssrc/main/runtime/orca-runtime-create-terminal-dependencies.tssrc/main/runtime/orca-runtime-create-terminal-desktop.tssrc/main/runtime/orca-runtime-create-terminal.tssrc/main/runtime/orca-runtime-resolve-browser-network-execution-host-for-worktree.tssrc/main/runtime/orca-runtime-resolve-worktree-removal-target.tssrc/main/runtime/rpc/methods/agent-launch-account-replay.test.tssrc/main/runtime/rpc/methods/agent-launch-surfaces.tssrc/main/runtime/rpc/methods/agent-launch-worktree-creation.tssrc/main/runtime/rpc/methods/agent-launch.test-fixture.tssrc/main/runtime/rpc/methods/agent-launch.tssrc/main/runtime/rpc/methods/orchestration-worker-start-mode.tssrc/main/runtime/rpc/methods/orchestration/worker/local-worker-start.tssrc/main/runtime/rpc/methods/orchestration/worker/worker-launch-preferences.tssrc/main/runtime/rpc/methods/orchestration/worker/worker-start-agent-placement.tssrc/main/runtime/rpc/methods/orchestration/worker/worker-topology.tssrc/main/runtime/rpc/methods/orchestration/worker/worker-worktree-creation.tssrc/main/runtime/rpc/methods/orchestration/worker/workers-codex-account.test.tssrc/main/runtime/rpc/methods/orchestration/worker/workers-new-worktree.test.tssrc/main/runtime/rpc/methods/orchestration/worker/workers.tssrc/main/runtime/rpc/methods/worktree-create-args.tssrc/main/runtime/runtime-account-controller.tssrc/main/runtime/runtime-agent-launch-account.tssrc/main/runtime/runtime-codex-account-placement.test.tssrc/main/runtime/runtime-codex-account-placement.tssrc/main/runtime/runtime-codex-account-pre-create.test.tssrc/main/runtime/runtime-folder-worktree-create.tssrc/main/runtime/runtime-legacy-worker-terminal-recovery-types.tssrc/main/runtime/runtime-local-worktree-terminal-startup.test.tssrc/main/runtime/runtime-local-worktree-terminal-startup.tssrc/main/runtime/runtime-managed-worktree-create-types.tssrc/main/runtime/runtime-pty-controller-contract.tssrc/main/runtime/runtime-service-command-surface.tssrc/main/runtime/runtime-terminal-contracts.tssrc/main/runtime/runtime-terminal-create-routing.tssrc/main/startup/codex-launch-preparation.tssrc/shared/agent-launch-account.tssrc/shared/agent-launch-intent.tssrc/shared/agent-launch-operation.tssrc/shared/protocol-version.tssrc/shared/rpc-contract/agent-launch-params.tssrc/shared/rpc-contract/launch-account-param.tssrc/shared/rpc-contract/orchestration-worker-start-params.tssrc/shared/rpc-contract/worktree-create-params.tssrc/shared/runtime-worktree-contracts.tssrc/shared/worktree/create-types.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Preserve the known worktree details in replay failure data. · agent-launch.ts:324-371
src/main/runtime/rpc/methods/agent-launch.ts:324-371
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winPreserve the known worktree details in replay failure data.
When pinned worktree startup fails after registration, this handler leaves the operation outcome
unknownbut replacesWorktreeStartupErrorwith a plainagent_session_operation_unknownerror. The RPC mapper can no longer attach the known worktree ID, effects, or residual resources. A caller can find worktree IDs throughworktree.list, but the failure and operation record do not identify which worktree this launch created. Preserve the known worktree details in the failure while keeping the operation outcomeunknown.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ea8338a3-8991-48ba-aca0-0dde2d4d2ded
📒 Files selected for processing (9)
src/main/runtime/rpc/errors.test.tssrc/main/runtime/rpc/errors.tssrc/main/runtime/rpc/methods/orchestration/worker/worker-worktree-creation.tssrc/main/runtime/rpc/methods/orchestration/worker/workers-codex-account.test.tssrc/main/runtime/runtime-folder-worktree-create.test.tssrc/main/runtime/runtime-folder-worktree-create.tssrc/main/runtime/runtime-local-worktree-terminal-startup.test.tssrc/main/runtime/runtime-local-worktree-terminal-startup.tssrc/shared/worktree/worktree-startup-error.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
ELI5
A coordinator can start one Codex worker on account A and another on account B while keeping the global account selection and existing sessions unchanged. Today these launches follow the selected account.
What Changed
Both entry points accept an explicit account for a fresh native Codex launch:
The shared launch path resolves an exact managed account ID, a unique case-insensitive native-host email, or
system/"System default". Unknown, ambiguous, untrusted and unsupported accounts are rejected before worktree or Dispatch creation.Existing managed-home preparation supplies
CODEX_HOMEonly to the new process. It does not call account-switch setters or changeactiveCodexManagedAccountId. Pane attribution records the effective account and skips explicitly pinned panes when checking global-selection staleness. Launch receipts expose sanitizedprovider,requestedandeffectivevalues without credentials or home paths.If pinned terminal startup fails after worktree creation, the failure receipt retains the created worktree for explicit recovery; the launch stays pinned and the worktree is not deleted automatically.
CLI callers require the execution runtime's
codex.launch-account.v1capability before sending a mutation. Optional RPC fields preserve the omitted-account path. Authoritative agent-launch replay preserves the original account receipt and conflicts on changed intent; legacy create-cache requests with a pin are rejected.Why
Per-launch selection addresses concurrent Codex account isolation using Orca's existing account, home and launch infrastructure. Switching global selection would affect unrelated launches. Automatic account or quota failover is explicitly outside this change.
Linked Issue
Addresses the explicit Codex launch portion of #9496. This does not close its broader per-worktree/provider requirements.
#20512 is a separate follow-up: no automatic quota failover. Claude account support in #22691 is unmerged and is not stacked into this PR.
Visual Proof
N/A — this adds a CLI/RPC launch contract and receipts; no renderer UI is changed.
Testing
Windows; Node 24.19.0, Bun 1.4.2, pnpm 12.8.1,
ORCA_BACKGROUND_LAUNCH=1. Fake account fixtures and mocked providers; no real-account launches.Current reconciliation: exact head
e2df927124305692434dea39a77d75973c5a1d13incorporates upstreamb75213100b5358bedb7e16b48afd30645e54de14by an ordinary merge on the same branch, preserving all previous commits. The 48 incoming commits intersect 14 delivery files. The sole textual conflict joined the folder startup failure tests and the upstream headless-provisioning test; both remain. A duplicate execution-host type import produced by the automatic merge was removed.CLI activation adopts upstream host-only navigation. Unpinned native chat now ignores custom terminal commands, as upstream requires; explicit pins still use a fresh native terminal and reject custom Codex commands before effects. Background worktree provisioning and recovery changes retain the pinned startup throw and the created worktree's identity. The extracted orchestration capability registry coexists with the additive
codex.launch-account.v1advertisement.New/strengthened regressions cover managed A/B and system pins with a structured-chat default, rejection of custom commands for a pinned launch, and pinned startup failure under background provisioning without an unpinned fallback. The account receipt replay test uses upstream's declared Node-runtime pool because it exercises the host's durable Node SQLite ledger. No test assertion, timeout or native gate was relaxed. The managed-create account preparation was expressed without reassigning the request argument to keep the existing 300-line lint limit.
Current source results:
b752131...archive with the same frozen dependencies: two Windows recovery-command quoting assertions, nine prestart SQLite teardown failures, one durable worker-replay SQLite teardown failure, and eight authoritative metadata-pruning failures. The baseline has 57 passed / 20 failed / 77 total. These limitations remain visible.Passed on the reconciled source:
Source tests use the current Vitest config, Bun/Node pools and real-home write guard. The normal test wrapper's native preflight remains blocked; the direct source runner results do not claim a packaged runtime proof. Native check-only rejects missing patched node-pty job exports, the windows-registry addon and synchronous process-tree CreationTime support.
Local commissioning is waiting for operator provisioning of the Windows toolchain. The earlier official native rebuild failed to find Visual Studio. During this reconciliation,
vswheredetected a new Build Tools 2022 instance still marked incomplete/non-launchable; the operator confirmed installation is in progress. MSVC/MSBuild began appearing, while the Windows SDK was still absent at the last inventory. No rebuild, official Orca update, installed app replacement, credential change or positive installed acceptance was performed in this reconciliation. Recheck the completed toolchain before rebuilding the preserved exact source head.AI Disclosure
Implemented and reviewed with Codex GPT-6.1-Sol, including coordinator review and independent source validation.
Review
The account primitive is shared by worker-start and worktree creation. Explicit pins use a fresh native terminal; a structured-chat preference receives the existing downgrade receipt with reason
pinned_codex_account. SSH, WSL, forwarded workspaces,--on, resume, terminal reuse and custom Codex commands fail closed. Omitted--accountretains the previous routing, mode and RPC behavior.Agent skill upstream boundary
Notes
The capability is additive; it introduces no stream opcode or feature-specific protocol-version bump. Upstream daemon protocol 40 remains independently negotiated. No installed app, credentials or account selection was changed, and no positive installed-runtime proof is claimed.
Checklist
pnpm lint,pnpm testand packagedpnpm buildall green: focused lint/quality, all three typechecks and CLI build passed; upstream CI and the Windows/native limitations above remain visible.