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 #5003 (Track B, step 7: the Lunch Flow conversion, models layer, as B1 did for Brex).
Stacked on #5241. Fork pre-flight: jaysbeekay/sure#731 (same branch, same commit; its CI, Gatekeeper review and screenshot history live there).
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.
Summary by cubic
Moves Lunch Flow's connection and account models onto the provider kit's base classes so the provider uses the kit's shared syncer and unlinking logic instead of its own copies. No behavior changes; all existing Lunch Flow tests pass unedited. The stack history reconciliation brings no new code changes to this PR.
LunchflowItemandLunchflowAccountnow inheritProviderItemandProviderAccount, gettingSyncable, shared unlinking, and the account associations from the base.LunchflowItem::Syncerbecomes a thin subclass ofProviderItem::Syncer, keeping Lunch Flow's credential error naming and its limited-investment-data warning via a newcollect_processing_warningshook, a no-op for Brex. The warning covers linkedInvestmentandCryptoaccounts and its count is pinned by tests.- The shared syncer's failure path now records the same
provider_sync_errordebug log entry Lunch Flow's old syncer wrote. LunchflowItem::Unlinkingis deleted; the kit's unlinker does the same work. Unlink results are keyed byprovider_account_idinstead oflfa_id; nothing reads that key.- The model part of the lifecycle contract moves into
ProviderItemModelLifecycleTests, which both Brex's and Lunch Flow's suites include. TheEnableBankingItem::Unlinkingcomment that said it mirrored the deleted Lunch Flow concern is removed.