You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Keep the native-main login in memory while Codex rewrites auth.json #7345
account-poolOAuth, credentials, Codex pool, quota, failover, plansenhancementNew feature or requestneeds-design설계 필요. Implementation waits on a written design.
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.
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.
Should OpenCodex keep the last complete login in memory while auth.json is 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:
PR
Content
Behavior change
Depends on
1a
One reader. Every caller that reads <CODEX_HOME>/auth.json itself (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 new src/ line names auth.json outside an allowlist.
None
—
1b
One writer. The refresh and reauth writes in main-account.ts and the switch, rollback and recovery writes in native-profile-manager.ts go through one module.
None
1a
2a
Watcher. A separate module that watches auth.json and reports its new state: complete, empty, partial, missing or unreadable.
None until a caller uses it
1a
2b
In-memory copy. It keeps the last complete login and takes its input from the 2a watcher.
Yes
2a, your answer above
2c
Checked write. Before the rename, the writer checks the file again. A change by Codex wins over the OpenCodex write.
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:
Keep current admission semantics and only consolidate reads/writes. This has the smallest compatibility surface but does not guarantee continuity through file rewrites.
Retain the last complete, same-owner login only for empty/partial replacement; treat absence as unavailable unless Codex positively confirms login. This limits ambiguous deletion retention but covers fewer replacement sequences.
Retain through empty/partial/missing states for an owner-selected maximum duration. This covers rename gaps, but intentional external logout can look identical to a rewrite until a separate authoritative signal arrives.
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.ts behind that reader, with a sibling tests/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. Retain tests/codex-integration/native-main-refresh-mode.test.ts as the existing refresh-owner parity check. No credential migration or new default should be implied by the preparatory refactor.
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.
Owner decision (lidge-jun, 2026-11-15): the second contract. Retain the last complete, same-owner native-main login only while auth.json is empty or partially written. A missing file counts as unavailable unless Codex positively confirms the login. Explicit logout, account replacement, pause/revocation, a refresh-mode change and ownership loss invalidate any retained grant regardless of time, and expired access tokens still follow the selected refresh owner. Implementation goes in src/codex/native-main-credentials.ts behind the #7918 reader, with the retention fixtures listed above.
account-poolOAuth, credentials, Codex pool, quota, failover, plansenhancementNew feature or requestneeds-design설계 필요. Implementation waits on a written design.
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.
lidge-jun commentedon Nov 15, 2026
Owner decision (lidge-jun, 2026-11-15): the second contract. Retain the last complete, same-owner native-main login only while
auth.jsonis empty or partially written. A missing file counts as unavailable unless Codex positively confirms the login. Explicit logout, account replacement, pause/revocation, a refresh-mode change and ownership loss invalidate any retained grant regardless of time, and expired access tokens still follow the selected refresh owner. Implementation goes insrc/codex/native-main-credentials.tsbehind the #7918 reader, with the retention fixtures listed above.fix(codex): address CodeRabbit on #7345
fix(codex): retain the native-main login only through a rewrite (#7345)…