Generate provider models on the provider kit

JA
5d ago
+275-244

Summary

Provider kit Track B, B6a: the provider:family generator emits a provider's models on the provider kit. The generated connection model inherits ProviderItem and the account model ProviderAccount, so a new provider syncs through ProviderItem::Syncer and unlinks through ProviderItem::Unlinking. The syncer and unlinking templates are deleted outright, with no flag (owner decision, 2026-11-15).

Part of jaysbeekay/sure#670 (Track B, step 6: the generator onto the kit, sliced by layer: B6a models, B6b account flow, then controller and routes, then views). Stacked on the Mercury views slice (jaysbeekay/sure#753) in fork stack #687.

Upstream draft PR: https://github.com/we-promise/sure/pull/5262 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit.

Before / after (what rails g provider:family writes)

BeforeAfter
app/models/<key>_item.rb< ApplicationRecord, including Syncable and Unlinking, with its own #syncer< ProviderItem (which supplies Syncable, ProviderItem::Unlinking and, by constant lookup, ProviderItem::Syncer)
import_latest_<key>_data(sync: nil), passing the sync to the importer(sync_start_date: nil), as ProviderItem::Syncer calls it; the importer is built without the sync, with a TODO to pass the start date on
with_credentials scopenoneevery secret field set (all when the provider declares no secret); ProviderItem::AccountFlow lists connections through it
app/models/<key>_account.rb< ApplicationRecord with its own account_provider / account associations and #current_account< ProviderAccount, which defines all three
app/models/<key>_item/syncer.rb92-line templatenot written; syncer.rb.tt deleted
app/models/<key>_item/unlinking.rb74-line templatenot written; unlinking_concern.rb.tt deleted
Locale: sync messagessync.status.* (read only by the deleted syncer)syncer.*: the keys, plural forms and interpolations ProviderItem::Syncer reads, as Brex's

Existing providers are untouched: this changes only what the generator writes.

What the generated provider gives up, stated

  • Investment stats. The old syncer also collected trade and holding counts for --type=investment; ProviderItem::Syncer collects transaction stats only. A provider that needs more overrides collect_processing_warnings or subclasses the syncer, as Brex and Mercury do for credential errors.
  • The auth-error status flip. The old syncer set status: :requires_update on Provider::<Key>::AuthenticationError. The kit's syncer stores a translated credentials_invalid message when a subclass's credentials_error? says so, and leaves status alone.
  • The disposition: argument on unlink_all!. The deleted unlinking concern accepted disposition: and refused anything but retain. ProviderItem::Unlinking#unlink_all! always retains and takes no disposition. The generated model still includes ProviderDisconnectable with supports_discard = false, so it still advertises retain only; no caller in the app passes a disposition to a family provider's unlink_all! (checked by grep; only FinanceKit's API takes one).

Screenshots

None: no UI change.

Demo data

No demo data needed.

Migration notes

No migration. The generator's migration template is unchanged.

Verification

  • Tests, fail-first. In Provider::FamilyGeneratorTest, five new tests failed on the old templates, each for the right reason (the model still < ApplicationRecord; no with_credentials; syncer.rb still written; no gocardless_items.syncer in the locale) and pass after:
    • the generated item model is a provider kit connection (banking and investment);
    • it counts every connection as credentialed when it has no secret field;
    • the generated account model is a provider kit account;
    • the generator writes no syncer or unlinking concern (and both templates are gone);
    • the generated locale has every syncer message the provider kit reads: the same keys, plural forms and interpolations as brex_items.syncer.
  • Test removed: "the unlinking scaffold renders to valid Ruby and carries the disposition seam" tested the deleted template.
  • Mutations, each caught (7): the item model left < ApplicationRecord; with_credentials ignoring the secret; import_latest_* keeping sync:; the account model left < ApplicationRecord; a syncer key missing from the locale; a plural form dropped; an interpolation dropped.
  • bin/rails test (full, at this commit): 16,527 runs, 0 failures; the same 8 ReleaseNotesWorkflowTest errors (no node in the test image).
  • bin/rubocop on the changed Ruby, bin/brakeman: no offenses or warnings.
  • Size (git diff -C): non-test +46 / -214.
  • Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.

Blast radius

Who else hits these lines, and what do they pass?

  • Only rails g provider:family; nothing in the app loads the templates. The generator's other steps (adapter, migration, importer, processors, jobs) are unchanged; the processors and jobs call current_account, which ProviderAccount defines.
  • Siblings: the generated controller, routes and views still use the old scaffolds and the old panel.* / sync.success keys; the next slices move them onto the kit. docs/api/rails_provider_generator.md already describes the pre-kit models and is updated with the last slice.