Generate a stubbed account flow on the provider kit

JA
5d ago
+147-2

Summary

Provider kit Track B, B6b: provider:family writes a stubbed account flow. <key>_item/account_flow.rb subclasses ProviderItem::AccountFlow and defines every hook the kit needs: .cache_sensitive_params returns the declared fields, and each other hook is a stub that raises NotImplementedError naming the hook, under a TODO that says what it must return (owner decision, 2026-11-15, as A4 does for placeholder metadata).

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 B6a (jaysbeekay/sure#754) in fork stack #687.

Upstream draft PR: https://github.com/we-promise/sure/pull/5263 (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/account_flow.rbnot written (the generated controller did the selection and linking inline)a ProviderItem::AccountFlow subclass: .cache_sensitive_params returns the declared fields; five stubs: #fetch_accounts, #resolve_item, #provider_error_class, #upsert_provider_account!, #provider_account_snapshot_changed?
Calling an unwritten hookn/aNotImplementedError: TODO: GocardlessItem::AccountFlow#fetch_accounts, raised by the provider's own stub, not the base class
<Key>Account.name_for, .currency_for, .default_accountable_attributesnot defineddefaults the flow reads (:name, :currency or "USD", {}), under a TODO to match the API's field names
Generator summarylists the account flow and says to implement its hooks

What changed

  • lib/generators/provider/family/templates/account_flow.rb.tt (new) and the generator step that writes it, beside the importer.
  • account_model.rb.tt: the three class methods ProviderItem::AccountFlow calls on the provider account class.

Screenshots

None: no UI change.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Tests, fail-first. Four new tests in Provider::FamilyGeneratorTest. Three failed before the change (the template missing, Errno::ENOENT; the generator writing no account_flow.rb; the account model without name_for); the fourth, on .cache_sensitive_params, was added after Gatekeeper review 6941039840. All pass after:
    • "the generated account flow stubs every hook the provider kit needs": loads the rendered flow in an isolated namespace and, for each of the five stubbed hooks, checks the generated class defines it itself (the base class also raises NotImplementedError, so raising alone would prove nothing) and that it raises a TODO naming that hook; "the generated account flow expires the account cache on the declared fields" checks .cache_sensitive_params is defined by the generated class and returns the declared fields (added after Gatekeeper review 6941039840);
    • "the generator writes the account flow";
    • "the generated account model answers the account flow's payload questions".
  • Review fix (full review 6949187413): the generator's summary gives the account flow its own step, "4. Implement the account flow", instead of listing it under the Importer step. Pinned by "the summary gives the account flow its own step after the importer", which failed before.
  • Mutations, each caught (5): a hook left to the base class; cache_sensitive_params left to the base class; a stub returning [] instead of raising; a stub without its TODO; the generator not writing the file.
  • bin/rails test (full, at this commit): 16,530 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: non-test +68 / -0.
  • The earlier merge-down commits' subjects ("Merge up/... into up/...") exceed 72 characters. They stay fork-only: Track B is rebased linear when it goes upstream, as Track A was, so they never reach we-promise/sure.
  • Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.

Blast radius

  • Only rails g provider:family. The generated controller still does its own selection and linking in this slice; the next slice replaces it with ProviderItemsController, which is what calls the flow.