Skip to content

Simplify Claude, Codex and Copilot providers (lane G1) - #801

Open
Finesssee wants to merge 35 commits into
simplify/provider-registryfrom
simplify/providers-claude-codex
Open

Finesssee wants to merge 35 commits into
simplify/provider-registryfrom
simplify/providers-claude-codex

Conversation

@Finesssee

@Finesssee Finesssee commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Simplification lane G1: the Claude, Codex and Copilot providers. The goal is to preserve behavior: no persisted format, serde name, CLI output, bridge DTO, user-facing string or error text changes.

Stacked on #795 (simplify/provider-registry, head 733d69a). Land this after #795. The diff below is against that branch.

scripts/local-check.ps1 was not run. The workstation's no-permanent-delete hook blocks it, so I ran its Rust steps one at a time instead (see Commands). pnpm test was skipped because the worktree has no node_modules, and I did not install it.

Summary

  • 35 commits. Most refactors have characterization pins in a separate commit before them; c340721 and 63fdd22 carry their pins in the same commit, and dbb5cb6 has no separate pin commit (its existing tests cover it).
  • Each lever and the dead path (PBG-05) has its own commit.
  • The last five commits are moves only. They split the five target god-files so that their production parts are under about 800 lines. claude/web_api.rs is the one exception, at 853 lines. Two other files are still over 800, claude/oauth/mod.rs (845) and claude/accounts.rs (817); they were not split because Use a standalone saved Claude account for usage when Claude Code credentials are off #788 has them open.

Levers

