Skip to content
This repository was archived by the owner on Jul 30, 2026. It is now read-only.

refactor(usage): make discovery, quotas, and pricing exact - #191

Merged
makoMakoGo merged 2 commits into
personal/local-clientsfrom
codex/consolidate-current-contracts
Jul 23, 2026
Merged

refactor(usage): make discovery, quotas, and pricing exact#191
makoMakoGo merged 2 commits into
personal/local-clientsfrom
codex/consolidate-current-contracts

Conversation

@makoMakoGo

@makoMakoGo makoMakoGo commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

This PR makes the retained ADRs and the runtime describe one current product.
It keeps eight complete ADRs, removes 22 superseded or patch-style ADR files,
and implements the remaining source gaps against
personal/local-clients@a0d60f8d.

The resulting contract is:

  • automatic local input discovery uses fixed paths beneath the selected home;
    additional roots come only from scanner.extraScanPaths, while OpenCode
    database files come only from scanner.opencodeDbPaths;
  • Subscription Usage exists only in the TUI; the root/headless usage command
    and its parallel output surface are removed;
  • subscription providers are exactly claude, codex, zai, grok,
    kimi-coding-plan-key, kimi-coding-plan-credential,
    minimax-token-plan-cn, and minimax-token-plan-global;
  • model identity is canonicalized once, pricing uses exact model IDs with exact
    provider scopes, and an unmatched model displays $0.00; and
  • current cache, report, and TUI schemas replace retired aliases and envelope
    variants instead of carrying compatibility branches.

Behavior

Local acquisition

  • Default client roots are deterministic functions of the selected home.
  • scanner.extraScanPaths supports every local client except OpenCode.
    SQLite and multi-layout clients, including Goose, Kilo, Kiro, CodeBuddy,
    Warp, and Zed, discover current-format inputs from configured roots with
    canonical-path deduplication.
  • OpenCode keeps its file-specific scanner.opencodeDbPaths authority.
  • Warp remains a read-only local warp.sqlite parser. Its per-model total is
    the checked sum of warp_tokens, byok_tokens, and
    custom_endpoint_tokens.
  • The Amp, Copilot, Grok, and Warp local token parsers remain registered.

Subscription Usage

  • Subscription fetching and cache display live inside the TUI Usage tab.
  • Codex reads exactly ~/.codex/auth.json.
  • Grok reads exactly ~/.grok/auth.json, exposes one account, and requests the
    Grok Build billing backend without mutating credentials.
  • Kimi is split into the explicit API-key provider and the fixed
    ~/.kimi-code/credentials/kimi-code.json credential provider.
  • MiniMax CN and Global are separate providers and separate cards.
  • Amp and Copilot subscription providers are removed.
  • Provider fetches are read-only, use a closed cache envelope, preserve the
    installed snapshot on an empty or failed refresh, and expose provider
    failures as diagnostics.

Identity, pricing, and storage

  • Models JSON and TUI storage carry separate modelId and displayName
    fields.
  • Pricing canonicalizes the observed model ID before lookup, then performs
    exact provider-scoped or exact unscoped catalog matching. Prefix, substring,
    and fuzzy price matches are removed.
  • TUI generation storage is schema 47; scan-input message shards use the
    current v9 envelope.
  • The root command grammar is tui, models, pricing, wrapped, and
    cache.

Validation

  • cargo fmt --all -- --check
  • cargo test --workspace --no-fail-fast
    • CLI unit suite: 748 passed, 1 ignored
    • core unit suite: 1,228 passed, 2 ignored
    • all integration and doc-test suites completed without failures
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo build -p tokscale-cli
  • bun run build:cli
  • git diff --check
  • full source and documentation path-authority audit

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 107 files, which is 7 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.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f9d6400-cb14-49c9-8000-326b149020ca

📥 Commits

