Skip to content

refactor: single source of truth — eliminate post-fetch filtering and fallback chains#365

Merged
rygel merged 1 commit intodevelopfrom
refactor/single-source-of-truth
Mar 20, 2026
Merged

refactor: single source of truth — eliminate post-fetch filtering and fallback chains#365
rygel merged 1 commit intodevelopfrom
refactor/single-source-of-truth

Conversation

@rygel
Copy link
Copy Markdown
Owner

@rygel rygel commented Mar 20, 2026

Summary

  • Eliminates post-fetch filtering and fallback chains across 5 files
  • ProviderDefinition is now enforced as the authority for PlanType, IsQuotaBased, and display names at the pipeline boundary — not just at provider construction time

Changes

GeminiProvider — stop building objects you'll throw away

Error results from failed Gemini account fetches are no longer added to the results list. The post-loop filter results.Where(r => r.IsAvailable) that discarded them is removed. If all accounts fail, a single CreateUnavailableUsage is returned.

GeminiProvider — explicit OAuth client retry

The catch when clientId == CLI silent fallback is replaced by ResolveOAuthClientsToTry() + DetectPreferredOAuthClientId(). The retry order is now declared upfront and testable.

ProviderUsageDisplayCatalog — single-pass filter

The two sequential passes (ShouldShowInMainWindow then hidden items) are merged into one .Where() predicate.

ProviderMetadataCatalog.ResolveDisplayLabel — 7 levels → 3

  • Canonical providers: definition is authoritative
  • Derived providers: prefer runtime label unless definition declares PreferDisplayNameOverridesForDerivedProviderIds
  • Unknown providers: runtime label → providerId

ProviderUsageProcessingPipeline — definition enforced at pipeline boundary

PlanType and IsQuotaBased now use definition?.PlanType ?? usage.PlanType — the definition wins. Runtime values are only a fallback for dynamic/unknown providers with no registered definition.

ProviderStatusPresentationCatalog — named extraction

Session auth display text resolved in ResolveSessionAuthDisplayText().

Test plan

  • 903 tests pass (4 pre-existing failures unrelated to this change)
  • CI green

🤖 Generated with Claude Code

… fallback chains

- GeminiProvider: stop adding error ProviderUsage objects to the results list;
  only successful fetches enter the results. If all accounts fail, return a
  single CreateUnavailableUsage instead of per-account error cards. Removes the
  post-loop filter (results.Where(r => r.IsAvailable)) which was there solely to
  discard the objects we just built.

- GeminiProvider: make OAuth client retry explicit. Replaces the implicit
  'catch when clientId == CLI' silent retry with ResolveOAuthClientsToTry() +
  DetectPreferredOAuthClientId() so the fallback order is declared upfront and
  visible to callers.

- ProviderUsageDisplayCatalog: combine the two sequential filter passes
  (ShouldShowInMainWindow + hidden items) into a single .Where() predicate.

- ProviderMetadataCatalog.ResolveDisplayLabel: collapse 7-level fallback chain
  to 3 clear branches. Canonical providers always use definition; derived
  providers prefer runtime label unless definition declares overrides; unknown
  providers fall back to runtime label then providerId.

- ProviderUsageProcessingPipeline.NormalizeUsage: enforce PlanType and
  IsQuotaBased from ProviderDefinition at the pipeline boundary. Definition is
  now the single source of truth; runtime values are only used when no definition
  exists (unknown/dynamic providers).

- ProviderStatusPresentationCatalog: extract session auth display text
  resolution into ResolveSessionAuthDisplayText() named method.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Build Performance Report

⏱️ Build Time: 12 minutes

📊 Comparison with main branch:

  • Baseline (avg): 10 minutes
  • Current: 12 minutes
  • Change: 📈 20%

✅ Within acceptable range


This is an automated performance check

@rygel rygel merged commit d339aad into develop Mar 20, 2026
20 checks passed
@rygel rygel deleted the refactor/single-source-of-truth branch March 20, 2026 11:19
@rygel rygel mentioned this pull request Mar 20, 2026
2 tasks
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