Skip to content

feat: full Rust rewrite (17-crate Cargo workspace) - #640

Open
ndycode wants to merge 13 commits into
mainfrom
rust-rewrite
Open

feat: full Rust rewrite (17-crate Cargo workspace)#640
ndycode wants to merge 13 commits into
mainfrom
rust-rewrite

Conversation

@ndycode

@ndycode ndycode commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

Full Rust rewrite of codex-multi-auth as a 17-crate Cargo workspace under crates/, added alongside the existing TypeScript tree (the TS plugin keeps shipping for JS-host users — R1 below).

  • ~120k lines of Rust across 16 library crates + 5 binaries (codex-multi-auth, codex-multi-auth-codex, mcodex, codex-multi-auth-app-launcher, and the new codex-multi-auth-app-router)
  • 2,976+ tests, 0 failures (55 test binaries), clippy -D warnings clean, debug + release builds green
  • Byte-compatible persistence: same files, same paths under ~/.codex/multi-auth/, same JSON key order/indent/trailing-newline conventions — verified by golden byte fixtures generated from the TS implementation (crates/testkit/goldens/)
  • Same CLI surface: 29-command registry, auth-prefix normalization, frozen error/usage strings, exit codes, --json stable anchors — pinned by a documentation.test.ts-analogue docs-parity test
  • Stack: tokio, hyper/axum-primitives, reqwest (rustls only — no openssl), serde with preserve_order, crossterm (hand-rolled TUI port), clap-free hand-parsed command grammars

Architecture

L0 core → L1 config storage rotation climirror usage tui auth → L2 accounts
→ L3 request → L4 quota → L5 runtime → L6 proxy wrapper → L7 manager → L8 bin

Key decisions (full rationale in the architecture doc used to drive the port):

Verification

  1. Golden byte tests: every persisted format round-trips byte-identically against fixtures produced by the TS dist/ build
  2. Ported TS test assertions: the high-value suites (storage, rotation, accounts, proxy, SSE response handler, transformer, fetch-helpers, auth/device-auth, config) were ported with assertions verbatim
  3. E2E smoke (sandboxed CODEX_HOME/CODEX_MULTI_AUTH_DIR): usage/status/list/config explain/rotation status parity, golden account pool renders correctly, wrapper forwards to the real installed codex CLI (codex-cli 0.142.5) through a shadow home, resolver-error strings byte-match scripts/codex.js
  4. Adversarial parity review: 8 subsystem reviewers diffed TS vs Rust line-by-line → 32 candidate divergences → 27 confirmed by independent adversarial verification → 27/27 fixed with pinning tests (including a critical refresh-queue single-flight wedge, mapped-status error-ladder bug, and streaming-failure ledger bookkeeping)

CI

.github/workflows/rust.yml: check + clippy + test on ubuntu-latest and windows-latest, Rust 1.96.0 pinned.

