docs: sync migration plan status

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
zyycn
2026-06-13 10:23:29 +08:00
co-authored by Codex
parent 53511d5c7a
commit 7b8fcda9ab
4 changed files with 22 additions and 19 deletions
File diff suppressed because one or more lines are too long
@@ -3016,9 +3016,9 @@ This pass re-read the TypeScript routes and core modules under `/home/zyy/Codes/
- [ ] Old `/admin/*` settings mutations used the proxy API key as a write gate. Rust must use admin sessions only.
- [ ] Old refresh fallback could be dangerous for one-time refresh tokens if retried after a mid-flight failure. Rust must keep the one-time RT preservation rule and retry only when the request definitely did not reach the server.
- [ ] Old settings exposed proxy and provider knobs that are out of scope. Rust config and API must not keep dead settings as no-op compatibility fields.
- [ ] Old route responses mix multiple body shapes. Rust must keep `/v1/*` OpenAI-compatible and `/admin/*` lower camelCase `code/message/data/requestId`.
- [ ] Empty placeholder modules are not acceptable. A module either owns tested behavior or is removed from the target structure with a documented reason.
- [x] Old settings exposed proxy and provider knobs that are out of scope. Rust config and API keep proxy URL, provider, Ollama, OpenAI official key, proxy API key, and Electron/self-update fields out of the retained settings surface.
- [x] Old route responses mix multiple body shapes. Rust keeps `/v1/*` OpenAI-compatible and `/admin/*` lower camelCase `code/message/data/requestId`, backed by dedicated API contract tests.
- [x] Empty placeholder modules are not acceptable. Current module roots either expose real submodules or owned behavior; no empty Rust source modules remain in `src/`.
---
@@ -10,6 +10,8 @@
**Checkpoint 2026-06-12:** Commit `b9c30ba` completed Tasks 1-3 for the in-scope OpenAI GPT/Codex path: Chat Completions route/translation/output, Responses request field parity, default Responses streaming, Codex context headers, and local-only WebSocket flag serialization cleanup. Commit `350ffbe` completed Task 4: `previous_response_id` requests use WebSocket `response.create` and return SSE-compatible output. Commit `3ecd5b6` partially completed Task 5 for non-streaming `/v1/responses`: 429/402/403 account-state classification and fallback retry across imported accounts. Commit `3960a35` extends the same fallback path to HTTP SSE Responses setup and Chat Completions. Commit `6d18d2c` completes Task 5 policy for WebSocket-backed Responses: handshake upstream errors are classified before request body send, non-history WebSocket requests may fallback accounts, successful handshakes capture rate-limit headers, and `previous_response_id` requests remain account-affine for streaming and non-streaming clients. Commit `1738f24` adds Task 6 cache groundwork: persisted backend model snapshots and cached `/v1/models*` reads. Commit `0b6cc7e` adds Task 7 import compatibility for Sub2API OpenAI OAuth exports and marks the detected source format while ignoring proxy-only fields. Commit `f75db60` adds `/admin/refresh-models` backed by imported accounts. Commit `4b19846` syncs refreshed model-plan allowlists into the runtime account pool. Commit `db6cb98` adds admin account label/status/delete mutations with runtime pool synchronization. Commit `16eb4ed` adds batch delete/status mutations. Commit `8af350d` adds local client API key status/delete mutations. Commit `203270f` adds encrypted account Cookie get/set/delete. Commit `960bbb2` adds local client API key label and batch-delete mutations. Commit `72438c6` adds native and Sub2API account export. Commit `16938e6` adds manual account creation for Codex OAuth tokens. Commit `869b6f8` narrows `POST /admin/accounts` to TS-like `token`/`refreshToken` import semantics for OpenAI GPT/Codex accounts. Commit `e1f35e0` adds deterministic Codex CLI `auth.json` import through the same validated JWT-claim path. Commit `93cfee3` adds admin health-check, per-account refresh, reset-usage, and quota routes for imported Codex accounts. Commit `bfe561d` maps HTTP SSE terminal failures to OpenAI-compatible upstream errors for non-streaming clients while preserving streaming passthrough. Commit `cf5ff0b` adds Rust-local client API key metadata export/import with target-local key rotation. Commit `a32a53c` adds admin-session-gated `/admin/auth/status` and `/admin/auth/logout`, returning sanitized account/pool state and clearing SQLite accounts plus the runtime pool without token exposure. Commit `1d6c301` adds admin-session-gated `/admin/auth/device-login` and `/admin/auth/device-poll/{device_code}` backed by the OpenAI OAuth device-code flow and shared validated account import path. Commit `a3b4d2b` adds `/admin/auth/login-start`, `/admin/auth/code-relay`, `/admin/auth/callback`, and the registered `/auth/callback` redirect path, with in-memory PKCE sessions, OpenAI authorization-code exchange, and shared validated account import.
**Checkpoint 2026-06-13:** Commit `b879dd6` adds admin-session-gated `/admin/accounts/quota-warnings`, computed from cached SQLite quota snapshots and configured warning thresholds without calling the upstream Codex backend.
**Scoped HTTP SSE error update:** Non-WebSocket `/v1/responses` HTTP SSE collection now detects upstream `event: error` and `event: response.failed` terminal frames. Non-streaming clients receive a `502` OpenAI-compatible `upstream_error` body with the upstream message, while streaming clients keep passthrough SSE frames and record the lifecycle event as an upstream SSE failure.
---
@@ -198,7 +200,7 @@ Immediate priority after this audit:
- Modify: `docs/implementation-status.md`
- Modify: `README.md` if route behavior changes
- [ ] Run: `cargo fmt --check`
- [ ] Run: `cargo test`
- [ ] Run: `cargo clippy --all-targets --all-features --locked -- -D warnings`
- [ ] Update implementation status with completed parity items and any intentionally omitted non-goals.
- [x] Run: `cargo fmt --check`
- [x] Run: `cargo test`
- [x] Run: `cargo clippy --all-targets --all-features --locked -- -D warnings`
- [x] Update implementation status with completed parity items and any intentionally omitted non-goals.
@@ -34,7 +34,7 @@ The document should state that `utils` may contain `pagination`, `json`, and `cr
- Delete: `src/pagination.rs`
- Delete: `src/crypto.rs`
- [ ] **Step 1: Add the utils module root**
- [x] **Step 1: Add the utils module root**
```rust
pub mod crypto;
@@ -42,15 +42,15 @@ pub mod json;
pub mod pagination;
```
- [ ] **Step 2: Move pagination helpers**
- [x] **Step 2: Move pagination helpers**
Move `Page<T>`, `encode_cursor`, `decode_cursor`, and `clamp_limit` into `src/utils/pagination.rs` unchanged.
- [ ] **Step 3: Move crypto helpers**
- [x] **Step 3: Move crypto helpers**
Move `CryptoError`, `CryptoResult<T>`, and `SecretBox` into `src/utils/crypto.rs` unchanged.
- [ ] **Step 4: Add JSON string helpers**
- [x] **Step 4: Add JSON string helpers**
```rust
use serde_json::Value;
@@ -72,7 +72,7 @@ pub fn string_at(value: &Value, path: &[&str]) -> Option<String> {
}
```
- [ ] **Step 5: Expose `utils` from the library**
- [x] **Step 5: Expose `utils` from the library**
```rust
pub mod utils;
@@ -93,17 +93,17 @@ Remove the old top-level `pub mod crypto;` and `pub mod pagination;` declaration
- Modify: `tests/*.rs`
- Modify: `tests/common/*.rs`
- [ ] **Step 1: Update source imports**
- [x] **Step 1: Update source imports**
Use `crate::utils::crypto::{CryptoError, SecretBox}` and
`crate::utils::pagination::{clamp_limit, decode_cursor, encode_cursor, Page}`.
- [ ] **Step 2: Update integration test imports**
- [x] **Step 2: Update integration test imports**
Use `codex_proxy_rs::utils::crypto::SecretBox` and
`codex_proxy_rs::utils::pagination::Page`.
- [ ] **Step 3: Remove duplicate JSON helper functions**
- [x] **Step 3: Remove duplicate JSON helper functions**
Import `crate::utils::json::first_string` in `src/service/api_key_service.rs` and
`src/http/admin/accounts.rs`, then delete the local `first_string` and `string_at`
@@ -114,7 +114,7 @@ definitions.
**Files:**
- No source edits after this task unless verification fails.
- [ ] **Step 1: Format**
- [x] **Step 1: Format**
Run:
@@ -122,7 +122,7 @@ Run:
cargo fmt
```
- [ ] **Step 2: Run focused tests**
- [x] **Step 2: Run focused tests**
Run:
@@ -130,7 +130,7 @@ Run:
cargo test --test crypto_test --test account_repository_test --test admin_accounts_import_export_test --test admin_api_keys_route_test
```
- [ ] **Step 3: Run full gate**
- [x] **Step 3: Run full gate**
Run: