bug(codex): CODEX_ACCOUNT_MANAGEMENT_UNAVAILABLE survives daemon restart on v0.12.11 (Windows)
Bug
On Windows, every Codex spawn fails immediately with CODEX_ACCOUNT_MANAGEMENT_UNAVAILABLE, and unlike #4908 it is not cleared by a daemon restart.
ao spawn --project <proj> --name "noop-codex" --agent codex --prompt "..."
→ Codex account setup did not complete (CODEX_ACCOUNT_MANAGEMENT_UNAVAILABLE)
[request Manu-Galaxy-Book5Pro-360/8PEgzM7LDB-000109]
Env: AO 0.12.11 (stable, installed 2026-09-06) · Windows 11 Home SL 10.0.26200 (x64) · Codex CLI 0.145.0 · claude-code 2.1.263
Relationship to #4908
#4908 (closed COMPLETED) reported the same error code, with the defining symptom that restarting the daemon lets bootstrap run again and task creation succeed. That fix (2ae83e096e213b405119e98c677339e513db71ad) is an ancestor of the v0.12.11 tag I'm running, so the sticky-sync.Once fix is present in this build.
The remaining failure is worse than the one #4908 described: the documented recovery path no longer recovers. A full ao stop + restart, verified fresh pid and healthz: ok, returns the identical error on the next spawn.
This is also not #4973 — that one surfaces CODEX_ACCOUNT_AUTH_UNVERIFIED via the refreshToken display/launch mismatch. Here the error code is the bootstrap-unavailable one, and my account state never flips to unauthorized after a failed spawn; it stays authorized throughout.
Reproduction
- Windows 11, Codex CLI installed and logged in (
codex login status→Logged in using ChatGPT). ao spawn --agent codex --project <any> --name <name> --prompt <any>- Observe
CODEX_ACCOUNT_MANAGEMENT_UNAVAILABLE, returned instantly. ao stop, wait for daemon to come back, confirm new pid viaao status.- Repeat step 2. Same error.
Evidence that this isn't local auth
Every AO-side probe reports Codex ready, both before and after the failed spawn:
ao agent ls → codex installed authorized
ao doctor → PASS codex: ...\npm\codex.cmd (codex-cli 0.145.0)
codex login status → Logged in using ChatGPT
Ruled out:
- Not auth. CLI is logged in; AO itself reports
authorized. - Not sticky bootstrap state. Full daemon restart, fresh pid,
healthz: ok,readyz: ready— same error. - Not spawn in general.
--agent claude-codespawns successfully in the same project, same session. - Not the readiness warning.
--skip-agent-checkdoes not bypass it.
Expected
A Codex session spawns, as claude-code does. Failing that, the error should name the underlying bootstrap failure rather than the generic CODEX_ACCOUNT_MANAGEMENT_UNAVAILABLE — #4908 already noted the original error is discarded at the WaitCodexAccountBootstrap boundary, and from the outside there is still no way to tell why bootstrap failed.
Secondary: codex-launch-flags warning has the wrong root cause (Windows path escaping)
Possibly unrelated to the above, but it reproduces on the same machine and the diagnosis in ao doctor is misleading:
WARN codex-launch-flags: codex rejected AO's launch flags (...): exit status 1
— codex sessions may spawn without activity hooks; a codex CLI update likely
changed its flag/config surface
The "codex CLI update changed its flag surface" guess is wrong. codex features list and all the config keys work fine on 0.145.0. The actual cause is the unescaped Windows backslash path interpolated into the hooks.* command string.
Isolating the flags AO passes, holding everything else constant:
-c check_for_update_on_startup=false → exit 0
-c notice.hide_rate_limit_model_nudge=true → exit 0
-c projects={'C:\Users\...\Temp'={trust_level="trusted"}} → exit 0
-c hooks.SessionStart=[{...command="& \"C:\Users\...\ao.exe\" ..."}] → exit 1
Error: invalid type: string "[{hooks=[{type=\"command\",command=\"& \\\"C:\Users\...\ao.exe\\\" hooks codex session-start\",timeout=5}]}]", expected a sequence
in `hooks`
Reduced to just the path style inside the hooks command:
command="& \"C:\Users\manuj\ao.exe\" hooks codex stop" → exit 1
command="& \"C:/Users/manuj/ao.exe\" hooks codex stop" → exit 0
command="& \"C:\Users\manuj\ao.exe\" hooks codex stop" → exit 1 (doubling doesn't help)
So the ao.exe path interpolated into hooks.* needs proper escaping (or forward slashes) when building the -c value on Windows. Note projects={...} is fine as AO sends it — it's single-quoted, so only the hooks.* values are affected.
Minor: ao version prints dev on the released 0.12.11 install, which makes version reporting in bug reports confusing.
Hi @mikelord007 , thank you for reporting the issue. I went through the description and also did some proper lookup on another issues and PRs related to it. I see the failure is more prone to happen in windows and we haven't tested the feature thoroughly on that environment. Would you like to pickup the issue and fix the root cause? Or should I pick it up from here?
you can go ahead!
Independent reproduction and root cause (Windows)
I hit this on a different machine and build, and traced it to a specific pre-launch admission check. Summarising here because the root cause looks orthogonal to #5017.
Environment: AO 0.12.12 (stable) · Windows 11 Enterprise 10.0.26200 (x64) ·
Codex CLI 0.151.0 (standalone) · claude-code 2.1.150. Same symptom set as the
report: instant CODEX_ACCOUNT_MANAGEMENT_UNAVAILABLE, survives a full daemon
restart with a fresh pid, ao agent ls shows codex installed authorized
throughout, and --agent claude-code spawns fine in the same project.
The daemon's own API surfaces the underlying reason:
POST /api/v1/agents/codex/accounts/ensure → 503
{"error":"unavailable","code":"CODEX_ACCOUNT_MANAGEMENT_UNAVAILABLE",
"message":"Codex account setup did not complete",
"details":{"reasonCode":"account_storage_unsafe","retryable":false}}
Call chain
bootstrapInner() codex_account_reconcile.go
→ cleanupPendingCredentialHomes() codex_account_catalog.go
→ ensurePrivateDirectory(pendingRoot) codex_account_catalog.go
→ validateCodexDirectoryAncestors() codex_secure_fs_windows.go ← first statement
→ ancestor walk reaches the volume root C:\
→ codexWindowsPathMetadataIsSafe() == false
→ errors.New("codex directory ancestor ACL is unsafe") // plain error
→ bootstrapStorageFailure() → bootstrapFailure("account_storage_unsafe", false)
ensurePrivateDirectory calls validateCodexDirectoryAncestors as its first
statement, before os.MkdirAll. bootstrapInner runs both
cleanupPendingCredentialHomes calls before reconcileGlobal, so this fails before
reconcileGlobalInner reaches AccountFactory.Open. Neither Codex nor the
account-scoped app-server is ever started — no process is spawned, consistent with
the error returning instantly.
ACL evidence
The walk validates through the volume root. On my machine every AO-owned level
passes and C:\ is the first failing ancestor. Evaluating C:\ the way
codexWindowsHandleSecurity does:
| ACE / property | Value | AO's evaluation |
|---|---|---|
| Owner | NT SERVICE\TrustedInstaller |
ownerTrusted = false |
Authenticated Users |
0x00000004 (FILE_ADD_SUBDIRECTORY), not inherit-only |
counted, intersects codexWindowsMutationMask |
Authenticated Users |
0xE0010000, INHERIT_ONLY |
correctly skipped — not a factor |
BUILTIN\Users |
0x001200A9 (read/execute) |
passes, correctly not a factor |
SYSTEM, BUILTIN\Administrators |
0x001F01FF |
trusted, pass |
Two things worth being precise about: the inherit-only 0xE0010000 ACE is already
ignored by the INHERIT_ONLY_ACE filter and should not be cited as a cause, and the
ordinary read/execute BUILTIN\Users ACE is correctly accepted. ownerTrusted = false alone short-circuits codexWindowsAncestorACLIsSafe, so the owner check fails
independently of any ACE.
I can only speak to my own machine here — I haven't inspected the original reporter's filesystem permissions, so I'm not asserting this is the same failure they hit, only that the symptoms match and this path fails first when it applies.
Current main
I diffed v0.12.12 against main; these are byte-identical, so the behaviour is
unchanged on main:
codex_secure_fs_windows.go(validateCodexDirectoryAncestors,codexWindowsHandleSecurity)codex_windows_security.go(codexWindowsAncestorACLIsSafe, mutation mask, trust predicates)codex_account_catalog.go(ensurePrivateDirectory,cleanupPendingCredentialHomes)codex_account_reconcile.go(bootstrapInner,bootstrapStorageFailure)
Why the obvious workarounds are wrong
Changing ownership or ACLs on C:\ is not an acceptable workaround. It is a
machine-wide OS security change to satisfy one application, and a
TrustedInstaller-owned volume root with a default Authenticated Users
FILE_ADD_SUBDIRECTORY ACE is a normal Windows configuration. I deliberately left
the machine unmodified.
Adding TrustedInstaller to the trusted-owner set is not sufficient on its own.
It would clear ownerTrusted, but the non-inherit-only 0x4 ACE still intersects
codexWindowsMutationMask and would fail codexWindowsAncestorACLIsSafe.
The invariant worth preserving
After validation, no untrusted principal should be able to directly mutate the private vault, replace an already-existing component used to reach it, or redirect resolution through a reparse point.
Mapping that onto Windows directory rights, substitution of an existing component
C under parent A needs two distinct rights:
- gating:
DELETEonC, orFILE_DELETE_CHILDonA. Rename is the sharp edge here — unlikeRemoveDirectoryit does not require the directory to be empty, so a principal with either right can relocate an existing component wholesale and interpose a replacement at the same path. - completing:
FILE_ADD_SUBDIRECTORYonA, which alone can only create a previously unused name (CreateDirectoryon an existing name returnsERROR_ALREADY_EXISTS).
WRITE_DAC / WRITE_OWNER matter because they let a principal grant themselves the
gating rights; note the owner implicitly holds WRITE_DAC, which is why ancestor
ownership is worth checking at all.
By that analysis the current ancestor policy rejects several rights that do not
confer substitution over an existing component: FILE_ADD_SUBDIRECTORY (0x4) and
FILE_ADD_FILE/FILE_WRITE_DATA (0x2) only add new names, and — worth checking
against the generic mapping rather than assuming — FILE_GENERIC_WRITE maps to
READ_CONTROL | FILE_WRITE_DATA | FILE_APPEND_DATA | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE, containing no DELETE, FILE_DELETE_CHILD,
WRITE_DAC or WRITE_OWNER. GENERIC_ALL maps to FILE_ALL_ACCESS and does
include them.
Fix design space
I'm deliberately not proposing a patch — I haven't built or tested one, and this is security-policy code where a plausible-looking design can be wrong. Offering the constraints instead:
- the private vault policy should stay strict and unchanged;
- ancestor policy is a genuinely different problem from vault policy and probably warrants its own predicate and its own rights mask, focused on replacement/substitution rights rather than reusing the vault mutation mask;
- structural validation (is a directory,
FILE_ATTRIBUTE_REPARSE_POINTclear) needs to be retained on every component — that is what defends against redirection; - whether a system-servicing owner such as
TrustedInstallershould be trusted for ancestors only is a policy call for maintainers, but the volume root cannot satisfy vault-grade ownership on stock Windows.
One caution from my own analysis, in case it saves someone the detour: I first
considered stopping the strict walk at a trust anchor (e.g. the AO data root) and
applying only structural checks above it. That is unsound. If an untrusted
principal holds FILE_DELETE_CHILD on the anchor's parent, they can rename the
entire anchor aside — contents intact, its own ACL irrelevant — and create a
replacement at the same path. There is a real instance of this shape on stock
Windows: the inherit-only 0xE0010000 ACE on C:\ maps to
GENERIC_READ|GENERIC_WRITE|GENERIC_EXECUTE|DELETE and propagates to child objects,
so a directory created directly under C:\ inherits an ACE granting
Authenticated Users DELETE on it. Any relaxation should keep a per-component
rights check rather than trusting a boundary.
I haven't tested any variant against the suite, so I can't speak to what it does to existing behaviour beyond the paths I traced.
Test coverage
There is no codex_secure_fs_windows_test.go, and the ancestor walk and its
termination appear to have no direct coverage. The Windows tests in
codex_windows_security_test.go are pure-predicate unit tests over synthetic inputs
— TestWindowsAncestorACLPolicyAllowsReadButRejectsMutation passes
ownerTrusted: true and a single synthetic ACE, so it cannot observe a
TrustedInstaller-owned root or a real 0x4 ACE.
A test that would have caught this has to exercise the real ancestor chain up to
the volume root rather than a synthesized ACL: create a vault under a normal temp
directory, apply protectCodexPrivateDirectory, and assert
validateCodexDirectoryAncestors returns nil on a stock unprivileged Windows
runner. Worth pairing with a junction-substitution case (junctions need no admin) so
the reparse defense stays honest if the ancestor policy is relaxed.
Diagnosability
bootstrapStorageFailure classifies anything that is not an *os.PathError /
*os.LinkError as account_storage_unsafe. The ancestor rejection is a plain
errors.New, so it lands in that bucket and the real cause — which ancestor failed,
and which predicate — never reaches the surface. That matches the request in the
issue body for the underlying bootstrap failure to be named; propagating the failing
path and predicate would turn this into a short diagnosis rather than a source trace.
Follow-up with end-to-end validation from another Windows machine/build.
The previously identified account_storage_unsafe path was indeed the blocker in my environment. After forward-porting the ancestor ACL fix plus the Windows managed-home fix from the work around #5108, the failure disappeared without modifying the machine-wide ACLs or ownership on C:.
On a packaged AO Desktop build I verified:
Codex account bootstrap: PASS account_storage_unsafe: absent account management: supported managed Codex credential home admission: PASS fresh Codex session spawn: PASS normal session resume: PASS
I then used the same build for real read-only Codex worker execution and AO orchestrator/delegated-worker execution, so this was not just an /accounts/ensure smoke test.
One additional bug was masked by the ancestor failure: AccountFactory.Open was checking info.Mode().Perm() == 0700 for managed homes. On Windows the directory reports POSIX-style mode bits such as 0777, so the managed account path still fails after fixing only the ancestor walk. #5108 addresses this with platform-specific Windows DACL/ownership validation.
So at least for this reproduction, #5108 is the correct implementation path for the account-management failure.
Closing the reported stock-Windows bootstrap failure as fixed by merged #5108. Current main trusts the Windows system-root TrustedInstaller owner under the bounded ancestor ACL policy and validates managed homes using Windows DACL/ownership rather than POSIX 0700 bits. The same failure was independently re-tested on a packaged Windows build in this thread: account bootstrap and fresh Codex spawn passed. Open #5017 tracks a separate post-launch PATH handoff case.