Not ported (deliberate)

  • index.ts / vendored @codex-ai/* shims (JS-host only; logic absorbed — R1)
  • npm lifecycle scripts (postinstall, preuninstall, repo-hygiene, pack budget)
  • hashline tools + session-recovery hook ported as library code but not wired (R2; JS-host-only surfaces)

Known accepted deviations

Documented in module headers throughout; the notable ones:

  • UTF-16 vs Unicode-scalar length caps differ only for astral-plane characters
  • V8-specific error-message interpolations carry Rust Display text (fixed prefixes/suffixes frozen)
  • getAccountsSnapshot deep-clones (TS shared nested arrays with the live pool)

🤖 Generated with Claude Code

note: greptile review for oc-chatgpt-multi-auth. cite files like lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.

Greptile Summary

this pr adds a full rust workspace alongside the existing typescript implementation.

  • adds rust implementations for auth, storage, rotation, request handling, proxying, runtime services, cli management, tui, usage, and codex integration
  • adds five binaries, including the app router and launcher
  • adds rust workspace ci for ubuntu and windows
  • adds rust tests and byte-compatibility fixtures, but does not add vitest coverage that exercises compatibility between the shipping typescript plugin and the new rust surfaces

Confidence Score: 2/5

this pr is not safe to merge until account-store concurrency, app-bind concurrency, stale reset-marker handling, and windows startup path escaping are fixed.

concurrent processes can overwrite shared credential or app-bind state, a transient windows marker-cleanup failure can make saved accounts load as empty, and valid windows paths containing cmd metacharacters can prevent the bound router from starting.

Files Needing Attention: crates/storage/src/save.rs, crates/storage/src/transactions.rs, crates/runtime/src/app_bind.rs

Important Files Changed

Filename Overview
crates/storage/src/save.rs adds wal-first atomic persistence, but stale reset markers can hide successfully saved accounts after windows cleanup failures.
crates/storage/src/transactions.rs adds task serialization, but no cross-process coordination protects the shared credential store.
crates/runtime/src/app_bind.rs adds router binding and startup integration, but cross-process bind races and incompletely escaped windows batch paths can leave routing unavailable.
crates/proxy/src/local_bridge.rs adds authenticated local forwarding with explicit inbound credential stripping and loopback restrictions.
crates/auth/src/local_client_tokens.rs adds hashed local tokens, restrictive unix permissions, atomic writes, and serialized mutation.
crates/request/src/response_handler.rs ports buffered and streaming sse handling with bounded accumulation and terminal failure detection.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  cli[cli and wrappers] --> runtime[runtime services]
  runtime --> auth[oauth and token refresh]
  runtime --> proxy[local proxy pipeline]
  proxy --> request[request transform and failover]
  request --> upstream[chatgpt and codex api]
  runtime --> rotation[account rotation]
  rotation --> storage[account storage]
  auth --> storage
  storage --> codex[codex cli files]
  launcher[app launcher] --> router[app router]
  router --> proxy
Loading

Fix All in Codex

Prompt To Fix All With AI
Fix the following 4 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 4
crates/storage/src/save.rs:229
**stale reset intent hides accounts**

when windows antivirus or another process transiently locks the reset-intent marker, this best-effort removal silently fails after the new account file is committed. the next load treats the stale marker as an intentional reset and returns empty storage, making the newly saved accounts and credentials disappear.

### Issue 2 of 4
crates/storage/src/transactions.rs:33
**storage lock excludes other processes**

when the cli and runtime proxy, or two cli processes, mutate the same account store concurrently, each process acquires its own tokio mutex and independently replaces the shared wal and primary file. a stale read-modify-write transaction can therefore overwrite a newer account selection or credential update.

### Issue 3 of 4
crates/runtime/src/app_bind.rs:676-678
**batch paths leave metacharacters active**

when a windows installation or user-profile path contains a cmd metacharacter such as `&`, `^`, or `|`, this helper escapes only percent characters before interpolating the path into the startup `.cmd` file. cmd.exe alters or splits the command, so the app router does not start and the bound codex desktop app cannot reach its configured provider.

### Issue 4 of 4
crates/runtime/src/app_bind.rs:248-256
**bind lock excludes other processes**

when two processes run the app-bind command concurrently, each process owns a separate mutex and both rewrite `config.toml` and the bind-state file. the last writes can combine configuration and state from different router instances, leaving the recorded hash, port, or client key inconsistent and causing routing or unbind failures.

Reviews (1): Last reviewed commit: "fix(rust): resolve 27 confirmed parity d..." | Re-trigger Greptile

Greptile also left 4 inline comments on this PR.

Context used (6)

ndycode and others added 13 commits July 26, 2026 19:23
Wave 0 of the Rust rewrite: workspace Cargo.toml, per-crate manifests with
frozen dependency sets, complete module trees, and PORT-PENDING stubs for
every planned .rs file. cargo check --workspace is green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Full port of the foundation layer: constants, CodexError family, serde
models (PluginConfig, AccountStorageV3, flagged, WAL journal, tokens),
byte-compatible json_io, fs_retry with Win32 errno mapping, runtime
paths probing ladder, masking logger, JWT/token utils, display-width
tables, table formatter, clock seam, shutdown registry. Test sandbox +
golden byte fixtures generated from the TS reference implementation.

376 tests passing; clippy -D warnings clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rsion

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…r, usage, tui, auth (wave 1)

Full ports: plugin config (54 getters, lockfile, mtime-CAS save, explain
report), account storage (WAL-first save pipeline, recovery ladder,
4-tier identity matching, transactions, flagged store, named backups),
rotation trackers/hybrid selector (never-persisted by construction),
codex-cli mirror state/sync/writer, usage ledger with toFixed(8) cost
parity, hand-rolled TUI (select engine, themes, dashboard builders),
auth (PKCE OAuth, device auth, browser openers, refresh lease/queue,
local client tokens). settings.json golden reproduces the TS fixture
byte-for-byte.

Known gap: auth callback_server.rs still stubbed (implementer connection
dropped); follow-up in next commit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Port of lib/auth/server.ts: never-rejecting bind on fixed port 1455
(ready:false + bindErrorCode on conflict), first-code-wins capture,
100ms poll / 5-min timeout, frozen route/status/header contract,
bundled success page via include_str!. 22 tests incl. live port-1455
serial suite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Port of lib/accounts.ts + sidecar stores: AccountManager (never-persisted
runtime state wrap, 4-tier identity hydration, codex-cli token merge,
transactional commit_refreshed_auth), selection (round-robin, #509
drain-first no-advance, hybrid delegation, tracker interactions),
persistence (build_storage_snapshot as the only storage bridge, #474
strictly-greater pin adoption, 500ms debounced save, 7-day rate-limit
clamp with reason->key matrix), session affinity (#474 generation drop),
capability/entitlement stores, account policies + routing profiles with
golden byte parity. 216 tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Port of the request pipeline: transformer (background-mode gating,
fast-session, plan/capability tool sanitization), model map (full alias
table + hand-rolled codex-max lookbehind semantics), SSE response
handler (incomplete=success, raw-passthrough at original status,
synthetic 502 terminal errors), stream failover (pre-first-byte replay,
cap 1), fetch helpers (7-day retry-after clamp, quota-404->429),
error classification, rate-limit backoff/decision (seconds-vs-ms epoch
heuristics), prompts cache (ETag+sha256, SWR, bundled fallback).
Implements the ModelCatalog/ModelProfileProvider seams for accounts.
541 tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Port of forecast (pure H5 risk engine), quota probe (6-model chain,
header reset-at heuristics, observability hook seam), quota cache with
golden byte parity, readiness (RAW >=100 exhaustion), preemptive
scheduler (in-memory H4 rules, never persisted), budget guard (UTC
windows vs usage ledger), audit JSONL rotation, live account sync
(notify watcher + poll fallback + debounce), runtime policy gate.
161 tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Port of the runtime layer: app-bind (byte-exact config.toml rewriting,
sha256 gate, detached router spawn, #614 orphan self-heal, R3 router
binary swap), first-run O_EXCL claim, rotation modules (choose_account
pin>sequential>affinity>hybrid, #474 no-markSwitched-on-pinned, #509
no-advance, #606 stale-state recovery, #623 forced-index), monotonic
extend-only token refresh cooldowns, account check engine, oauth flow
orchestration, observability snapshot, recovery library (R2), services
lifecycle. 281 tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The hard merge: one request pipeline implementing the union of the
index.ts loader fetch state machine and the runtime rotation proxy loop
(selection, refresh, model fallback chains, 429 mark-before-sleep,
stream failover cap 1, token-invalidation no-rotate, synthetic terminal
bodies, counters surviving fallback restarts). Proxy HTTP surface with
loopback validation, timing-safe client auth, stable error codes, 64MiB
cap, header scrub. Local bridge (/health /v1/models /v1/responses).
App router binary with R3 idle-exit. Wrapper: forwarding, shadow
CODEX_HOME with sync-back, --account force (#623) fail-hard, bin
resolver, mcodex monitor/tmux. 166 tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The full CLI: dispatcher (29-command registry, auth-prefix
normalization, frozen error strings), all commands with exact flag
grammars/exit codes/JSON rules, repair suite (fix never deletes,
doctor 15 checks with masked identities, verify-flagged with drift
guards), health check (no re-base asymmetry, re-enables working
disabled accounts), login dashboard flow + settings hub (11 toggles +
16 numerics, per-path FIFO write queue), formatters, oc-chatgpt
import/orchestrator, update notice, integration generators.
436 tests green; workspace clippy-clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Five thin binary mains (codex-multi-auth, codex-multi-auth-codex,
mcodex, app-launcher, app-router) wiring manager/wrapper/proxy/runtime,
plus the documentation.test.ts analogue asserting the 29-command
registry, --json anchors, and stable error-code tables against
docs/reference.

Workspace fully green: 2976 tests / 0 failures across 55 binaries,
clippy -D warnings clean, release build clean. E2E smoke verified
sandboxed: status/list/config explain/rotation status parity, golden
account pool renders correctly, wrapper forwards to the real codex CLI
through a shadow home.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…eview

8 subsystem reviewers diffed TS vs Rust line-by-line; 32 candidates were
independently verified adversarially, 27 confirmed and all fixed with
pinning tests. Highlights: refresh-queue lazy-future wedge (critical,
now eagerly spawned), error ladder keyed off mapped status so remapped
404 usage-limit/entitlement responses hit the 429/403 branches (high),
streaming forward failures now do account bookkeeping + correct ledger
rows (high), Windows shadow-home junctions instead of privileged
symlinks (high), stray FORCE_ACCOUNT_INDEX scrubbed (high), atomic 0600
file modes, i64 saturating retry-after math, lease release-before-await,
toast debounce gates, TUI numpad/signal/local-date fixes.

Full re-gate: 2998 tests / 0 failures, clippy -D warnings clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 355 files, which is 255 over the limit of 100.

To get a review, narrow the scope:
• coderabbit review --committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

Upgrade to a paid plan to raise the limit.

Usage-priced reviews support at most 300 files.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 28812ee4-55b9-49c8-ab96-bef46c7dc6f8

📥 Commits

Reviewing files that changed from the base of the PR and between 4cdf7a4 and 92d5fce.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (355)
  • .gitattributes
  • .github/workflows/rust.yml
  • .gitignore
  • Cargo.toml
  • crates/accounts/Cargo.toml
  • crates/accounts/src/account_policy.rs
  • crates/accounts/src/capability_matrix.rs
  • crates/accounts/src/capability_policy.rs
  • crates/accounts/src/entitlement_cache.rs
  • crates/accounts/src/lib.rs
  • crates/accounts/src/manager.rs
  • crates/accounts/src/manager_persistence.rs
  • crates/accounts/src/manager_selection.rs
  • crates/accounts/src/rate_limits.rs
  • crates/accounts/src/routing_profiles.rs
  • crates/accounts/src/session_affinity.rs
  • crates/auth/Cargo.toml
  • crates/auth/assets/oauth-success.html
  • crates/auth/src/auth_rate_limit.rs
  • crates/auth/src/browser.rs
  • crates/auth/src/callback_guidance.rs
  • crates/auth/src/callback_server.rs
  • crates/auth/src/device_auth.rs
  • crates/auth/src/lib.rs
  • crates/auth/src/local_client_tokens.rs
  • crates/auth/src/oauth.rs
  • crates/auth/src/org_override.rs
  • crates/auth/src/refresh_lease.rs
  • crates/auth/src/refresh_queue.rs
  • crates/bin/Cargo.toml
  • crates/bin/src/bin/codex-multi-auth-app-launcher.rs
  • crates/bin/src/bin/codex-multi-auth-app-router.rs
  • crates/bin/src/bin/codex-multi-auth-codex.rs
  • crates/bin/src/bin/codex-multi-auth.rs
  • crates/bin/src/bin/mcodex.rs
  • crates/bin/src/lib.rs
  • crates/bin/tests/docs_parity.rs
  • crates/climirror/Cargo.toml
  • crates/climirror/src/lib.rs
  • crates/climirror/src/observability.rs
  • crates/climirror/src/state.rs
  • crates/climirror/src/sync.rs
  • crates/climirror/src/writer.rs
  • crates/config/Cargo.toml
  • crates/config/src/config_schema.rs
  • crates/config/src/dashboard_settings.rs
  • crates/config/src/explain.rs
  • crates/config/src/getters.rs
  • crates/config/src/lib.rs
  • crates/config/src/load.rs
  • crates/config/src/lockfile.rs
  • crates/config/src/save.rs
  • crates/config/src/unified_settings.rs
  • crates/config/tests/dashboard_settings_test.rs
  • crates/config/tests/explain_test.rs
  • crates/config/tests/load_test.rs
  • crates/config/tests/save_test.rs
  • crates/config/tests/transient_read_fault_test.rs
  • crates/config/tests/unified_settings_test.rs
  • crates/core/Cargo.toml
  • crates/core/src/clock.rs
  • crates/core/src/constants.rs
  • crates/core/src/display_width.rs
  • crates/core/src/env_parsing.rs
  • crates/core/src/errors.rs
  • crates/core/src/fs_retry.rs
  • crates/core/src/json_io.rs
  • crates/core/src/jwt.rs
  • crates/core/src/lib.rs
  • crates/core/src/logger.rs
  • crates/core/src/model_family.rs
  • crates/core/src/runtime_paths.rs
  • crates/core/src/schemas/account_storage.rs
  • crates/core/src/schemas/flagged.rs
  • crates/core/src/schemas/journal.rs
  • crates/core/src/schemas/mod.rs
  • crates/core/src/schemas/parse.rs
  • crates/core/src/schemas/plugin_config.rs
  • crates/core/src/schemas/token.rs
  • crates/core/src/shutdown.rs
  • crates/core/src/table_formatter.rs
  • crates/core/src/temp_path.rs
  • crates/core/src/token_utils.rs
  • crates/core/src/types.rs
  • crates/core/src/utils.rs
  • crates/core/src/wsl.rs
  • crates/manager/Cargo.toml
  • crates/manager/src/commands/account.rs
  • crates/manager/src/commands/best.rs
  • crates/manager/src/commands/bridge.rs
  • crates/manager/src/commands/budget.rs
  • crates/manager/src/commands/check.rs
  • crates/manager/src/commands/config_explain.rs
  • crates/manager/src/commands/debug_bundle.rs
  • crates/manager/src/commands/forecast.rs
  • crates/manager/src/commands/history.rs
  • crates/manager/src/commands/init_config.rs
  • crates/manager/src/commands/integrations.rs
  • crates/manager/src/commands/mod.rs
  • crates/manager/src/commands/models.rs
  • crates/manager/src/commands/monitor.rs
  • crates/manager/src/commands/report.rs
  • crates/manager/src/commands/rotation.rs
  • crates/manager/src/commands/status.rs
  • crates/manager/src/commands/switch.rs
  • crates/manager/src/commands/uninstall.rs
  • crates/manager/src/commands/unpin.rs
  • crates/manager/src/commands/usage.rs
  • crates/manager/src/commands/verify.rs
  • crates/manager/src/commands/why_selected.rs
  • crates/manager/src/commands/workspace.rs
  • crates/manager/src/dispatcher.rs
  • crates/manager/src/forecast_report_shared.rs
  • crates/manager/src/formatters/account.rs
  • crates/manager/src/formatters/dashboard.rs
  • crates/manager/src/formatters/mod.rs
  • crates/manager/src/formatters/model.rs
  • crates/manager/src/formatters/quota.rs
  • crates/manager/src/formatters/text_style.rs
  • crates/manager/src/health_check.rs
  • crates/manager/src/help.rs
  • crates/manager/src/integration_generators.rs
  • crates/manager/src/lib.rs
  • crates/manager/src/login/account_credentials.rs
  • crates/manager/src/login/account_pool_write.rs
  • crates/manager/src/login/action_panel.rs
  • crates/manager/src/login/flow.rs
  • crates/manager/src/login/manual_callback.rs
  • crates/manager/src/login/menu_actions.rs
  • crates/manager/src/login/menu_data.rs
  • crates/manager/src/login/mod.rs
  • crates/manager/src/login/oauth.rs
  • crates/manager/src/login/persist_selected.rs
  • crates/manager/src/oc_chatgpt/import_adapter.rs
  • crates/manager/src/oc_chatgpt/mod.rs
  • crates/manager/src/oc_chatgpt/orchestrator.rs
  • crates/manager/src/oc_chatgpt/target_detection.rs
  • crates/manager/src/quota_cache_helpers.rs
  • crates/manager/src/rate_limit_markers.rs
  • crates/manager/src/registry.rs
  • crates/manager/src/repair/doctor.rs
  • crates/manager/src/repair/fix.rs
  • crates/manager/src/repair/mod.rs
  • crates/manager/src/repair/verify_flagged.rs
  • crates/manager/src/settings/backend.rs
  • crates/manager/src/settings/dashboard.rs
  • crates/manager/src/settings/experimental.rs
  • crates/manager/src/settings/hub.rs
  • crates/manager/src/settings/mod.rs
  • crates/manager/src/settings/panels.rs
  • crates/manager/src/settings/persist.rs
  • crates/manager/src/settings/preview.rs
  • crates/manager/src/settings/schema.rs
  • crates/manager/src/settings/write_queue.rs
  • crates/manager/src/update_notice.rs
  • crates/proxy/Cargo.toml
  • crates/proxy/src/client_auth.rs
  • crates/proxy/src/lib.rs
  • crates/proxy/src/local_bridge.rs
  • crates/proxy/src/model_fallback.rs
  • crates/proxy/src/pipeline.rs
  • crates/proxy/src/retry_loop.rs
  • crates/proxy/src/router.rs
  • crates/proxy/src/server.rs
  • crates/proxy/tests/local_bridge_test.rs
  • crates/proxy/tests/pipeline_test.rs
  • crates/proxy/tests/server_test.rs
  • crates/quota/Cargo.toml
  • crates/quota/src/audit.rs
  • crates/quota/src/budget_guard.rs
  • crates/quota/src/cache.rs
  • crates/quota/src/forecast.rs
  • crates/quota/src/health.rs
  • crates/quota/src/lib.rs
  • crates/quota/src/live_account_sync.rs
  • crates/quota/src/parallel_probe.rs
  • crates/quota/src/preemptive_scheduler.rs
  • crates/quota/src/probe.rs
  • crates/quota/src/readiness.rs
  • crates/quota/src/runtime_policy.rs
  • crates/request/Cargo.toml
  • crates/request/assets/codex-host-bridge.txt
  • crates/request/assets/codex-instructions.md
  • crates/request/assets/tool-remap-message.txt
  • crates/request/src/attempt_budget.rs
  • crates/request/src/context_overflow.rs
  • crates/request/src/error_classification.rs
  • crates/request/src/failover_config.rs
  • crates/request/src/failure_policy.rs
  • crates/request/src/fetch_helpers.rs
  • crates/request/src/headers.rs
  • crates/request/src/input_utils.rs
  • crates/request/src/lib.rs
  • crates/request/src/model_map.rs
  • crates/request/src/prompts/codex.rs
  • crates/request/src/prompts/fetch_utils.rs
  • crates/request/src/prompts/host_bridge.rs
  • crates/request/src/prompts/host_prompt.rs
  • crates/request/src/prompts/mod.rs
  • crates/request/src/rate_limit_backoff.rs
  • crates/request/src/rate_limit_decision.rs
  • crates/request/src/request_init.rs
  • crates/request/src/resilience.rs
  • crates/request/src/response_compaction.rs
  • crates/request/src/response_handler.rs
  • crates/request/src/response_metadata.rs
  • crates/request/src/stream_failover.rs
  • crates/request/src/stream_failover_runtime.rs
  • crates/request/src/token_refresh.rs
  • crates/request/src/tool_utils.rs
  • crates/request/src/transformer.rs
  • crates/request/src/url_rewriting.rs
  • crates/request/src/wait_utils.rs
  • crates/request/tests/context_overflow_test.rs
  • crates/request/tests/response_handler_test.rs
  • crates/request/tests/stream_failover_runtime_test.rs
  • crates/request/tests/stream_failover_test.rs
  • crates/rotation/Cargo.toml
  • crates/rotation/src/circuit_breaker.rs
  • crates/rotation/src/lib.rs
  • crates/rotation/src/routing_mutex.rs
  • crates/rotation/src/selector.rs
  • crates/rotation/src/trackers.rs
  • crates/runtime/Cargo.toml
  • crates/runtime/src/account_check.rs
  • crates/runtime/src/account_pool.rs
  • crates/runtime/src/account_selection.rs
  • crates/runtime/src/account_state.rs
  • crates/runtime/src/account_status.rs
  • crates/runtime/src/app_bind.rs
  • crates/runtime/src/app_launcher.rs
  • crates/runtime/src/capability_boost.rs
  • crates/runtime/src/config_toml.rs
  • crates/runtime/src/current_account.rs
  • crates/runtime/src/event_handler.rs
  • crates/runtime/src/first_run.rs
  • crates/runtime/src/hydrate_emails.rs
  • crates/runtime/src/lib.rs
  • crates/runtime/src/live_sync.rs
  • crates/runtime/src/loader_setup.rs
  • crates/runtime/src/login_menu_accounts.rs
  • crates/runtime/src/manager_cache.rs
  • crates/runtime/src/oauth_flows/browser.rs
  • crates/runtime/src/oauth_flows/facade.rs
  • crates/runtime/src/oauth_flows/manual.rs
  • crates/runtime/src/oauth_flows/mod.rs
  • crates/runtime/src/observability.rs
  • crates/runtime/src/preemptive_quota.rs
  • crates/runtime/src/proactive_refresh.rs
  • crates/runtime/src/quota_probe.rs
  • crates/runtime/src/quota_settings.rs
  • crates/runtime/src/recovery/constants.rs
  • crates/runtime/src/recovery/hashline.rs
  • crates/runtime/src/recovery/hook.rs
  • crates/runtime/src/recovery/mod.rs
  • crates/runtime/src/recovery/storage.rs
  • crates/runtime/src/recovery/types.rs
  • crates/runtime/src/refresh_guardian.rs
  • crates/runtime/src/rotation/account_selection.rs
  • crates/runtime/src/rotation/mod.rs
  • crates/runtime/src/rotation/proxy_state.rs
  • crates/runtime/src/rotation/request_init.rs
  • crates/runtime/src/rotation/server_types.rs
  • crates/runtime/src/rotation/storage_meta.rs
  • crates/runtime/src/rotation/token_refresh.rs
  • crates/runtime/src/services.rs
  • crates/runtime/src/storage_scope.rs
  • crates/runtime/src/toast.rs
  • crates/runtime/src/ui_runtime.rs
  • crates/runtime/src/verify_flagged.rs
  • crates/storage/Cargo.toml
  • crates/storage/src/backup_metadata.rs
  • crates/storage/src/backup_paths.rs
  • crates/storage/src/backup_restore.rs
  • crates/storage/src/backups.rs
  • crates/storage/src/clear.rs
  • crates/storage/src/facade.rs
  • crates/storage/src/fixture_guards.rs
  • crates/storage/src/flagged.rs
  • crates/storage/src/health.rs
  • crates/storage/src/identity.rs
  • crates/storage/src/import_export.rs
  • crates/storage/src/lib.rs
  • crates/storage/src/load.rs
  • crates/storage/src/match_utils.rs
  • crates/storage/src/matching.rs
  • crates/storage/src/migrations.rs
  • crates/storage/src/misc.rs
  • crates/storage/src/named_backups.rs
  • crates/storage/src/normalize.rs
  • crates/storage/src/parser.rs
  • crates/storage/src/path_state.rs
  • crates/storage/src/paths.rs
  • crates/storage/src/project_migration.rs
  • crates/storage/src/public_types.rs
  • crates/storage/src/restore.rs
  • crates/storage/src/save.rs
  • crates/storage/src/save_retry.rs
  • crates/storage/src/snapshot.rs
  • crates/storage/src/transactions.rs
  • crates/storage/tests/facade_test.rs
  • crates/testkit/Cargo.toml
  • crates/testkit/goldens/README.md
  • crates/testkit/goldens/account-policies.json
  • crates/testkit/goldens/accounts-v3.json
  • crates/testkit/goldens/accounts-v3.wal
  • crates/testkit/goldens/app-bind-state.json
  • crates/testkit/goldens/budget-guards.json
  • crates/testkit/goldens/codex-cli-accounts.json
  • crates/testkit/goldens/codex-cli-auth.json
  • crates/testkit/goldens/config-toml-provider-block.toml
  • crates/testkit/goldens/first-run-setup.json
  • crates/testkit/goldens/flagged-v1.json
  • crates/testkit/goldens/generate.mjs
  • crates/testkit/goldens/local-client-tokens.json
  • crates/testkit/goldens/quota-cache.json
  • crates/testkit/goldens/routing-profiles.json
  • crates/testkit/goldens/runtime-observability.json
  • crates/testkit/goldens/settings.json
  • crates/testkit/goldens/update-check-cache.json
  • crates/testkit/goldens/usage-ledger-row.jsonl
  • crates/testkit/src/goldens.rs
  • crates/testkit/src/lib.rs
  • crates/testkit/src/port1455.rs
  • crates/testkit/src/remove_with_retry.rs
  • crates/testkit/src/sandbox.rs
  • crates/tui/Cargo.toml
  • crates/tui/src/ansi.rs
  • crates/tui/src/auth_menu.rs
  • crates/tui/src/auth_menu_builder.rs
  • crates/tui/src/confirm.rs
  • crates/tui/src/format.rs
  • crates/tui/src/lib.rs
  • crates/tui/src/login_prompts.rs
  • crates/tui/src/runtime_options.rs
  • crates/tui/src/select.rs
  • crates/tui/src/theme.rs
  • crates/tui/src/ui_copy.rs
  • crates/usage/Cargo.toml
  • crates/usage/src/ledger.rs
  • crates/usage/src/lib.rs
  • crates/usage/src/pricing.rs
  • crates/usage/src/redaction.rs
  • crates/usage/src/types.rs
  • crates/wrapper/Cargo.toml
  • crates/wrapper/src/account_force.rs
  • crates/wrapper/src/bin_resolver.rs
  • crates/wrapper/src/forward.rs
  • crates/wrapper/src/lib.rs
  • crates/wrapper/src/mcodex.rs
  • crates/wrapper/src/routing.rs
  • crates/wrapper/src/shadow_home.rs
  • crates/wrapper/src/statusline.rs
  • crates/wrapper/src/update_check.rs
  • crates/wrapper/tests/account_force_test.rs

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rust-rewrite
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch rust-rewrite

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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

Copy link
Copy Markdown

Outcome

The trigger reproduces the pull request summary but contains no requested change, review finding, CI failure, or other actionable follow-up. The working tree was already clean, so I did not modify files, create an empty commit, or open a redundant pull request.

Checks

  • git status --short --branch — confirmed branch work has no uncommitted changes.
  • find .. -name AGENTS.md -print — located the applicable repository instructions.
  • git log -3 --oneline --decorate — confirmed HEAD is the supplied PR head commit 92d5fce.
  • git diff --stat — confirmed there is no patch to test, commit, or submit.

View task →


// Best-effort reset-marker unlink (the marker persists across clears
// until this very unlink — spec 02 §3.4).
let _ = fs::remove_file(&reset_marker_path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 stale reset intent hides accounts

when windows antivirus or another process transiently locks the reset-intent marker, this best-effort removal silently fails after the new account file is committed. the next load treats the stale marker as an intentional reset and returns empty storage, making the newly saved accounts and credentials disappear.

Context Used: speak in lowercase, concise sentences. act like th... (source)

Knowledge Base Used: Account Storage Layer

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/storage/src/save.rs
Line: 229

Comment:
**stale reset intent hides accounts**

when windows antivirus or another process transiently locks the reset-intent marker, this best-effort removal silently fails after the new account file is committed. the next load treats the stale marker as an intentional reset and returns empty storage, making the newly saved accounts and credentials disappear.

**Context Used:** speak in lowercase, concise sentences. act like th... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

**Knowledge Base Used:** [Account Storage Layer](https://app.greptile.com/zeian/-/custom-context/knowledge-base/ndycode/codex-multi-auth/-/docs/storage-accounts.md)

How can I resolve this? If you propose a fix, please make it concise.

Fix in Codex

use cma_core::schemas::account_storage::AccountStorageV3;
use cma_core::schemas::flagged::FlaggedAccountStorageV1;

static STORAGE_MUTEX: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 storage lock excludes other processes

when the cli and runtime proxy, or two cli processes, mutate the same account store concurrently, each process acquires its own tokio mutex and independently replaces the shared wal and primary file. a stale read-modify-write transaction can therefore overwrite a newer account selection or credential update.

Context Used: speak in lowercase, concise sentences. act like th... (source)

Knowledge Base Used: Account Storage Layer

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/storage/src/transactions.rs
Line: 33

Comment:
**storage lock excludes other processes**

when the cli and runtime proxy, or two cli processes, mutate the same account store concurrently, each process acquires its own tokio mutex and independently replaces the shared wal and primary file. a stale read-modify-write transaction can therefore overwrite a newer account selection or credential update.

**Context Used:** speak in lowercase, concise sentences. act like th... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

**Knowledge Base Used:** [Account Storage Layer](https://app.greptile.com/zeian/-/custom-context/knowledge-base/ndycode/codex-multi-auth/-/docs/storage-accounts.md)

How can I resolve this? If you propose a fix, please make it concise.

Fix in Codex

Comment on lines +676 to +678
fn escape_windows_batch_path(value: &str) -> String {
value.replace('%', "%%")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 batch paths leave metacharacters active

when a windows installation or user-profile path contains a cmd metacharacter such as &, ^, or |, this helper escapes only percent characters before interpolating the path into the startup .cmd file. cmd.exe alters or splits the command, so the app router does not start and the bound codex desktop app cannot reach its configured provider.

Context Used: speak in lowercase, concise sentences. act like th... (source)

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/runtime/src/app_bind.rs
Line: 676-678

Comment:
**batch paths leave metacharacters active**

when a windows installation or user-profile path contains a cmd metacharacter such as `&`, `^`, or `|`, this helper escapes only percent characters before interpolating the path into the startup `.cmd` file. cmd.exe alters or splits the command, so the app router does not start and the bound codex desktop app cannot reach its configured provider.

**Context Used:** speak in lowercase, concise sentences. act like th... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

**Knowledge Base Used:**
- [Runtime Services](https://app.greptile.com/zeian/-/custom-context/knowledge-base/ndycode/codex-multi-auth/-/docs/runtime-services.md)
- [Codex CLI Integration](https://app.greptile.com/zeian/-/custom-context/knowledge-base/ndycode/codex-multi-auth/-/docs/codex-cli-integration.md)

How can I resolve this? If you propose a fix, please make it concise.

Fix in Codex

Comment on lines +248 to +256
fn lock_for(key: &Path) -> Arc<TokioMutex<()>> {
let mut guard = APP_BIND_LOCKS
.lock()
.unwrap_or_else(|poison| poison.into_inner());
guard
.entry(key.to_path_buf())
.or_insert_with(|| Arc::new(TokioMutex::new(())))
.clone()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 bind lock excludes other processes

when two processes run the app-bind command concurrently, each process owns a separate mutex and both rewrite config.toml and the bind-state file. the last writes can combine configuration and state from different router instances, leaving the recorded hash, port, or client key inconsistent and causing routing or unbind failures.

Context Used: speak in lowercase, concise sentences. act like th... (source)

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/runtime/src/app_bind.rs
Line: 248-256

Comment:
**bind lock excludes other processes**

when two processes run the app-bind command concurrently, each process owns a separate mutex and both rewrite `config.toml` and the bind-state file. the last writes can combine configuration and state from different router instances, leaving the recorded hash, port, or client key inconsistent and causing routing or unbind failures.

**Context Used:** speak in lowercase, concise sentences. act like th... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

**Knowledge Base Used:**
- [Runtime Services](https://app.greptile.com/zeian/-/custom-context/knowledge-base/ndycode/codex-multi-auth/-/docs/runtime-services.md)
- [Codex CLI Integration](https://app.greptile.com/zeian/-/custom-context/knowledge-base/ndycode/codex-multi-auth/-/docs/codex-cli-integration.md)

How can I resolve this? If you propose a fix, please make it concise.

Fix in Codex

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant