Skip to content

Simplify misc providers: cursor, alibaba, zai, qwencloud and seven more (lane G3) - #804

Open
Finesssee wants to merge 72 commits into
simplify/provider-registryfrom
simplify/providers-misc
Open

Finesssee wants to merge 72 commits into
simplify/provider-registryfrom
simplify/providers-misc

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Lane G3 of the provider simplification: groups 6 and 7 (cursor, alibabatokenplan, zai, qwencloud, codebuddy, doubao, sub2api, zoommate, factory, bedrock, gemini, kiro, infini). Behavior-preserving: no persisted formats, serde names, CLI output, bridge DTOs, user-facing strings or error text change.

Lands after #795. This branch is stacked on simplify/provider-registry (now at 27f9ad9, after its merge of main). Base this PR's review on that branch; retarget to main once #795 merges.

Levers done

Item Provider What changed
PBG-02 zai Deleted the unused mcp_details module (and its 5 own tests)
PBG-24/61 zai Dead URLs and MissingToken; one endpoint-override parser; limit-unit table; test helpers and tables
PBG-04 kiro Deleted the unused CLI version API; renamed version.rs to cli_path.rs (path helpers kept)
PBG-45 kiro Dead config path, one spawn helper, JSON string readers behind a trim flag
PBG-25/26/62 cursor Dead browser-cookie path, the %SZ date fallback that can never parse, infallible result builder, shared on-demand helpers, WAL sidecar helper, test event()
PBG-07 alibabatokenplan JSON walkers through one deep_find
PBG-47 alibabatokenplan One console POST helper, one payload decoder, inlined optional wrapper, fetch_via routing
PBG-63 alibabatokenplan Region, CLI and envelope test tables (every row kept)
PBG-06 qwencloud JSON walkers through one deep_find; console posts through one closure (replaces post_api_optional)
PBG-42 qwencloud, alibabatokenplan cornerstoneParam built with json!, after a characterization test pinned the full params string. One lever over the two copies of the same builder: -7 combined (alibaba -5, qwencloud -2)
PBG-44 codebuddy One env path reader (formatter swap skipped, below)
PBG-19 doubao Calls the shared providers::resolve_api_key (identical); dropped the product scan that discarded its message
PBG-12 sub2api One rate-limit window builder; merged unknown-kind totals arms; dropped renames equal to the field name (no rename_all on these structs)
PBG-40 zoommate Borrowed &RequestContext; bearer-cache invalidation without re-matching; preferred host moved to front; failover through the tested should_failover
PBG-41 factory One GET-and-decode helper; one auth-and-usage helper for web and API
PBG-09 bedrock Golden SigV4 Authorization test first, then one signed_post and one canonical-header template
PBG-43 bedrock json_str helper, shared missing-credentials error, infallible AWS CLI path lookup
PBG-16 gemini Characterization tests first; one fnm-root fn with cfg; shared window closures; RFC 3339-only reset parse (the %SZ branch could never yield a DateTime); UsageSnapshot return instead of a 4-tuple
PBG-68 codebuddy, doubao, factory mock_usage and probe_with test helpers; removed the duplicate Factory sources test
test_infini infini rust/tests/providers/test_infini.rs was never compiled (no rust/tests target wiring). Its 8 cases moved into infini.rs tests; the 4 single-assert identity cases fold into one test. File moved to the Recycle Bin

Dead-module deletions (lead-approved)

PBG-01 to PBG-05 are approved by the lane lead in the LANE-G rulings: one module per commit, named here so each can be reverted alone.

Commit Module Port ledger
a5edb93 Delete unused zai MCP details module zai/mcp_details.rs (no callers) No port-audit ledger tracks it. The only hit is the copied upstream CHANGELOG's original z.ai launch note ("MCP details submenu", macOS), which this Windows module never surfaced
59411b0 Delete unused Kiro CLI version API kiro/version.rs version API (KiroVersion, detect_version, get_version, is_installed, is_compatible, CLI_VERSION, reset_cache); KiroProvider never overrides Provider::detect_version No ledger hits. The path helpers stay and move to cli_path.rs in 331eaea

Skipped, with reasons

  • PBG-25 deserialize_opt_f64 swap: not identical (no trim; errors on bool/array/object).
  • PBG-25 team_budget dashboard_post: team_budget.rs already sends every dashboard POST through one fetch_team_dashboard; nothing left to merge.
  • PBG-42 / PBG-44 format::number swaps: ties-to-even differs from the JS-style rounding; no characterization proved identical output.
  • PBG-42 qwencloud Default derive: lane A spec block.
  • PBG-49 unread serde field removals: they gate decode leniency.
  • PBG-12 Parsed*/Response collapse: per-field leniency differs.
  • PBG-16 path-join helper: adds lines. Shared jwt_payload for zoommate/gemini: base64 alphabet handling differs.
  • Under the 3-line rule: sub2api subscription table, zoommate send_json, factory mirrored branches, doubao coding-plan lane table (2 lines), alibaba typed PercentWindow (+4 after rustfmt).

