Repository navigation
fix(codex): Codex 0.157+ starts in Orca-managed homes instead of failing with SUN_LEN - #22878
Conversation
…th exceeds sun_path Codex >= 0.157 auto-starts a background app-server daemon and connects to <CODEX_HOME>/app-server-control/app-server-control.sock. Orca's managed homes under userData make that path longer than sun_path (104 bytes on macOS, 108 on Linux/Windows), so every interactive codex in an Orca terminal failed with 'path must be shorter than SUN_LEN'. The config mirror now writes a marked [features] daemon_auto_start = false into only those homes, removes it when the home fits, and never promotes it into ~/.codex.
- A runtime config.toml holding only Orca's daemon override no longer reads as a
config-sync stall, so users without ~/.codex/config.toml get no false
"missing" warning in the accounts pane.
- The legacy shared-home refresh re-applies the guard, so retained pre-rollout
panes keep daemon auto-start off after a system-default launch.
- Warn once when an inline `features = {...}` or `[[features]]` blocks the
override instead of failing silently.
- Rename the upsert's TUI-specific internals now that it serves any table.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe change adds platform-aware Codex daemon socket-path checks and applies a marked feature override when a path exceeds its platform limit. Config mirroring applies the guard to legacy and managed runtime configs. Sync-status and ordinary-settings handling recognize or remove the override. The TOML settings updater now supports arbitrary single-segment tables, and SSH relay code uses the shared Unix socket limit helper. Priority: ➖ Normal Merge Risk: 🔵 Low · up to A managed WSL home with a long path may still fail to start Codex if system-home discovery fails. Cover that fallback before merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to No new security exposure was established. The main remaining uncertainty is whether WSL launch preparation applies the socket-path guard when there is no readable source configuration. 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)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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: 33ab8178-7b66-40b0-bf4a-bf7df03445f8
📒 Files selected for processing (20)
config/tsconfig.cli.jsonsrc/main/codex-accounts/legacy-shared-config-compatibility.test.tssrc/main/codex-accounts/runtime-home-managed-auth-recovery.test.tssrc/main/codex-accounts/runtime-home-real-home-lane-routing.test.tssrc/main/codex-accounts/runtime-home-retained-auth-provenance.test.tssrc/main/codex-accounts/runtime-home-system-resource-materialization.test.tssrc/main/codex-accounts/service-account-add-login.test.tssrc/main/codex-accounts/service-wsl-accounts.test.tssrc/main/codex-accounts/service.test.tssrc/main/codex/codex-config-mirror.test.tssrc/main/codex/codex-config-mirror.tssrc/main/codex/codex-config-settings-upsert.tssrc/main/codex/codex-daemon-socket-path-guard.test.tssrc/main/codex/codex-daemon-socket-path-guard.tssrc/main/codex/config-settings-promotion.test.tssrc/main/codex/config-sync-stall.test.tssrc/main/codex/config-sync-stall.tssrc/main/codex/config-toml-runtime-owned-sections.tssrc/main/ssh/relay-socket-path-limit.tssrc/shared/unix-socket-path-limit.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| const unguardableHomesWarned = new Set<string>() | ||
|
|
||
| /** Applies (or removes) Orca's daemon override so it tracks the home's current path. */ | ||
| export function applyCodexDaemonSocketGuard( | ||
| config: string, | ||
| homePath: string, | ||
| platform = process.platform | ||
| ): string { | ||
| if (!codexDaemonSocketPathExceedsLimit(homePath, platform)) { | ||
| return stripCodexDaemonOverride(config) | ||
| } | ||
| // Why: upsert rewrites an existing daemon_auto_start line in place, so re-applying is a no-op. | ||
| const guarded = upsertTableSettingsInContent( | ||
| config, | ||
| 'features', | ||
| new Map([['daemon_auto_start', DAEMON_OVERRIDE_RAW]]) | ||
| ) | ||
| if ( | ||
| !guarded.includes(CODEX_DAEMON_OVERRIDE_MARKER) && | ||
| !/\bdaemon_auto_start\s*=\s*false\b/.test(guarded) && | ||
| !unguardableHomesWarned.has(homePath) | ||
| ) { | ||
| // Why: an inline `features = {...}` or `[[features]]` blocks the upsert; say so once instead of failing silently. | ||
| unguardableHomesWarned.add(homePath) | ||
| console.warn( | ||
| `[codex-config] Could not turn off Codex daemon auto-start in ${homePath}: its config defines features in a form Orca cannot extend. Codex may fail with "path must be shorter than SUN_LEN"; add daemon_auto_start = false to features in ~/.codex/config.toml.` | ||
| ) | ||
| } | ||
| return guarded | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '45,145p' src/main/codex/codex-daemon-socket-path-guard.ts
sed -n '125,230p' src/main/codex/codex-config-mirror.ts
sed -n '120,180p' src/main/codex/config-toml-runtime-owned-sections.tsRepository: stablyai/orca
Length of output: 10937
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- guard declarations and imports ---'
sed -n '1,110p' src/main/codex/codex-daemon-socket-path-guard.ts
printf '%s\n' '--- bound helper definitions ---'
rg -n -C 8 "function upsertTableSettingsInContent|export function upsertTableSettingsInContent|DAEMON_OVERRIDE_RAW|preserveRuntimeConflictValues|extractOrdinaryCodexSettings|syncSystemConfigIntoManagedCodexHomeUnsafe" src/main
printf '%s\n' '--- focused usages ---'
rg -n -C 6 "extractOrdinaryCodexSettings|preserveRuntimeConflictValues|daemon_auto_start|applyCodexDaemonSocketGuard" src test tests 2>/dev/null || trueRepository: stablyai/orca
Length of output: 41921
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings
Length of output: 37122
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- upsert helper ---'
sed -n '1,240p' src/main/codex/codex-config-settings-upsert.ts
printf '%s\n' '--- preservation helper ---'
cat -n src/main/codex/codex-config-settings-preservation.ts
printf '%s\n' '--- promotion flow ---'
sed -n '1,280p' src/main/codex/config-settings-promotion.ts
printf '%s\n' '--- mirror entrypoints and promotion callers ---'
rg -n -C 12 "promoteCodexRuntimeSettingsToSystem|syncSystemConfigIntoLegacySharedCodexHome|syncSystemConfigIntoManagedCodexHome|planCodexSettingsPromotion|runtimeValuesToPreserve" src/main/codex
printf '%s\n' '--- daemon-related tests beyond initial excerpt ---'
sed -n '130,360p' src/main/codex/codex-daemon-socket-path-guard.test.tsRepository: stablyai/orca
Length of output: 45649
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- mirror merge and entrypoints ---'
rg -n "function mergeSystemCodexConfigIntoRuntime|export function mergeSystemCodexConfigIntoRuntime|syncSystemConfigIntoLegacySharedCodexHome|syncSystemConfigIntoManagedCodexHome|function prepareSystemConfigFor" src/main/codex/codex-config-mirror.ts
sed -n '1,170p' src/main/codex/codex-config-mirror.ts
sed -n '230,430p' src/main/codex/codex-config-mirror.ts
printf '%s\n' '--- promoted keys and value readers ---'
rg -n -C 8 "PROMOTED_STRUCTURED_KEYS|readPromotedSettingValues|features" src/main/codex/config-toml-promoted-setting-values.ts
printf '%s\n' '--- focused base-to-head diff ---'
git diff --unified=30 646e9a5b02514795af5139961ccca225dfa01b12 8625d5aba3b5e7f43389b4b14a919daebe1f7ed9 -- src/main/codex/codex-daemon-socket-path-guard.ts src/main/codex/codex-config-mirror.ts src/main/codex/config-toml-runtime-owned-sections.ts src/main/codex/codex-daemon-socket-path-guard.test.tsRepository: stablyai/orca
Length of output: 44621
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- numbered decisive source ranges ---'
nl -ba src/main/codex/codex-config-mirror.ts | sed -n '105,155p;164,225p;238,285p'
nl -ba src/main/codex/config-settings-promotion.ts | sed -n '175,225p;265,330p'
nl -ba src/main/codex/config-toml-promoted-setting-values.ts | sed -n '1,42p;90,125p'
nl -ba src/main/codex/config-toml-runtime-owned-sections.ts | sed -n '154,170p'
nl -ba src/main/codex/codex-daemon-socket-path-guard.ts | sed -n '15,82p;84,145p'Repository: stablyai/orca
Length of output: 22708
Preserve the original daemon_auto_start value when removing the override.
When features.daemon_auto_start = true exists, applyCodexDaemonSocketGuard replaces it with the marked false line. A later short-home guard removes that marked line, but it cannot restore true.
This loss can occur when the managed or legacy mirror receives a blank or missing system config, because those branches apply the guard without merging the system config. Promotion also cannot recover the value because daemon_auto_start is not a promoted setting, and extractOrdinaryCodexSettings removes the marked line when it seeds a missing system config.
Preserve the replaced boolean value in the Orca override metadata, and restore it when stripCodexDaemonOverride removes the override. Keep deleting the table only when Orca inserted the override for a previously absent setting. Add coverage for existing true values through short-home cleanup, blank-source mirroring, and promotion seeding.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — initial review of the Codex daemon socket guard and the mirror/promotion plumbing it needs, across all 20 changed files.
- Daemon socket path guard (
src/main/codex/codex-daemon-socket-path-guard.ts) — measuresrealpath(home) + /app-server-control/app-server-control.sockin UTF-8 bytes against the hostsun_pathbudget, then adds or removes the Orca-owneddaemon_auto_start = falseline under[features]; WSL homes are measured by their Linux path against the Linux limit, and inline/arrayfeatureswarns once instead of failing silently. - Shared sun_path budget (
src/shared/unix-socket-path-limit.ts) — extracts the per-OS 104/108 constant and reuses it in the SSH relay path limit, preserving that path's prior behavior. - Generic table upsert (
src/main/codex/codex-config-settings-upsert.ts) — generalizes the existing[tui]placement rule to any single-segment table so the guard can target[features];upsertTuiSettingsInContentnow delegates to it. - Mirror integration (
src/main/codex/codex-config-mirror.ts) — applies the guard on every config write: fresh mirror, merge path, the previously no-op empty-source branch, and the legacy shared home (whose early return for a blank source was removed). - Sync status and promotion (
config-sync-stall.ts,config-toml-runtime-owned-sections.ts) — a guard-only runtime config reads assynced(no user settings withheld), and the marked line is stripped before settings are seeded into~/.codex, so it never reaches the user's real config. - Tests — a new 18-case guard suite with exact byte/limit boundaries and round-trips, plus identity mocks in 11 existing suites so their byte assertions stay host-independent.
ℹ️ The guard has no exit path once Codex fixes the upstream socket path
The override is keyed only on the home's path length, so there is no condition under which it stops being written — not a Codex version floor, not an upstream-fix check. When Codex eventually fixes the client-side socket path (the PR says it will be reported upstream), Orca will keep turning the daemon off in every long managed home until this code is removed, so daemon-backed codex agents/resume stays unavailable there longer than the bug requires. Not a blocker for this fix, just worth a tracked follow-up.
Technical details
# Daemon guard outlives the upstream bug
## Affected sites
- `src/main/codex/codex-daemon-socket-path-guard.ts:61` — the only gate is `codexDaemonSocketPathExceedsLimit`; there is no Codex-version or expiry condition.
- `src/main/codex/codex-daemon-socket-path-guard.ts:15-20` — the JSDoc frames the override as scoped to Codex >= 0.157, but the code never checks the installed version.
## Required outcome
- A tracked follow-up (issue or in-code TODO) that removes the guard once the supported Codex range no longer needs it, so the capability loss does not outlive the bug.
## Open questions for the human
- Is there a Codex version floor below which Orca must keep the guard? If so, gating on that version would let a fixed Codex keep the daemon enabled in long homes.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…or stalls When the settings write-back or mirror refused (unreadable baseline, failed write to ~/.codex, unreadable source), the whole pass returned before the daemon guard was applied. A home whose config.toml predates the guard then kept failing with SUN_LEN on every launch for as long as the stall lasted. The guard now lands on those paths too; the mirror itself is unchanged.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review (8625d5a): one commit that makes the daemon socket guard land even when the settings mirror stalls, plus the regression test that pins it.
- Guard survives a stalled mirror (
src/main/codex/codex-config-mirror.ts) —syncSystemConfigIntoManagedCodexHomenow delegates to a boolean-returningmirrorSystemConfigIntoManagedCodexHomeand callsensureCodexDaemonSocketGuardwhenever it returns false. That covers the write-back refusal, a mirror throw, andrefused-indeterminate, which previously returned before the guard — so a long home whose settings sync stalled could still fail to start Codex. Thetruepaths (skipped-missing-source,mirrored) already applied the guard inside the unsafe mirror, so there is no double-write. - Extracted
writeCodexDaemonSocketGuard— the managed blank-source branch shares the same guarded compare-and-swap helper instead of duplicating it inline. - Regression test (
codex-daemon-socket-path-guard.test.ts) — forces an unreadable baseline so promotion refuses, then asserts the runtime config gains the override while~/.codex/config.tomlis untouched. It genuinely exercises the new wrapper path: the guard cannot be written anywhere else once promotion has returned null.
Verified locally: pnpm test src/main/codex/codex-daemon-socket-path-guard.test.ts src/main/codex/codex-config-mirror.test.ts → 53 passed (19 + 34). I also traced the promotion/baseline state machine: the override is not a promoted key and is stripped before seeding ~/.codex, so applying it on the stall path cannot be stranded or leaked, and isOnlyCodexDaemonOverride still reports guard-only configs as synced.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…not service construction
…d pass Guarding account homes with no ~/.codex/config.toml ran the WSL ownership check, a synchronous wsl.exe call per account, at startup before the window opens and on every account switch. WSL homes are guarded by WSL launch prep, so that pass now covers host homes only.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review (e2c8dd9): three commits that close the last account-home gap in the daemon guard and re-scope two tests.
- Guard-only pass for managed account homes with no source config (
src/main/codex-accounts/codex-config-mirror.ts) —syncIntoManagedHomenow asserts the home path first and, when~/.codex/config.tomlis absent, calls the newly exportedensureCodexDaemonSocketGuardinstead of returning. A resumed session or acodextyped in a non-selected account home now gets the override even though there was nothing to mirror. - Exported
ensureCodexDaemonSocketGuard(src/main/codex/codex-config-mirror.ts) — the previously-private stall-path helper is shared with the account mirror, and the constructor'sstoreparameter is narrowed toPick<Store, 'getSettings'>to match actual usage. - New regression test (
src/main/codex-accounts/codex-config-mirror.test.ts) — covers bothsafeSyncToManagedHomesandsafeSyncIntoManagedHomewith a missing~/.codex/config.toml, asserting the exact[features]bytes land in a long home without creating a real~/.codex. It genuinely fails without the source change (the config read wouldENOENT). - Reset-credit test re-scoping (
service-reset-credit-home-ownership.test.ts) — service construction now happens before the fault is held/reset, so the ownership-read assertions measure the retry, not construction-time mirror IO.
Verified locally: pnpm test on the changed suites → 26 passed; pnpm tc:node exits 0; pnpm test src/main/codex src/main/codex-accounts → 196 files passed with one unrelated process-teardown integration failure (codex-app-server-teardown.integration.test.ts) that this PR does not touch.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the delta since the prior pullfrog review (20d7d59): one commit that keeps the startup guard-only pass from running WSL ownership checks before the window opens, plus the regression test that pins it.
- WSL homes skip the startup guard-only pass (
src/main/codex-accounts/codex-config-mirror.ts) —syncIntoManagedHomenow checks a missing source config before asserting the home path, and applies the guard only to non-WSL homes in that branch. WSL homes run Linux Codex and their ownership check is a blockingwsl.execall; WSL launch prep already applies the guard to any home a terminal launches into (syncWslConfigAndGlobalInstructionsForLaunch→syncSystemConfigIntoManagedCodexHome), so the skip costs no coverage there and avoids reintroducing the pre-window stall the previous commit risked. - Regression test (
codex-accounts/codex-config-mirror.test.ts) — asserts the injected ownership assert is never called for a WSL UNC home with a missing~/.codex/config.toml. I confirmed it is not theatre: reverting the source locally makes it fail (expected "vi.fn()" to not be called at all, but actually been called 1 times), and it passes with the change.
Verified locally: pnpm test src/main/codex-accounts/codex-config-mirror.test.ts src/main/codex/codex-daemon-socket-path-guard.test.ts → 22 passed.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
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: 9a505dcc-9b19-4f96-b84d-e1c045cf29bf
📒 Files selected for processing (2)
src/main/codex-accounts/codex-config-mirror.test.tssrc/main/codex-accounts/codex-config-mirror.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| // Why: with no ~/.codex/config.toml there is nothing to mirror, but Codex still cannot start in a long home without the daemon guard. | ||
| // WSL homes are skipped: their ownership check is a blocking wsl.exe call (startup, account switch), and WSL launch prep guards the home it launches. | ||
| if (!parseWslUncPath(managedHomePath)) { | ||
| ensureCodexDaemonSocketGuard(this.assertManagedHomePath(managedHomePath, expectedAccountId)) | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n 'ensureCodexDaemonSocketGuard|safeSyncIntoManagedHome|syncIntoManagedHome|applyCodexDaemonSocketGuard' src/main/codex-accounts src/main/codex
sed -n '90,145p' src/main/codex-accounts/codex-config-mirror.tsRepository: stablyai/orca
Length of output: 7862
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- candidate files ---'
git ls-files 'src/main/codex-accounts' 'src/main/codex' | rg '(service|runtime-home|wsl|config-mirror|socket-path|launch|codex)' | head -120
printf '%s\n' '--- outlines ---'
ast-grep outline src/main/codex-accounts/codex-config-mirror.ts
ast-grep outline src/main/codex/codex-config-mirror.ts
printf '%s\n' '--- account mirror and codex guard ---'
cat -n src/main/codex-accounts/codex-config-mirror.ts | sed -n '1,145p'
cat -n src/main/codex/codex-config-mirror.ts | sed -n '1,280p'
printf '%s\n' '--- WSL and launch references ---'
rg -n -C 5 'parseWslUncPath|wsl\.exe|WSL|launch|runtimeHomePath|ensureCodexDaemonSocketGuard|Codex.*start|start.*Codex' src/main/codex-accounts src/main/codex -g '*.ts'Repository: stablyai/orca
Length of output: 45654
🏁 Script executed:
#!/bin/bash
set -eu
for f in \
src/main/codex-accounts/runtime-home-service-launch.ts \
src/main/codex-accounts/runtime-home-service-wsl-core.ts \
src/main/codex-accounts/runtime-home-service-wsl.ts \
src/main/codex-accounts/runtime-home-service.ts \
src/main/codex-accounts/wsl-codex-command.ts \
src/main/codex-accounts/codex-account-registration.ts \
src/main/codex-accounts/service.ts \
src/main/codex/codex-daemon-socket-path-guard.ts \
src/shared/wsl-paths.ts
do
if [ -f "$f" ]; then
printf '\n--- %s ---\n' "$f"
wc -l "$f"
rg -n -C 4 'launch|prepare|wsl|WSL|runtimeHome|config\.toml|socket|guard|Codex|command|exec|spawn' "$f" || true
fi
done
printf '\n--- cross-file call sites ---\n'
rg -n -C 3 'runtime-home-service-launch|prepare.*Wsl|prepare.*WSL|launch.*Wsl|launch.*WSL|ensureCodexDaemonSocketGuard|wsl-codex-command|safeSyncIntoManagedHome' src/main src/shared -g '*.ts'Repository: stablyai/orca
Length of output: 42374
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- finishWslLaunchPreparation ---'
rg -n -C 12 'finishWslLaunchPreparation' src/main/codex-accounts
printf '%s\n' '--- WSL shell preflight files ---'
git ls-files src/main/codex src/main/runtime/rpc/methods | rg 'managed-wsl|agent-hooks'
for f in \
src/main/codex/managed-wsl-home-shell-preflight.ts \
src/main/runtime/rpc/methods/agent-hooks.ts \
src/main/providers/local-pty-windows-spawn-environment.ts
do
if [ -f "$f" ]; then
printf '\n--- %s ---\n' "$f"
cat -n "$f" | sed -n '1,260p'
fi
done
printf '%s\n' '--- guard implementation and focused tests ---'
cat -n src/main/codex/codex-daemon-socket-path-guard.ts | sed -n '1,220p'
rg -n -C 8 'long|overlong|socket|daemon_auto_start|missing|absent|config' \
src/main/codex/codex-daemon-socket-path-guard.test.ts \
src/main/codex-accounts/runtime-home-wsl-managed-accounts.test.ts \
src/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts \
src/main/codex-accounts/codex-config-mirror.test.tsRepository: stablyai/orca
Length of output: 42800
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- WSL launch sync delegation ---'
cat -n src/main/codex-accounts/runtime-home-service-home-routing.ts | sed -n '230,310p'
printf '%s\n' '--- socket guard implementation ---'
cat -n src/main/codex/codex-daemon-socket-path-guard.ts | sed -n '14,180p'
printf '%s\n' '--- mirror tests around missing source/config ---'
cat -n src/main/codex-accounts/codex-config-mirror.test.ts | sed -n '1,125p'
printf '%s\n' '--- direct launch and missing config references ---'
rg -n -C 8 'config\.toml|missing source|no source|no.*config|daemon_auto_start|socket|guard' \
src/main/codex-accounts/runtime-home-wsl-managed-accounts.test.ts \
src/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts \
src/main/codex-accounts/codex-config-mirror.test.ts \
src/main/codex/codex-daemon-socket-path-guard.test.tsRepository: stablyai/orca
Length of output: 41905
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- WSL system-home resolution ---'
rg -n -C 12 'getWslSystemCodexHomePath|joinWslPath|getWslHome' \
src/main/codex-accounts/runtime-home-service-home-routing.ts \
src/main/codex-accounts/runtime-home-service-wsl.ts \
src/main/wsl.ts \
src/main/wsl/index.ts \
src/main/wsl/*.ts 2>/dev/null || true
printf '%s\n' '--- launch preparation callers ---'
rg -n -C 8 'prepareForCodexLaunchAsync|prepareForCodexLaunch\(' src/main src/shared -g '*.ts' \
| head -240
printf '%s\n' '--- selected WSL account test context ---'
cat -n src/main/codex-accounts/runtime-home-wsl-managed-accounts.test.ts | sed -n '150,235p'Repository: stablyai/orca
Length of output: 41953
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- getWslHome implementation ---'
cat -n src/main/wsl.ts | sed -n '250,330p'
printf '%s\n' '--- production launch callers ---'
rg -n -C 6 'prepareForCodexLaunchAsync|prepareForCodexLaunch' \
src/main --glob '*.ts' --glob '!**/*.test.ts' | head -180Repository: stablyai/orca
Length of output: 16968
Guard the selected WSL home when system-home discovery fails.
When getWslHome() returns null, WSL launch preparation returns before calling syncSystemConfigIntoManagedCodexHome. The no-canonical-config branch also skips the guard. An overlong managed WSL home with no runtime config can then start Codex without daemon_auto_start = false, which can cause the SUN_LEN socket-path startup failure.
Apply the guard in WSL launch preparation when the selected managed home has no resolvable system home.
Suggested fix
-import { syncSystemConfigIntoManagedCodexHome } from '../codex/codex-config-mirror'
+import {
+ ensureCodexDaemonSocketGuard,
+ syncSystemConfigIntoManagedCodexHome
+} from '../codex/codex-config-mirror'
...
- if (!systemHomePath || systemHomePath === runtimeHomePath) {
+ if (!systemHomePath) {
+ ensureCodexDaemonSocketGuard(runtimeHomePath)
+ return
+ }
+ if (systemHomePath === runtimeHomePath) {
return
}
Review status: ready to merge (head
|
| Platform | Account-home socket path | Before | After |
|---|---|---|---|
| macOS | 178 bytes (limit 103) | SUN_LEN error |
Codex starts, and the guard line is in that home's config.toml |
| Linux | 151 bytes (limit 107) | SUN_LEN error |
Codex starts, and the guard line is written |
| Windows | 130 bytes (limit 107) | SUN_LEN error |
Codex starts, and the guard line is written |
Also verified:
- A home whose socket path fits under the limit gets no guard, and Codex still starts there with its daemon on. This covered Windows' 97-byte shared runtime home and short homes on macOS and Linux.
- The user's
~/.codex/config.tomlnever gets the guard line, on any platform. - Relaunching Orca doesn't rewrite a guarded
config.toml. - On macOS, a real Codex prompt ran to completion in a guarded account home that had mirrored provider settings.
- Windows QA ran at
20d7d59bcb. The only later commit,2e505eb9b4, changes behaviour only for WSL paths.
Known trade-offs and remaining gaps
- In a guarded home the Codex background daemon is off, so daemon-only features such as the agents overview aren't available there. Before this PR, Codex didn't start at all in those homes. Turning the daemon back on from Codex's
/experimentalmenu gets reverted on the next sync. - One gap remains, and it is narrow. A WSL pane opened before this update, on an account that is no longer selected and has no WSL-side
config.toml, stays unguarded until a new WSL terminal opens for that account. Closing that gap would bring back the blockingwsl.execall at startup. - The Codex daemon on Windows can't detach from inside an Orca terminal (the terminal's job object blocks it). The TUI still starts in short homes, so users aren't affected, and it is unrelated to this PR.
…ing with SUN_LEN (stablyai#22878) * fix(codex): turn off Codex daemon auto-start in homes whose socket path exceeds sun_path Codex >= 0.157 auto-starts a background app-server daemon and connects to <CODEX_HOME>/app-server-control/app-server-control.sock. Orca's managed homes under userData make that path longer than sun_path (104 bytes on macOS, 108 on Linux/Windows), so every interactive codex in an Orca terminal failed with 'path must be shorter than SUN_LEN'. The config mirror now writes a marked [features] daemon_auto_start = false into only those homes, removes it when the home fits, and never promotes it into ~/.codex. * fix(codex): address review of the daemon socket guard - A runtime config.toml holding only Orca's daemon override no longer reads as a config-sync stall, so users without ~/.codex/config.toml get no false "missing" warning in the accounts pane. - The legacy shared-home refresh re-applies the guard, so retained pre-rollout panes keep daemon auto-start off after a system-default launch. - Warn once when an inline `features = {...}` or `[[features]]` blocks the override instead of failing silently. - Rename the upsert's TUI-specific internals now that it serves any table. * fix(codex): apply the daemon socket guard even when the settings mirror stalls When the settings write-back or mirror refused (unreadable baseline, failed write to ~/.codex, unreadable source), the whole pass returned before the daemon guard was applied. A home whose config.toml predates the guard then kept failing with SUN_LEN on every launch for as long as the stall lasted. The guard now lands on those paths too; the mirror itself is unchanged. * fix(codex): guard managed account homes when ~/.codex/config.toml is missing * test(codex): keep reset-credit ownership checks scoped to the retry, not service construction * test(codex): build the account mirror test without a type cast * fix(codex): keep blocking WSL ownership checks off the no-config guard pass Guarding account homes with no ~/.codex/config.toml ran the WSL ownership check, a synchronous wsl.exe call per account, at startup before the window opens and on every account switch. WSL homes are guarded by WSL launch prep, so that pass now covers host homes only. --------- Co-authored-by: m4air <m4air@m4airs-Air.localdomain> Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> (cherry picked from commit c220d92)
|
Hello not working Error: start the Windows daemon from a non-elevated terminal; shared clients must not inherit administrator privileges |
Upstream never bumps the version on main; releases are tagged on side branches. machamy.14 merged main and so kept the 1.4.197 label while being mostly newer than v1.4.212. This catches main up again (including the Codex 0.157+ SUN_LEN startup fix, stablyai#22878, the one substantive change v1.4.212 had that main lacked) and labels the base 1.4.212. Folder project roots count as the default workspace (upstream) while git repos keep the fork's repo-path anchor. The Unity editor lookup reads the Windows process table directly now that upstream removed the helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing with SUN_LEN (stablyai#22878) * fix(codex): turn off Codex daemon auto-start in homes whose socket path exceeds sun_path Codex >= 0.157 auto-starts a background app-server daemon and connects to <CODEX_HOME>/app-server-control/app-server-control.sock. Orca's managed homes under userData make that path longer than sun_path (104 bytes on macOS, 108 on Linux/Windows), so every interactive codex in an Orca terminal failed with 'path must be shorter than SUN_LEN'. The config mirror now writes a marked [features] daemon_auto_start = false into only those homes, removes it when the home fits, and never promotes it into ~/.codex. * fix(codex): address review of the daemon socket guard - A runtime config.toml holding only Orca's daemon override no longer reads as a config-sync stall, so users without ~/.codex/config.toml get no false "missing" warning in the accounts pane. - The legacy shared-home refresh re-applies the guard, so retained pre-rollout panes keep daemon auto-start off after a system-default launch. - Warn once when an inline `features = {...}` or `[[features]]` blocks the override instead of failing silently. - Rename the upsert's TUI-specific internals now that it serves any table. * fix(codex): apply the daemon socket guard even when the settings mirror stalls When the settings write-back or mirror refused (unreadable baseline, failed write to ~/.codex, unreadable source), the whole pass returned before the daemon guard was applied. A home whose config.toml predates the guard then kept failing with SUN_LEN on every launch for as long as the stall lasted. The guard now lands on those paths too; the mirror itself is unchanged. * fix(codex): guard managed account homes when ~/.codex/config.toml is missing * test(codex): keep reset-credit ownership checks scoped to the retry, not service construction * test(codex): build the account mirror test without a type cast * fix(codex): keep blocking WSL ownership checks off the no-config guard pass Guarding account homes with no ~/.codex/config.toml ran the WSL ownership check, a synchronous wsl.exe call per account, at startup before the window opens and on every account switch. WSL homes are guarded by WSL launch prep, so that pass now covers host homes only. --------- Co-authored-by: m4air <m4air@m4airs-Air.localdomain> Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> (cherry picked from commit c220d92)







ELI5
Newer Codex (0.157 and later) starts a helper program in the background and talks to it through a special file called a socket. The operating system limits how long a socket's path can be: 104 bytes on macOS, 108 on Linux. Orca keeps each Codex account in a deeply nested folder, so that socket path ends up around 145 bytes and Codex fails with "path must be shorter than SUN_LEN". This PR tells Codex not to start the background helper, but only in folders whose path is too long. Codex then runs the way it did before 0.157. No account data is moved.
What Changed
Before: on macOS, typing
codex(0.157+) in an Orca terminal that uses a managed Codex account, or Orca's own runtime home, fails right away:Error: app server did not become ready on …/home/app-server-control/app-server-control.sock … path must be shorter than SUN_LEN.After: Codex starts normally (banner and sign-in screen) in those homes.
Mechanism:
src/main/codex/codex-daemon-socket-path-guard.tsmeasuresrealpath(home) + /app-server-control/app-server-control.sockin bytes. Codex canonicalizesCODEX_HOME, so the real path is what counts. It compares that length with thesun_pathsize of the host that runs Codex. Thesun_pathsizes now live insrc/shared/unix-socket-path-limit.tsand are reused byrelay-socket-path-limit.ts.daemon_auto_start = false # orca: …under[features]in that home's mirroredconfig.toml. It merges into an existing[features]table without disturbing its bytes, using the table upsert that previously handled only[tui]and is now generic.~/.codex/config.toml: Orca then has nothing to mirror, but it still adds the guard to every host managed account home at startup and when accounts are added or switched, so resuming a session or typingcodexin an account home that was not freshly launched also works. WSL account homes are guarded when a terminal launches into them instead, because checking a WSL home's ownership is a blockingwsl.execall that must not run before the window opens. It still lands when the settings write-back or mirror stalls (for example an unreadable baseline or a failed write to~/.codex), because a stalled settings sync must not also stop Codex from starting.~/.codex/config.toml, so the user's real config never gets it.getCodexConfigSyncStatustreats a runtime config that holds only this override as "synced", so no false "missing ~/.codex/config.toml" warning appears.featuresinline or as an array, so the key can't be placed, Orca logs one warning per home.Why
Codex (0.157 through 0.158.0-alpha.9) turns
daemon_auto_starton by default. The daemon server binds a short/tmp/codex-daemon-<uid>/<hash>path, but the client connects through the long<CODEX_HOME>/app-server-control/…symlink, and thesockaddr_unlength check rejects that path beforeconnect()runs. On macOS the ceiling is a 60-byte canonicalCODEX_HOME(64 on Linux). Orca's homes are well over it for every username.Alternatives considered and rejected:
--no-daemonor-cinto launch commands does not help when the user typescodexinto a terminal themselves.The config key is the one lever that covers every entry point. We will also report the client-side path issue to Codex upstream.
Linked Issue
No GitHub issue. Crash report from the Help menu, listed below.
Crash reports
path must be shorter than SUN_LENon…/orca/codex-accounts/<uuid>/home/app-server-control/app-server-control.sock(about 145 bytes, over the 104-byte macOS limit). Reproduced.Fix evidence
Repro (before), macOS arm64, Codex 0.157.0 installed with npm into /tmp, using a throwaway home shaped like the real one (
/tmp/orca-sunlen-repro/Library/Application Support/orca/codex-accounts/<uuid>/home, 155-byte socket path):codexTUI prints the user's exact error:Installing daemon from CLI version 0.157.0 … Error: app server did not become ready on …/app-server-control.sock … failed to connect to …/app-server-control.sock: path must be shorter than SUN_LEN.codex app-server daemon startfails the same way on 0.156.1, 0.157.0 and 0.158.0-alpha.9, so it is not fixed upstream.{"status":"started"}, and 61 bytes givespath must be shorter than SUN_LEN.CODEX_HOME=/tmp/cxalias) still fails, because Codex canonicalizes the path.After, with the same long home: adding
[features]\ndaemon_auto_start = falseto the home'sconfig.toml(the exact key this PR writes) brings the 0.157 TUI up normally, with the banner and sign-in screen and no daemon error.codex features liston 0.157 showsdaemon_auto_start stable true, which confirms it is the default that changed.Tests fail on the old code and pass with the fix. With only the changed source files reverted,
pnpm test src/main/codex/codex-daemon-socket-path-guard.test.tsgives3 failed | 15 passed:still guards a long home when the user has no ~/.codex/config.toml:expected 'stalled' to be 'synced'keeps the guard in the legacy shared home:expected 'model = "gpt-5"\n' to contain 'daemon_auto_start = false # orca: …'warns once … inline features:expected "warn" to be called 1 times, but got 0 timesWith the fix:
18 passed (18). A later test covers the stalled-sync path: with that path's guard call removed it fails, and with it the suite gives19 passed (19). The guard suite also covers the length gate just under and just over the limit, darwin vs linux, multibyte usernames, merging into an existing[features]table, idempotence, and stripping before promotion.Wider run:
pnpm test src/main/codex src/main/codex-accounts src/main/ipcgivesTest Files 626 passed | 4 skipped,Tests 6250 passed | 23 skipped.pnpm tcexits 0, oxlint is clean, andpnpm run check:code-quality:changedreports0 new finding(s) across 30 changed file(s).Visual Proof
N/A. There is no UI change. The fix changes the content of Codex's config file. The before/after terminal output is in "Fix evidence" above.
Testing
daemon_auto_start = falsekey)codex-daemon-socket-path-guard.test.ts, 19 tests;codex-accounts/codex-config-mirror.test.ts, 3 tests: two fail without the account-home fix, one fails if a WSL home runs its blocking ownership check). Nine existing suites mock the guard to the identity function, so their exact byte comparisons don't depend on the length of the host's temp path.Platforms: macOS tested for real. Linux is covered by unit tests of the length gate. Windows: the test machine has Codex 0.155 from npm, which cannot run the daemon, so this is unverified there. The guard uses the same 108-byte AF_UNIX limit, and Codex strips the
\\?\prefix from the canonical path (normalize_windows_device_path), so the measurement matches what Codex builds. SSH remotes use the host's own short~/.codex, so they are not affected.Trade-offs
codex agentsand daemon-backed resume or continuation are not available there. This is how every Codex version before 0.157 behaved. Before this fix, in those homes the TUI did not start at all.~/.codex/config.tomlis blank or missing, but it writes only the guard line, and only into a long home. A fresh mirror that comes out empty no longer writes a 0-byte file.Adversarial review
4 loops.
\\?\prefix not being counted (low, rebutted with Codex'snormalize_windows_device_pathand its test); inlinefeaturesblocking the guard silently (low); and TUI-specific names in the generic upsert (low). All valid ones are fixed, with tests.~/.codex/config.tomldid not exist, so a resumed session or acodextyped in a non-selected account home could still fail. Those passes now add the guard alone. Two reset-credit tests were adjusted so their "touches nothing" checks cover the retry, not service startup.wsl.execall per account, before the window opened for Windows users with WSL accounts and no WSL-side~/.codex/config.toml. The pass now skips WSL homes, which WSL launch prep already guards.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
~/.codex/config.tomlis never modified. Re-applying the guard is idempotent, so repeat launches don't rewrite the file.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)