Lever Commit(s) What changed
PBG-05 c2adfce Deleted the dead typed build_result path in codex/api.rs (-226). Upstream items it implemented: v0.70.0 CHANGELOG lines 1178 (spend-controls endpoint, steipete#2900), 1261 (spend_control.individual_limit, steipete#2737), 1834 (enterprise monthly credit limits). The path had no callers, so behavior is unchanged; see follow-up 1.
PBG-50 63fdd22 codex reset_observations: dropped the dead default_store_path; one shared read_store(blank_is_empty) reader.
PBG-10 1e7f003 pin, c340721 Codex API: one authed_get, a cache-tail helper, subscription wrappers inlined, arms merged.
PBG-11 65db4cc pin, 37b7f8b weekly_reset: one read_state_file, one admission check (same check order), a diagnostics macro table.
PBG-51 de87ae1, 0c76b42 Codex API test fixtures moved onto test_support.
PBG-52 65e2af1 weekly_reset test helpers.
PBG-38 (provider side) dbb5cb6 Copilot: shared request tail (send_json), snapshots() iterator, one slot match.
PBG-67 a0997d1 Copilot snapshot test helpers.
PBG-32 690830c pin, 367cfa9 Claude: one-caller CLI wrappers inlined; environment errors are now a marker table. Auth is still checked before environment.
PBG-14 5eeff08 pin, 334dd2d Claude CLI: find_near_label, label_section and percent_matches replace three hand-rolled section scans.
PBG-34 de5a23a pin, bd66fb6 Dead Claude escape stripping and wrappers removed (strip_ansi is now test-only, in cli_screen tests).
PBG-33 dc699c7 + a91fbe5 pins, bfb9a05 Small Claude folds and window helpers: admin ranked_totals, cli_reset month table, limit_window.
PBG-15 ae3183f pin, a50d8fe Claude web API: shared ensure_success, get and get_json.
PBG-31 4f918f4 pin, 89b2368, 7c2e5d7 claude-swap: one parse_envelope; a non-Windows Infallible guard gives termination one call shape; re-exports trimmed to externally used items.
PBG-53 d6734eb Claude CLI parse and error-state tests are table-driven.
PBG-54 42eaec8 Claude web API tests are table-driven.
PBG-55 241d28b Claude OAuth, refresh, claude-swap sanitize and credentials-store tests are table-driven.
PBG-56 70333ac Shared test builders for quota history, claude-swap projection and login junctions.

God-file splits (moves only)

Commit Before After
7942da8 claude_swap/parser.rs 822 parser.rs 406 + parser_tests.rs 416
8c489b1 claude/web_api.rs 1277 web_api.rs 853 + web_api_tests.rs 424
950c284 copilot/api.rs 1274 api.rs 780 + api_tests.rs 494
f036d67 codex/api.rs 2307 api.rs 408 + api/credentials.rs 287 + api/parse.rs 463 + api/reset_credits.rs 249 + api/tests.rs 940
c858406 claude/mod.rs 2594 mod.rs 636 + cli_probe.rs 568 + cli_binary.rs 116 + cli_text.rs 135 + tests.rs 1164

How the moves were made:

  • Test module paths are unchanged (providers::claude::tests::…, providers::codex::api::tests::… and so on), so test names in the inventory are stable.
  • I checked every split with a line-multiset move check: the trimmed non-blank lines before and after match, apart from the residue listed below.
  • The residue is:
    • pub(super) or pub(in crate::providers::codex) added to moved items that the parent or the sibling tests.rs uses;
    • use lines, and mod lines;
    • super::x paths that became super::super::x (authenticated_http_error, extract_semver);
    • rustfmt re-wraps caused by the 4-space dedent;
    • pub use cli_binary::locate_claude_binary;, which keeps the public path used by cli/tty_runner.rs and the desktop auto_resume.rs;
    • two dropped section-banner comments in codex/api.rs ("Data structures", "Helper functions").
  • Lines inside multi-line string literals in the moved tests were not dedented. They are byte-identical, so they can look over-indented.
  • codex/api/tests.rs (940 lines) and claude/tests.rs (1164 lines) are kept as single files, so related tests stay together. Splitting them further is optional follow-up work.
  • claude/web_api.rs is 853 lines. The rest is cohesive request code, and I left it as is.

To review the splits:

git diff -M --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change simplify/provider-registry...simplify/providers-claude-codex

LOC

Measured with loc.py:

Scope Raw lines Production lines SLOC (non-blank, non-comment)
This PR vs simplify/provider-registry, whole repo -326 (319654 → 319328) -465 -301
rust/src/providers only -326 -465 -301
vs origin/main (local ref), including #795 -3264 -2880 -3036
  • The lever commits are -393 lines. The splits add +67 lines of use, mod and visibility glue.
  • Test lines went up by 139: there are new pin tests, and the split test files have import headers.

Test inventory

The before and after inventories are in W:\pstack-logs\Win-CodexBar\simplify\ (inv-G1-before.txt, inv-G1-after.txt). The after file gives a reason for every removed or renamed test.

Area Before After
providers::claude 248 237 (incl. 1 ignored)
providers::codex 88 90
providers::copilot 22 22
  • Every table merge keeps every original row and assertion.
  • Removed without a table:
    • two dead-path tests in PBG-05. They exercised only the deleted build_result; see follow-up 1.
    • web_extras_keep_routines_in_raw_snapshot. Its input was identical to web_extras_order_oauth_scoped_then_routines, whose full id-list assertion covers it.
  • oauth_extras_keep_routines_in_raw_snapshot became a row of oauth_extras_put_scoped_weekly_before_routines.

Commands

All commands ran from the worktree on Windows (toolchain 1.98.0, x86_64-pc-windows-msvc):

Command Result
cargo +1.98.0 fmt --all --check clean
cargo +1.98.0 clippy --workspace --all-targets -- -D warnings clean
cargo +1.98.0 test -p codexbar lib: 3752 passed, 1 ignored; bin: 1 passed; doc: 0
cargo +1.98.0 test -p codexbar-desktop-tauri 639 passed

The codexbar total is 3754, down from 3763 at the base. All 9 fewer tests are table merges or dead-path tests in this lane; each one is listed with its reason in inv-G1-after.txt. For every split I also ran clippy -p codexbar --all-targets -D warnings and the affected provider tests.

  • I grepped rust/src in apps/desktop-tauri/src. The only source file a frontend test reads is rust/src/core/provider/spec.rs, which this PR does not touch.
  • The non-Windows claude_swap runner path is not compiled locally because there is no Linux target here. Hosted CI is Windows-only, so nothing compiles that path today, including the PBG-31 Infallible guard. A reviewer should run a Linux cargo check on it.

Skipped

  • PBG-27/28/29: Use a standalone saved Claude account for usage when Claude Code credentials are off #788 has their files open.
  • PBG-39 and PBG-44's formatter swap: skipped per the lane ruling.
  • PBG-00 (lifting the dead_code allow): checked locally; 50 warnings remain, so it is not committed.
  • PBG-30: every dedupe target lives in rust/src/managed_process.rs, which is another lane's file.
  • PBG-38 start_flow and PBG-39: these are in shell commands/system.rs, which is another lane's file.
  • Also skipped:
    • merging the two Codex enrich calls: an early return skips apply_reset_credits_window;
    • merging the Codex gate tests into one table: it would lose names and per-entry-point assertions;
    • a Copilot plan-label table: there are no existing tests to fold;
    • PBG-34 removal of unread deserialized fields: it would change serde strictness;
    • PBG-33 admin base_query: rustfmt made it 9 lines longer;
    • PBG-31 from_raw/as_label table: it would lose match exhaustiveness;
    • take_pipe: no gain after the cfg unification;
    • a PBG-56 parser helper: every call is already one line.

Cross-lane requests

  • managed_process.rs: expose create_managed_job, encode_wide_nul and a ProcessJob terminate, kill-on-close and handle API. Both the claude-swap runner and claude/accounts/login/windows_child.rs could then drop their copies (PBG-30).
  • Shell commands/system.rs: inline the one-caller Copilot start_flow (PBG-38, shell side).

Follow-ups (bugs found, not fixed here)

  1. The live Codex path (build_result_from_json) never maps individual_limit to a cost snapshot. Only the deleted dead path did (reference implementation in c2adfce's parent; upstream Decode Codex monthly credit limit from spend_control.individual_limit steipete/CodexBar#2737, Codex EDU monthly usage limit is only returned by the separate spend-controls endpoint steipete/CodexBar#2900).
  2. Codex reset_observations: a blank store file fails load but merges as empty. This PR pins that behavior as is (blank_store_fails_load_but_merges_as_empty).
  3. Claude reset descriptions: the lowercase and original text slices can be misaligned on non-ASCII text.
  4. The Claude Admin API cost ranking breaks ties nondeterministically, because it iterates in HashMap order.

Validation fix round

  • 5e6fc65 moves the cswap list doc line back above parse_account_list (doc only).
  • Body corrected: pin-commit ordering and the PBG-05 upstream references.
  • CircleCI job 1134 failed only on the timing-sensitive TrayPanel.test.tsx resize test; apps/ is byte-identical to base 733d69a, which passed. The new push triggers a fresh run.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: nesszer/Win-CodexBar/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 0835b438-a52e-4cbe-af80-a1cc13385ad0

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • 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

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

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