Skip to content

fix(codex): fence retained native login by account identity - #8808

Merged
lidge-jun merged 1 commit into
lidge-jun:devfrom
luvs01:fix/native-login-account-generation
Nov 17, 2026
Merged

lidge-jun merged 1 commit into
lidge-jun:devfrom
luvs01:fix/native-login-account-generation

Conversation

@luvs01

@luvs01 luvs01 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A complete Native main login could remain retained after another component observed a different physical account in the same auth file. During a later empty or partial rewrite, the proxy could return the previous account's credential.

  • Bind retained logins and observation tickets to the existing main-account identity generation, in addition to retention, file-identity, and credential-mutation fences.
  • Refuse stale asynchronous completions and same-fingerprint reuse across an account transition, including A → B → A.
  • Complete the existing owned lifecycle identity transition before capturing a new token/status retention ticket. This retires the previous account's runtime state first and preserves a newly read account through later same-account reconciliation.
  • Keep write-guard/device-reauth observations and explicit pre-exchange refresh tickets within their existing authority.
  • Update the retention contract and add attack-path and normal-rewrite regressions.

Verification

Recorded local validation:

  • bun test tests/codex-integration/native-main-credentials-retention.test.ts: 35 passed, 169 assertions.
  • Five new attack regressions failed against the unchanged implementation. The final suite covers independently observed replacement, empty/partial writes, A → B → A, stale regular/forced refresh completion, same-fingerprint reuse, write-guard authority, normal refresh, ownership loss, and expiration.
  • Fresh independent review found a double-transition compatibility gap when B was read before lifecycle reconciliation. Four token/status × empty/partial controls failed on that intermediate candidate and pass after sharing the existing lifecycle transition; they also verify that A's cached info is cleared first.
  • Typecheck passed across 2,536 files. Structure, privacy, file-size ratchet and staged whitespace checks passed.
  • Cold imports starting from either main-account or account-lifecycle passed with a private empty test home and a network-rejecting stub. The static import closure remained 288 modules, with no added Lab path.

Posted-head CI 43812231165 passed, including the Typecheck step and test changed job. Catalog checks also passed. This is exact-head hosted evidence; the local results above are retained prior validation and were not rerun for this status change.

A source comparison against dev c36793a9336b70cfe5bc3b7f6e6f751e730fb6fc found no duplicate implementation or incompatible contract change requiring a rebase. Maintainer security review and installed/live application validation remain separate; review readiness does not claim merge or release acceptance.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

The security checkbox records implementation review; explicit maintainer security review and the repository's maintainer-sponsored requirement for authentication surfaces remain required before merge.

Summary by CodeRabbit

  • Bug Fixes
    • Improved native sign-in reliability when account identity changes. Previously retained login credentials are no longer reused after an account replacement or identity change, including changes that occur while a refresh is in progress. Incomplete or empty credential updates retain access only while the associated account identity remains valid. This helps prevent an earlier login from becoming usable again after the account has changed.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Complete credential reads now observe the main-account identity before capturing eligible retention tickets. Retained native-main logins and observation tickets are bound to that identity generation, and stale generations are rejected.

Changes: Native-main login retention

Layer / File(s) Summary
Reconcile identity on owned reads
src/codex/account-lifecycle.ts, src/codex/main-account.ts, tests/codex-integration/native-main-credentials-retention.test.ts
Complete credential reads observe account identity before capturing a retention ticket when native-main traffic is allowed and retained credentials are enabled. Tests cover identity reconciliation during token and status reads and when native reauthentication starts.
Fence retained logins by identity generation
src/codex/native-main-credentials.ts, tests/codex-integration/native-main-credentials-retention.test.ts, structure/providers/native-main-login-retention.md
Observation tickets and retained entries include the account identity generation. Retention rejects stale tickets, and reads invalidate entries whose generation is no longer live. Tests cover account changes, identity round trips, and refreshes; the documentation describes the generation checks.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • lidge-jun/opencodex#8766: Adds process-memory retention for complete native-main logins. This change updates the retention contract in the same files and functions.
Merge Risk: Minimal · up to 5a76b

The change stops a retained native login from returning credentials for a previous account after the account changes. No concrete merge-blocking defect was found. Maintainer security review and installed-application validation are still pending, as the PR description states.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: retained native main-account login is now fenced by account identity generation, which the raw summary and PR objectives both describe. The title is specific and match…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: retained native main-account login is now fenced by account identity generation, which the raw summary and PR objectives both describe. The title is specific and matches the changeset, and it stays within the 8-word, single-sentence style.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 595de1e and 5a76b97.

Files selected for processing: 5

  • src/codex/account-lifecycle.ts
  • src/codex/main-account.ts
  • src/codex/native-main-credentials.ts
  • structure/providers/native-main-login-retention.md
  • tests/codex-integration/native-main-credentials-retention.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 16, 2026
@luvs01
luvs01 marked this pull request as ready for review November 16, 2026 23:02
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev under MAINTAINERS.md (not an approving review), 2026-11-17 triage round.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants