Move Lunch Flow's models onto the provider kit base classes
Summary
Provider kit Track B, B7a: Lunch Flow's connection and account models move onto the provider kit's base classes, and Lunch Flow drops its own syncer body and unlinking concern for the kit's. A pure move: no behaviour changes, and every existing Lunch Flow test passes unedited. The Lunch Flow convergence slices (C1a–C1c) made Lunch Flow's syncer identical to the kit's, which is what lets this be a move.
Part of jaysbeekay/sure#670 (Track B, step 7: the Lunch Flow conversion, models layer, as B1 did for Brex). Stacked on C2b (jaysbeekay/sure#730) in fork stack #687.
Upstream draft PR: https://github.com/we-promise/sure/pull/5242 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit.
What changed
LunchflowItem < ProviderItem(it getsSyncableandUnlinkingfrom the base) andLunchflowAccount < ProviderAccount(it getsaccount_provider,accountandcurrent_accountfrom the base;linked_accountstays).LunchflowItem::Syncer < ProviderItem::Syncer, a thin subclass, asBrexItem::Synceris. It keeps the constant andSafeSyncError, names Lunch Flow's credential errors, and keeps Lunch Flow's investment data-quality warning through a new kit hook,collect_processing_warnings(a no-op by default, called right after processing, where Lunch Flow called its warning).app/models/lunchflow_item/unlinking.rbdeleted;ProviderItem::Unlinkingdoes the same work.EnableBankingItem::Unlinkingsaid it mirrored the deleted Lunch Flow concern; that line goes (it does not mirror the kit's either).- Tests: the model half of the kit's contract (connection on its own table, sync, provider error text, unlink, dry run, destroy) moves into
ProviderItemModelLifecycleTests, whichProviderItemLifecycleTestsincludes, so Brex runs exactly the same tests; Lunch Flow includes the model half now and the rest when its account flow moves.
Demo data
No demo data needed.
Migration notes
No migration. Sync and AccountProvider rows keep recording LunchflowItem and LunchflowAccount.
Verification
- Existing tests unedited:
git diffoftest/touches no existing Lunch Flow test. The Lunch Flow model, syncer, importer, processor, controller and cache tests, with Brex's andProviderItemTest: 207 runs, 0 failures. - Contract (fail-first): new
LunchflowItem::LifecycleTestincludesProviderItemModelLifecycleTestsand adds "a sync warns when a linked account is an investment account". The warning test checks both sides: no warning for a linked depository account, the warning once it is an investment account. On the old models all 7 fail (to be a kind of ProviderItem, not LunchflowItem,undefined method 'provider_accounts'/'provider_key'). - Mutations, each caught: the kit never calling the warnings hook; Lunch Flow's hook not overriding it; the hook warning for every account type (all three by the warning test); Lunch Flow's credential errors not named (
LunchflowItem::SyncerTest, rejected key). bin/rails test(full, at the B7a commit): 16,337 runs, 0 failures; the same 8ReleaseNotesWorkflowTesterrors (nonodein the test image).bin/rubocopon changed files: no offenses.bin/brakeman: no warnings.- Size: non-test +10 / -215 (205 lines removed net).
- Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.
Blast radius
Family::Syncer.syncable_item_associationsstill findslunchflow_items(asserted in the contract).Family::FinancialDataReset,DestroyJob/DestroyableLaterandProviderDisconnectablereachLunchflowItemthrough its own class, unchanged.unlink_all!results now key each entryprovider_account_idinstead oflfa_id; nothing reads that key (LunchflowItemsController#destroyignores the result). Thelfa_idinLunchflowAccount::Investments::HoldingsProcessoris a separate log payload.- Siblings:
ProviderItem::Syncer's new hook is a no-op for Brex.
Review notes
A code review of the diff before commit raised eight points. Taken: the warning test now asserts both sides (and stubs schedule_account_syncs), and the inaccurate "Mirrors" comment in Enable Banking's unlinking is dropped rather than repointed. Declined, each the kit's existing behaviour that this move adopts as Brex's B1 did:
- the
lfa_id→provider_account_idresult key (no reader; see Blast radius); - the kit's unlinker looks up links inside its per-account rescue, so a DB error there is recorded in
result[:error]instead of raising todestroy, which rescued and logged it anyway; - the warning hook gets an unloaded relation and Lunch Flow calls
current_accountper row: the same queries Lunch Flow's syncer ran before; - a shared investment-warning helper for CoinStats and SimpleFIN: their own provider moves.
Unrelated dead code noticed: LunchflowAccount has_one :linked_account has no caller; left alone.