Declare provider metadata and display name on the adapter

Merged
JA
2d ago
+166-76

Summary

Provider kit Track A, A4: each account provider declares its display name and Provider::Metadata attributes on its adapter, and Provider::Metadata::REGISTRY is derived from those declarations.

Part of #5003

Stacked on #5080 (A3), in Track A's native stack on #5005.

Fork pre-flight: jaysbeekay/sure#689 (same commits, against a mirror of upstream main; its CI, Gatekeeper and review history live there).

What changed

  • declares_connection(key:, name:, ..., panel:, metadata:): name: is required and is the one display name, used as the panel title and as the metadata name. metadata: carries region, kinds, maturity, logo text/colour/icon, domain and tier. panel: is now true or a hash of turbo_id:/auto_open: overrides. A name or key inside metadata: raises ArgumentError.
  • Provider::Factory.metadata_declarations; REGISTRY = the 28 declared account providers + Provider::Metadata::UNDECLARED (Plaid EU, which shares Plaid's connection, and the three property valuation providers).
  • Generator template emits name:, panel: true and placeholder metadata: (region "Global", kinds from --type, maturity :alpha, a two-letter logo_text, with a TODO to set them), so a generated provider passes the completeness test; its missing-declaration warning, the generator guide (including its sample adapter, which lacked the declaration since A1) and the provider-logo guide use the new form.

No visible change. The 23 account providers that had no metadata name gain one; nothing visible reads it (panel rows use the panel title; the configuration path's name || key.titleize gives "Plaid" either way; FinanceKit's "Apple Wallet" is unchanged).

Review fixes (2026-11-15)

  • The generated adapter now declares placeholder metadata:, and the generator's missing-declaration warning shows it, so a generated provider passes "every declared account provider has metadata from its declaration".
  • That test now asserts each field (region, kinds, maturity, logo_text). slice(...).all? dropped a missing key, so Brex with no region passed; it now fails, naming the field.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Old vs new (Rails runner against the removed literal): same 32 keys; every value unchanged except 23 added name: keys; no other difference.
  • Fail-first: "each account provider's display name is both its panel title and its metadata name" failed before (Akahu's metadata name was nil); "metadata from its declaration" failed on the missing metadata_declarations.
  • Mutations, each caught: drop the UNDECLARED merge; metadata without name; panel title not from name; Brex without metadata; the template without name:; no guard on a name inside metadata:.
  • eager_load! then REGISTRY.size = 32.
  • bin/rails test (full): 15,872 runs, 0 failures; 8 errors in ReleaseNotesWorkflowTest from node missing in the test image. After rebasing the stack onto upstream main (dbeebf14c), the full suite at the top of the stack (A9): 16,246 runs, 0 failures, the same 8 environment errors.
  • bin/rubocop on changed files: no offenses. bin/brakeman: no warnings.

Blast radius

  • Provider::Metadata readers: ProviderLogo and logo_url (logo fields, domain), _drawer_header (maturity), settings/providers/show (region, kinds, tier, maturity), Settings::ProvidersController (name only on the configuration path and FinanceKit; maturity for panels). No adapter, concern or initializer reads it at load, so building REGISTRY from the adapters creates no cycle.
  • FAMILY_PANELS (A3) titles now come from name:; the A3 tests pinning Brex, Fio, Trade Republic and SnapTrade still pass unchanged.

Summary by cubic

Account providers now declare their display name and Provider::Metadata attributes on their adapter in declares_connection instead of a literal registry hash, and Provider::Metadata::REGISTRY is derived from those declarations. declares_connection requires name:, which backs both the panel title and the metadata name, while panel: becomes true or a hash of turbo_id/auto_open overrides.

Changes

  • declares_connection raises if name: or key: appear inside metadata:.
  • Provider::Metadata::REGISTRY is built from the 28 account providers' declarations plus hand-written UNDECLARED entries for providers without their own connection (Plaid EU, property valuation providers).
  • The 23 account providers without a metadata name gain one; nothing visible reads these names yet.
  • The generator now writes placeholder metadata (region, kinds, maturity, logo_text) with a TODO, and its missing-declaration warning and the provider guides use the new name:/panel: true form.
  • The completeness test checks each required metadata field individually, so a missing key no longer slips through a slice call.

Summary by CodeRabbit

  • New Features

    • Provider connections now include consistent display names and details such as supported regions, account types, availability, and branding.
    • Provider panels now use a consistent setup across supported connections.
  • Documentation

    • Updated provider setup guides and generator instructions to reflect current connection and branding options.