Repository navigation
fix(auth): retain the selected account when migrating Codex sessions - #118205
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 6:37 PM ET / 22:37 UTC. ClawSweeper reviewWhat this changesThe branch carries Doctor’s collision-safe legacy Codex-to-OpenAI profile mapping into persisted session repair so a migrated session retains the OAuth account selected by the operator. Merge readiness⛔ Blocked until stronger real behavior proof is added - 5 items remain Keep this PR open for maintainer review. The local migration and session-owner path is coherent and the PR includes focused coverage plus redacted terminal output, but the repository requires this reviewer to inspect sibling Priority: P2 Review scores
Verification
How this fits togetherOpenClaw Doctor migrates retired flowchart LR
A[Legacy Codex credentials] --> B[Doctor migration plan]
B --> C[Canonical OpenAI auth profiles]
B --> D[Session route repair]
D --> E[Stored selected account]
E --> F[Status and quota output]
Decision needed
Why: The repository policy makes that direct dependency inspection a prerequisite for a Codex verdict and a proof-sufficient determination, and this review environment lacks the required checkout. Before merge
Agent review detailsSecurityNone. PR surfaceSource +320, Tests +931. Total +1251 across 13 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Complete the required direct Codex source inspection, then merge only if its selected-account and rate-limit behavior confirms that preserving the mapped session override is the canonical way to retain the operator’s selected account. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the added focused tests construct real SQLite auth/session stores, run Doctor migration and session repair, and assert the selected account’s status output. This read-only review did not execute the tests. Is this the best way to solve the issue? Unclear pending mandatory Codex contract inspection; locally the patch uses the appropriate owner boundary by carrying one collision-aware migration decision into later persisted-session repair rather than re-inferring account identity. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 474c4e671e9f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash.
|
…penclaw#118205) * fix(auth): preserve selected OAuth accounts during Codex migrations * test(auth): complete doctor context and stabilize MCP pagination
Closes #58498
What Problem This Solves
Fixes an issue where upgrading or repairing an installation with multiple ChatGPT OAuth accounts could silently switch an existing session to the wrong account. Session status and rate-limit usage then belonged to a different person even though the user had explicitly selected another account.
Why This Change Was Made
Doctor now derives one collision-safe account migration plan across configuration, existing SQLite credentials, and legacy credential files, and carries that exact ephemeral plan to the existing late session-repair owner. Already-affected installations are repaired by reconstructing account identity only from authentic archived credentials with verified migration receipts and an unambiguous matching OAuth account. Ambiguous, tampered, unresolved, unrelated-agent, and incomplete migrations fail closed.
The sibling Codex source was directly inspected: codex-rs/app-server-protocol/src/protocol/common.rs confirms account/rateLimits/read has no account selector, and codex-rs/app-server/src/request_processors/account_processor.rs obtains rate limits from its selected AuthManager account. Correct host-side account selection is therefore required rather than attempting to pass an unsupported account argument.
User Impact
Existing and newly upgraded multi-account installations retain the chosen ChatGPT account through doctor repair, including installations already affected by an earlier migration. Session status and quota reporting again reflect the intended user.
Evidence
Final-Head CI and Account Proof
Week 75% leftfor the selected account and explicitly rejects the unrelated account outputWeek 20% left(src/commands/doctor-auth-flat-profiles.test.ts:113,:135-137).corepack pnpm check:test-types: PASS across core, plugin, and root test-type projects.corepack pnpm test src/flows/doctor-health-contribution-runners.state.codex.test.ts src/node-host/mcp.test.ts: 2 files, 19 tests PASS.codex-rs/app-server-protocol/src/protocol/v2/account.rs:20,:184,:269;codex-rs/app-server-protocol/src/protocol/common.rs:1192;codex-rs/app-server/src/request_processors/account_processor.rs:1010;codex-rs/login/src/auth/manager.rs:520,:2115; andcodex-rs/login/src/token_data.rs:11.Unrelated Mainline CI Repair
The existing MCP pagination ceiling test could exhaust its unrelated 50 ms wall-clock deadline under loaded CI before reaching its required 128-page ceiling. This PR isolates that single test with a 1,000 ms request deadline and retains the separate explicit 50 ms deadline regression unchanged. This repairs the independently reproduced existing-main CI failure without changing production behavior.
Exact-Head Redacted Operator-Visible Transcript
Executed both committed scenarios against actual doctor migration, isolated temporary SQLite credentials/session stores, authenticated account selection, and the actual status renderer. A process-local read-only observer prints only the safe quota substring; no OAuth credentials are exposed.
Direct Codex contract reverified:
codex-rs/app-server-protocol/src/protocol/common.rs:1058has no account selector for rate-limit reads;codex-rs/app-server/src/request_processors/account_processor.rs:1033uses the current authenticated account;codex-rs/login/src/auth/manager.rs:2029and:2115enforce account-matched reload.