Splits (moves only)

  • Test modules moved to sibling tests.rs files (same module path, so test names are unchanged): qwencloud, codebuddy, doubao, alibabatokenplan, sub2api, zoommate, factory, bedrock, gemini/api/tests.rs, cursor/api/tests.rs.
  • Production: qwencloud/fields.rs (375 lines, JSON field lookups), alibabatokenplan/fields.rs (341), doubao/arkcli.rs (239, arkcli usage plan fallback). Helpers not named outside their module are private.
  • Every owned file is now at or under 800 lines (largest: cursor/token_cost.rs 799, codebuddy/mod.rs 780).
  • apps/desktop-tauri/src references none of the moved or removed rust/ paths.

LOC

Measured with the program's loc.py (raw lines; prod vs test).

Ref Raw Prod Test SLOC
current base simplify/provider-registry (27f9ad9) 322,464 199,587 122,877 276,845
this branch (HEAD) 321,036 198,494 122,542 275,588
delta vs base -1,428 -1,093 -335 -1,257
delta vs 733d69a (original stack point) +1,382 +254 +1,128 +1,222
delta vs origin/main (includes #795's own savings) -2,313 -1,923 -390 -2,507

The +1,382 against 733d69a is the base branch's own merge of main (+2,810); none of those files overlap this branch.

loc.py counts all of infini.rs as prod because its test module carries an #[allow] between #[cfg(test)] and mod tests {. Corrected, infini is prod 0 / test -19, so the delta is prod -1,193, test -235.

Provider Prod Test
zai -454 -179
kiro -253 -70
qwencloud -109 +34
alibabatokenplan -81 -4
gemini -55 +136
bedrock -54 +40
cursor -50 -95
doubao -43 -21
zoommate -38 -3
sub2api -26 -6
factory -21 -12
codebuddy -9 -36
infini (corrected) 0 -19

Test inventory

cargo test -p codexbar -- --list | grep ': test' | wc -l: 3,763 at 733d69a, 3,808 at HEAD. Of the +45, +49/-1 come from the base's main merge (amp, groq, kilo, settings); the owned directories net -3.

Dir Before After Reason
zai 47 42 -5: the deleted mcp_details module's own tests
kiro 24 17 -7: tests of the deleted version API (parse, compare, display); windows_rejects_gui_kiro_binary_as_cli moved to cli_path
alibabatokenplan 31 30 -2: two pairs merged into tables (nested_gateway_errors_surface_without_auth_eviction, success_envelope_is_transient_only_without_windows), every input and expected row kept; +1 params characterization
factory 12 11 -1: available_sources_include_auto_api_and_web repeated the no-CLI sources test
qwencloud 12 13 +1 params characterization
bedrock 14 15 +1 golden SigV4 Authorization test
gemini 10 14 +4 quota-bucket characterization tests
infini 6 11 +5: the 8 cases from the uncompiled rust/tests/providers/test_infini.rs; 4 single-assert identity tests fold into provider_identity_and_sources
cursor, codebuddy, doubao, sub2api, zoommate 57, 21, 14, 10, 11 same helpers and file moves only; test names unchanged

Inventories: W:\pstack-logs\Win-CodexBar\simplify\inv-G3-before.txt, inv-G3-after.txt.

Commands run

All through the lane's private cargo wrapper (Rust 1.98.0, isolated target dir), one at a time, on HEAD after the rebase:

Command Result
cargo fmt --all --check pass
cargo clippy --workspace --all-targets -- -D warnings pass
cargo test -p codexbar 3,806 passed, 1 ignored (lib); 1 passed (bin)
cargo test -p codexbar-desktop-tauri 641 passed
cargo test -p codexbar -- --list 3,808 entries
grep apps/desktop-tauri/src for moved rust/ paths no hits

scripts/local-check.ps1 was not run (blocked on this machine by the no-permanent-delete hook). No UI surface changed, so no CUA proof applies.

Cross-lane requests

  • Lane PXC: one shared providers::json_walk / fields module. qwencloud/fields.rs and alibabatokenplan/fields.rs are near-identical, and the same walkers exist in deepgram, deepseek, elevenlabs, llmproxy, minimax and xkiro.
  • A shared Alibaba-family console POST, payload decoder and cornerstoneParam builder (qwencloud, alibabatokenplan, alibaba).
  • A shared JWT payload decoder that takes the base64 alphabet as a parameter (zoommate, gemini, codex_accounts::credentials).

Follow-up bugs (not fixed here)

  • format_count prints -,123 for negative values.
  • Cursor: api.rs and team_budget.rs each define BASE_URL = "https://cursor.com", and mod.rs repeats the COOKIE_DOMAINS literal. A small dedupe left for a follow-up.
  • Factory's eager .or(...await) always sends the app-host auth request, even when the first host succeeds. Pre-existing at the base (factory/mod.rs:505 on simplify/provider-registry); the refactor kept it as is.

chrono's DateTime::parse_from_str needs an offset in the format, so
%Y-%m-%dT%H:%M:%SZ returns NotEnough for every input.
The second chrono pattern had a literal Z and no offset, so it could never produce a DateTime; RFC 3339 already accepts those strings.
rust/tests/providers/test_infini.rs was never compiled (no rust/tests/providers.rs entry). Its eight cases still hold; they now run as async mockito tests, with the four single-assert identity checks folded into one test.
@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: 3905e2ac-07d9-407c-94e7-0bdf1e31e9da

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