Repository navigation
Description
Area
Authentication and account pool
What are you trying to accomplish?
Keep native-main requests working while Codex clears or rewrites ~/.codex/auth.json, without needing a fix on the Codex side.
What prevents this today?
In "codex" refresh mode (#7048), OpenCodex still reads auth.json directly for each request and in several other places. While Codex clears the file (codex login does this before it writes the new login, openai/codex#46430) or rewrites it, that read returns nothing, and the request continues without a login. I explained this in #2999 (#2999 (comment)) and asked whether you want the change; that question is still open, so I am opening this issue with the pull request ready.
What should OpenCodex do?
Keep the native-main login in memory with one point of reading (a watcher that adopts only complete, valid content) and one point of writing (used only in "opencodex" refresh mode). An empty or briefly missing file is a hiccup, not a logout; a missing file becomes a logout only after a grace period.
Example usage or interface
No new setting or command. Pull request #7344 implements it on top of dev and keeps #7048's "codex" mode and #7035's behavior as they are.
Alternatives or workarounds
Keep reading the file directly and rely on Codex never leaving it empty or partial. That needs a Codex-side change (reproduction: openai/codex#40267 (comment)).
Additional context
It is up to you. If you do not want it, close this issue and the pull request, and I will drop the branch.
Checks
- I searched existing issues and documentation.
- This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
- I removed secrets and personal data.
Activity
github-actions commentedon Oct 19, 2026
Automated translation bookkeeping — detected language: English.
Ingwannu commentedon Oct 19, 2026
Linked to Draft #7344. This is a change to native-main credential ownership and logout semantics, rather than only a file-read optimization. The ten-minute missing-file grace and retention of a last-good grant during rewrites need an explicit owner decision: distinguish transient empty/partial replacement, intentional logout, account switch, pause/revocation and a writer that lost ownership. Preserve #7048 refresh-mode ownership and #7035's request-local refreshed-token behavior independently.
I am keeping this as needs-design while that decision and the required authentication-boundary review remain open. The PR's frozen/missing-write, directory-event-loss, rename-boundary and shutdown fixtures are relevant evidence; they do not themselves approve the retention policy. No live auth/config/service change or new scan was run.
MarcTCruz commentedon Oct 24, 2026
@lidge-jun, one question for you:
Should OpenCodex keep the last complete login in memory while
auth.jsonis briefly missing, empty or partial? If yes, what default time?Your answer unblocks PR 2b and PR 2d below. Nothing else in this comment needs a reply.
#7344 is closed. As asked in #7344 (comment), I will land its work in six small pull requests against
dev, in this order:<CODEX_HOME>/auth.jsonitself (main-account.ts,auth-collision.ts,auth-api/account-pause-group.ts,account-lifecycle.ts,orca-import.ts,desktop-compatibility/native-identity.ts) calls one module. The module still reads the file on each call. A guard test fails when a newsrc/line namesauth.jsonoutside an allowlist.main-account.tsand the switch, rollback and recovery writes innative-profile-manager.tsgo through one module.auth.jsonand reports its new state: complete, empty, partial, missing or unreadable.nativeMainAuthGraceSeconds(whole seconds).1a and 1b come first, because they do not change behavior.
lidge-jun commentedon Oct 28, 2026
At dev@fdc6dd82d, the file reader still maps missing, malformed and tokenless content to null (
src/codex/main-account.ts:213-246). However, Codex refresh mode can resolve an absent file through the owned Codex RPC (main-account.ts:525-561), and its returned bearer deliberately survives keyring-related file removal for that request (main-account.ts:703-711). Process-wide retention must preserve that distinction. #7344 is closed; its six-step replacement plan is already recorded here.The outstanding owner decision can be evaluated as three contracts:
I recommend settling that contract before implementing retention; this proposal chooses neither a duration nor deletion semantics. The duration should be an upper bound from the first incomplete observation, never renewed indefinitely by repeated events. Explicit no-login/logout, account replacement, pause/revocation, refresh-mode changes and ownership loss must invalidate retained and pending grants independently of time. Expired access tokens must still follow the selected refresh owner. A successful request-local refresh whose publication is refused remains the separate #7035 contract.
There is no policy-independent retention slice yet. The already proposed reader/writer consolidation can proceed separately with unchanged behavior. After owner disposition, the smallest retention slice belongs in a new
src/codex/native-main-credentials.tsbehind that reader, with a siblingtests/codex-integration/native-main-credentials-retention.test.ts. Its decisive fixtures should distinguish truncate/restore, delete→different-account, authoritative logout during grace, repeated partial writes, pause/revocation, mode switch and stale completion after ownership loss. Retaintests/codex-integration/native-main-refresh-mode.test.tsas the existing refresh-owner parity check. No credential migration or new default should be implied by the preparatory refactor.refactor(codex): read the native-main auth.json through one module
test(codex): guard the auth.json literals in src with a file:line all…
refactor(codex): read the native-main auth.json through one module (#…
lidge-jun commentedon Nov 11, 2026
Parts 1a and 1b of the plan above (one native-main auth.json reader and writer, no behavior change) landed in #7918 (merge a80a329). The retention parts (2a–2d) still wait on the owner decision about the retention contract, so this issue stays open.