Repository navigation
chore(usage): decompose services/usage.ts into per-provider usage/* leaves (999 → 253) - #8545
Conversation
|
Verified independently: diff against the merge-base matches your stated +1648/-840 across 22 files exactly, every new *-split.test.ts is additions-only (no existing test line removed), typecheck:core and check:cycles are clean, and all 364 tests across the usage-related suite pass on your branch. Confirmed the two inherited base-red gates (file-size on providers/page.tsx + tokenHealthCheck.ts, db-rules on compressionDetailNormalizers.ts) are untouched by this diff — pre-existing, not caused by this PR. Real production consumers (quotaCache.ts, providerLimits.ts, saturationSignals.ts) only ever import getUsageForProvider, which the dispatcher still exports unchanged, so nothing external breaks. This looks merge-ready — nice clean decomposition, thanks for doing the byte-level faithfulness check up front. |
…an, vertex, xiaomi-mimo, xai, github usage fetchers into usage/* leaves Decompose services/usage.ts (god-file phase 1): move the remaining per-provider usage fetcher/parser logic into co-located leaves under open-sse/services/usage/ so usage.ts becomes a thin dispatcher (imports + USAGE_FETCHER_PROVIDERS + getUsageForProvider switch + __testing re-exports). New leaves (each a pure data transform or independent fetcher, no orchestration): - usage/github.ts getGitHubUsage, formatGitHubQuotaSnapshot, inferGitHubPlanName, shouldDisplayGitHubQuota - usage/crof.ts getCrofUsage - usage/nanogpt.ts getNanoGptUsage - usage/qoder.ts getQoderUsage, parseQoderUserStatusUsage - usage/opencode.ts getOpencodeUsage - usage/deepseek.ts getDeepseekUsage - usage/bailian.ts getBailianCodingPlanUsage - usage/vertex.ts getVertexUsage - usage/xiaomi-mimo.ts getXiaomiMimoUsage - usage/xai.ts getXaiUsage usage.ts re-exports parseQoderUserStatusUsage (named) and threads every helper the existing __testing contract exposes (usage-utils / usage-service-hardening / qoder-usage-quota / xiaomi-mimo-selftrack / xai-usage / vertex-spend suites read them from services/usage). External importers unchanged. open-sse/services/usage.ts: 1065 -> 256 lines (cap 800). npm run check:file-size: OK. typecheck:core: OK. eslint: clean. check:cycles: OK. Added characterization tests (tests/unit/usage-<provider>-split.test.ts) that import each leaf directly and pin its export surface + key edges, mirroring the existing usage-quota-core-split / usage-scalars-split pattern.
f1f6a43 to
05dc3f5
Compare
|
Rebased onto the current release tip ( Re-verified on the rebased head: the 10 |
|
Correction to my comment above: I measured it on pristine detached checkouts with an empty working tree: The gate is in |
|
Thanks @MumuTW — merged into |
…eaves (999 → 253) (diegosouzapw#8545) * chore(usage): extract crof, nanogpt, qoder, opencode, deepseek, bailian, vertex, xiaomi-mimo, xai, github usage fetchers into usage/* leaves Decompose services/usage.ts (god-file phase 1): move the remaining per-provider usage fetcher/parser logic into co-located leaves under open-sse/services/usage/ so usage.ts becomes a thin dispatcher (imports + USAGE_FETCHER_PROVIDERS + getUsageForProvider switch + __testing re-exports). New leaves (each a pure data transform or independent fetcher, no orchestration): - usage/github.ts getGitHubUsage, formatGitHubQuotaSnapshot, inferGitHubPlanName, shouldDisplayGitHubQuota - usage/crof.ts getCrofUsage - usage/nanogpt.ts getNanoGptUsage - usage/qoder.ts getQoderUsage, parseQoderUserStatusUsage - usage/opencode.ts getOpencodeUsage - usage/deepseek.ts getDeepseekUsage - usage/bailian.ts getBailianCodingPlanUsage - usage/vertex.ts getVertexUsage - usage/xiaomi-mimo.ts getXiaomiMimoUsage - usage/xai.ts getXaiUsage usage.ts re-exports parseQoderUserStatusUsage (named) and threads every helper the existing __testing contract exposes (usage-utils / usage-service-hardening / qoder-usage-quota / xiaomi-mimo-selftrack / xai-usage / vertex-spend suites read them from services/usage). External importers unchanged. open-sse/services/usage.ts: 1065 -> 256 lines (cap 800). npm run check:file-size: OK. typecheck:core: OK. eslint: clean. check:cycles: OK. Added characterization tests (tests/unit/usage-<provider>-split.test.ts) that import each leaf directly and pin its export surface + key edges, mirroring the existing usage-quota-core-split / usage-scalars-split pattern. * docs(changelog): add fragment for this PR
…eaves (999 → 253) (diegosouzapw#8545) * chore(usage): extract crof, nanogpt, qoder, opencode, deepseek, bailian, vertex, xiaomi-mimo, xai, github usage fetchers into usage/* leaves Decompose services/usage.ts (god-file phase 1): move the remaining per-provider usage fetcher/parser logic into co-located leaves under open-sse/services/usage/ so usage.ts becomes a thin dispatcher (imports + USAGE_FETCHER_PROVIDERS + getUsageForProvider switch + __testing re-exports). New leaves (each a pure data transform or independent fetcher, no orchestration): - usage/github.ts getGitHubUsage, formatGitHubQuotaSnapshot, inferGitHubPlanName, shouldDisplayGitHubQuota - usage/crof.ts getCrofUsage - usage/nanogpt.ts getNanoGptUsage - usage/qoder.ts getQoderUsage, parseQoderUserStatusUsage - usage/opencode.ts getOpencodeUsage - usage/deepseek.ts getDeepseekUsage - usage/bailian.ts getBailianCodingPlanUsage - usage/vertex.ts getVertexUsage - usage/xiaomi-mimo.ts getXiaomiMimoUsage - usage/xai.ts getXaiUsage usage.ts re-exports parseQoderUserStatusUsage (named) and threads every helper the existing __testing contract exposes (usage-utils / usage-service-hardening / qoder-usage-quota / xiaomi-mimo-selftrack / xai-usage / vertex-spend suites read them from services/usage). External importers unchanged. open-sse/services/usage.ts: 1065 -> 256 lines (cap 800). npm run check:file-size: OK. typecheck:core: OK. eslint: clean. check:cycles: OK. Added characterization tests (tests/unit/usage-<provider>-split.test.ts) that import each leaf directly and pin its export surface + key edges, mirroring the existing usage-quota-core-split / usage-scalars-split pattern. * docs(changelog): add fragment for this PR
Phase 1 god-file decomposition, 1 of 3. Independent of the sibling PRs — disjoint file sets, mergeable in any order.
What
open-sse/services/usage.ts999 → 253 lines. Ten per-provider usage fetchers move intousage/*leaves (crof, nanogpt, qoder, opencode, deepseek, bailian, vertex, xiaomi-mimo, xai, github).usage.tsbecomes a thin provider→fetcher dispatcher.Behavior-preserving move. The public import surface is unchanged —
usage.tsre-exports the symbols that existing tests import fromservices/usage(buildKiroUsageResult,discoverKiroProfileArn,parseQoderUserStatusUsage,glmMonthlyRemainingPercentage).Faithfulness
Mechanically verified rather than eyeballed — every moved function body was extracted from both revisions and compared after normalizing comments/whitespace:
Verification
typecheck:corecheck:cyclescheck-file-sizeservices/usageThe new
*-split.test.tsfiles are characterization tests — they lock the export surface and a couple of edge assertions, and say so in their header comments. They are not the regression guard; the 452 pre-existing tests are, and they are green.Inherited base-red (not from this PR)
release/v3.8.49is currently red on two gates that this branch does not touch:providers/page.tsx(1990 > 1927) andtokenHealthCheck.ts(843 > 841), fixed by chore(quality): ratchet file-size baseline to current code dimensions #8532 / refactor(dashboard): clear file-size base-red by extracting provider-card highlight wiring #8524Both were verified present on the base at branch point.