Declare provider metadata and display name on the adapter

JA
6d 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 jaysbeekay/sure#670. Stacked on jaysbeekay/sure#688 (A3); built on the fork first and sent upstream as part of Track A's native stack on top of we-promise/sure#5005.

Upstream: we-promise/sure#5081 (same commits), in Track A's native stack we-promise/sure#5087.

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.
  • 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.