Reviewing files that changed from the base of the PR and between a0d60f8 and de64c4c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (133)
  • AGENTS.md
  • CONTEXT.md
  • README.md
  • README.zh-cn.md
  • crates/tokscale-cli/Cargo.toml
  • crates/tokscale-cli/src/claude_diagnostics.rs
  • crates/tokscale-cli/src/cli.rs
  • crates/tokscale-cli/src/commands/mod.rs
  • crates/tokscale-cli/src/commands/models.rs
  • crates/tokscale-cli/src/commands/pricing.rs
  • crates/tokscale-cli/src/commands/shared.rs
  • crates/tokscale-cli/src/commands/usage/amp.rs
  • crates/tokscale-cli/src/commands/usage/claude.rs
  • crates/tokscale-cli/src/commands/usage/copilot.rs
  • crates/tokscale-cli/src/commands/usage/grok.rs
  • crates/tokscale-cli/src/commands/wrapped.rs
  • crates/tokscale-cli/src/main.rs
  • crates/tokscale-cli/src/main_tests.rs
  • crates/tokscale-cli/src/paths.rs
  • crates/tokscale-cli/src/tui/app.rs
  • crates/tokscale-cli/src/tui/cache.rs
  • crates/tokscale-cli/src/tui/data/mod.rs
  • crates/tokscale-cli/src/tui/export.rs
  • crates/tokscale-cli/src/tui/mod.rs
  • crates/tokscale-cli/src/tui/settings.rs
  • crates/tokscale-cli/src/tui/subscription_usage/claude.rs
  • crates/tokscale-cli/src/tui/subscription_usage/codex.rs
  • crates/tokscale-cli/src/tui/subscription_usage/grok.rs
  • crates/tokscale-cli/src/tui/subscription_usage/helpers.rs
  • crates/tokscale-cli/src/tui/subscription_usage/kimi.rs
  • crates/tokscale-cli/src/tui/subscription_usage/minimax_tokenplan.rs
  • crates/tokscale-cli/src/tui/subscription_usage/mod.rs
  • crates/tokscale-cli/src/tui/subscription_usage/zai.rs
  • crates/tokscale-cli/src/tui/ui/daily.rs
  • crates/tokscale-cli/src/tui/ui/footer.rs
  • crates/tokscale-cli/src/tui/ui/mod.rs
  • crates/tokscale-cli/src/tui/ui/models.rs
  • crates/tokscale-cli/src/tui/ui/period.rs
  • crates/tokscale-cli/src/tui/ui/usage.rs
  • crates/tokscale-cli/tests/cli_tests.rs
  • crates/tokscale-cli/tests/copilot_memory.rs
  • crates/tokscale-core/src/adapters/antigravity.rs
  • crates/tokscale-core/src/adapters/cache.rs
  • crates/tokscale-core/src/adapters/claude.rs
  • crates/tokscale-core/src/adapters/cline.rs
  • crates/tokscale-core/src/adapters/codebuddy.rs
  • crates/tokscale-core/src/adapters/codebuff.rs
  • crates/tokscale-core/src/adapters/codex.rs
  • crates/tokscale-core/src/adapters/discover.rs
  • crates/tokscale-core/src/adapters/error.rs
  • crates/tokscale-core/src/adapters/file.rs
  • crates/tokscale-core/src/adapters/goose.rs
  • crates/tokscale-core/src/adapters/hermes.rs
  • crates/tokscale-core/src/adapters/junie.rs
  • crates/tokscale-core/src/adapters/kilo.rs
  • crates/tokscale-core/src/adapters/kiro.rs
  • crates/tokscale-core/src/adapters/mod.rs
  • crates/tokscale-core/src/adapters/omp.rs
  • crates/tokscale-core/src/adapters/openclaw.rs
  • crates/tokscale-core/src/adapters/opencode.rs
  • crates/tokscale-core/src/adapters/pi.rs
  • crates/tokscale-core/src/adapters/roocode.rs
  • crates/tokscale-core/src/adapters/warp.rs
  • crates/tokscale-core/src/adapters/zed.rs
  • crates/tokscale-core/src/aggregate/tui.rs
  • crates/tokscale-core/src/aggregate/tui_sessions.rs
  • crates/tokscale-core/src/clients.rs
  • crates/tokscale-core/src/input_health.rs
  • crates/tokscale-core/src/lib.rs
  • crates/tokscale-core/src/lib_tests.rs
  • crates/tokscale-core/src/local_clients.rs
  • crates/tokscale-core/src/message_cache.rs
  • crates/tokscale-core/src/paths.rs
  • crates/tokscale-core/src/pricing/cache.rs
  • crates/tokscale-core/src/pricing/custom.rs
  • crates/tokscale-core/src/pricing/litellm.rs
  • crates/tokscale-core/src/pricing/lookup.rs
  • crates/tokscale-core/src/pricing/lookup_tests.rs
  • crates/tokscale-core/src/pricing/mod.rs
  • crates/tokscale-core/src/pricing/models_dev.rs
  • crates/tokscale-core/src/pricing/openrouter.rs
  • crates/tokscale-core/src/scanner.rs
  • crates/tokscale-core/src/sessions/antigravity_cli.rs
  • crates/tokscale-core/src/sessions/copilot.rs
  • crates/tokscale-core/src/sessions/goose.rs
  • crates/tokscale-core/src/sessions/hermes.rs
  • crates/tokscale-core/src/sessions/kimi.rs
  • crates/tokscale-core/src/sessions/zed.rs
  • crates/tokscale-core/src/usage_views.rs
  • docs/adr/0001-no-silent-fallback.md
  • docs/adr/0002-claude-placeholder-is-not-a-client.md
  • docs/adr/0003-pi-and-omp-are-separate-clients.md
  • docs/adr/0004-cwd-workspace-attribution.md
  • docs/adr/0005-local-client-boundaries.md
  • docs/adr/0006-agent-identity-for-agents-tab.md
  • docs/adr/0007-client-identity-catalog.md
  • docs/adr/0008-single-copy-memory-pipeline.md
  • docs/adr/0009-ahead-only-upstream-policy.md
  • docs/adr/0010-period-views-derive-from-daily.md
  • docs/adr/0012-local-client-exclusions.md
  • docs/adr/0013-pricing-source-authority.md
  • docs/adr/0014-explicit-subscription-usage-boundary.md
  • docs/adr/0015-local-only-product-surface.md
  • docs/adr/0016-juya-ai-npm-release-identity.md
  • docs/adr/0017-fixed-token-bucket-imputation.md
  • docs/adr/0018-bounded-input-fold-pipeline.md
  • docs/adr/0019-current-format-only-local-storage.md
  • docs/adr/0020-input-ingestion-and-integrity-contract.md
  • docs/adr/0022-deterministic-cli-command-semantics.md
  • docs/adr/0023-provider-owned-credentials.md
  • docs/adr/0024-subscription-usage-redesign.md
  • docs/adr/0025-antigravity-cli-only-local-input.md
  • docs/adr/0026-group-by-view-scope-contract.md
  • docs/adr/0027-current-input-discovery-and-graph-semantics.md
  • docs/adr/0028-tui-client-universe-and-view-selection.md
  • docs/adr/0029-keep-claude-discovery-catalog-scoped.md
  • docs/adr/0030-client-input-and-data-health-terminology.md
  • docs/adr/0032-current-kilo-runtime-identity.md
  • docs/adr/0033-tui-canonical-local-report-surface.md
  • docs/cli.md
  • docs/clients.md
  • docs/configuration.md
  • docs/facts/cline.md
  • docs/facts/droid.md
  • docs/facts/kilo.md
  • docs/facts/kimi-code.md
  • docs/fork.md
  • docs/performance/2026-07-10-scan-rss-optimization.md
  • docs/performance/2026-07-21-public-surface-cleanup.md
  • docs/pricing.md
  • docs/upstream/2026-06-22.md
  • docs/upstream/2026-07-10.md
  • packages/benchmarks/README.md

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 codex/consolidate-current-contracts

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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1031897066

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/pricing.md
Comment thread docs/adr/0014-explicit-subscription-usage-boundary.md
Comment thread docs/adr/0014-explicit-subscription-usage-boundary.md Outdated
Comment thread docs/adr/0014-explicit-subscription-usage-boundary.md Outdated
@makoMakoGo
makoMakoGo force-pushed the codex/consolidate-current-contracts branch from 1031897 to b5fff9d Compare July 23, 2026 10:02
@makoMakoGo makoMakoGo changed the title docs(adr): consolidate current architecture contracts refactor(usage): make discovery, quotas, and pricing exact Jul 23, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 37 untouched benchmarks


Comparing codex/consolidate-current-contracts (de64c4c) with personal/local-clients (a0d60f8)

Open in CodSpeed

@makoMakoGo
makoMakoGo merged commit e362e81 into personal/local-clients Jul 23, 2026
10 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant