Skip to content

fix(usage): declare the Adobe Firefly usage fetcher the dispatcher already calls - #12321

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
maxmad64bis:fix/usage-fetcher-registration
Sep 1, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
maxmad64bis:fix/usage-fetcher-registration

Conversation

@maxmad64bis

@maxmad64bis maxmad64bis commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

usage/fetcherProviders.ts says of itself that it exists "so the registration list can't drift from the dispatcher's switch statement", and asks whoever adds a case to remember to add it here too.

It drifted. #8006 added adobe-firefly and firefly to the dispatcher and to USAGE_SUPPORTED_PROVIDERS, but not to this list. So the connection UI says usage is supported while the provider-plugin manifest, genericQuotaFetcher and the free-access quota cache all report no usage fetcher — when getUsageForProvider will happily call getAdobeFireflyUsage for either id.

Nothing suggests this was deliberate. git log -S adobe-firefly on both files turns up exactly one commit, the one that added the feature. No guard, no comment, no test excludes them.

Declaring them is what makes the balance actually get fetched: registerGenericQuotaFetchers wires a generic fetcher for every declared id, and resolveFreeAccessState stops returning early. That's the intended effect, not a side effect — worth stating plainly since two more providers now take part in quota refreshes.

The test is the enforcement the docstring asked for in prose. It reads the dispatcher's cases from the source and compares both directions, so a case without a declaration fails, and so does a declaration the dispatcher would never reach.

It also records the differences between this list and USAGE_SUPPORTED_PROVIDERS, each with a reason. Those sets aren't meant to converge — aggregators like openrouter have a fetcher without being surfaced as a usage-reporting account — but an unexplained difference now fails, so the next drift can't hide among the accepted ones. xiaomi-mimo-token-plan is in there as a real gap: declared supported, no fetcher. Left alone rather than widen this PR.

Related Issues

Validation

  • Change type: provider
  • Focused tests and category gates from the golden path
  • npm run lint
  • Reconciled with the current active release base; focused checks rerun afterward
  • Production-code changes include a new or updated automated test in this PR

Red before green: 2 of 4 cases failed on the unmodified list — the undeclared pair, and the unexplained difference between the two sets. After adding the two ids, 4/4. Measured on the base: the dispatcher handles 49 ids, the list declared 47, USAGE_SUPPORTED_PROVIDERS lists 46.

npm run lint exits 2 here and on an untouched checkout of the base alike (suppressions left that do not occur anymore, zero reported errors).

Tests Added Or Updated

  • tests/unit/usage-fetcher-registration-coverage.test.ts (new, 4 cases)

Coverage Notes

The production change is two strings in a const array. The test covers the invariant that array exists to hold, in both directions, plus the recorded divergences and a staleness check so they can't outlive the difference they explain.

Reviewer Notes

  • The test reads usage.ts as text rather than importing it: pulling in the dispatcher drags its whole fetcher graph — DB, sockets, child_process — which is exactly the weight fetcherProviders.ts was extracted to avoid.
  • It anchors on switch (provider) { and stops at that switch's closing brace. Anchoring on the first switch would land in a doc comment twenty lines above, and running to end-of-file would let a future switch contribute cases to an invariant that isn't about it.
  • Neighbours feat(providers): expose usage-supported in provider plugin manifest #12214 and feat(usage): add Kilo Code balance and Kilo Pass quotas #12178 touch the same file for different reasons; no overlap with these two lines.

@maxmad64bis
maxmad64bis force-pushed the fix/usage-fetcher-registration branch from 54ccbd1 to f2c31f3 Compare September 1, 2026 14:20
@diegosouzapw
diegosouzapw merged commit 78a0e4b into diegosouzapw:release/v3.8.51 Sep 1, 2026
16 checks passed
@maxmad64bis
maxmad64bis deleted the fix/usage-fetcher-registration branch September 24, 2026 21:16
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…ready calls (diegosouzapw#12321)

usage/fetcherProviders.ts exists, in its own words, "so the registration list can't drift from the dispatcher's switch statement". It drifted: diegosouzapw#8006 added adobe-firefly and firefly to the dispatcher and to USAGE_SUPPORTED_PROVIDERS but not to this list, so the connection UI advertised usage support while the provider-plugin manifest, genericQuotaFetcher and the free-access quota cache all reported no fetcher — for two ids getUsageForProvider would happily serve.

Declaring them is what makes the balance actually get fetched (registerGenericQuotaFetchers wires a generic fetcher per declared id, and resolveFreeAccessState stops returning early), which the PR states plainly rather than burying as a side effect.

The test turns the docstring's prose invariant into enforcement: it reads the dispatcher's cases from source and compares both directions, and records each accepted difference against USAGE_SUPPORTED_PROVIDERS with a reason plus a staleness check, so the next drift can't hide among them. xiaomi-mimo-token-plan is left flagged as a real gap rather than widening the PR.

Verified in a combined batch worktree: 174/174 focused tests across all 11 PRs of this batch, typecheck:core clean, complexity 2706/3218, cognitive-complexity 1221/1437, check:cycles and check:docs-counts green.

Thanks @maxmad64bis.
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.

2 participants