Start a Lunch Flow import at the sync's window when it has one

JA
6d ago
+102-7

Summary

Lunch Flow convergence, C1b: a Lunch Flow sync now honours its sync window, as Brex's does. When a sync has an explicit window_start_date, every account's transaction fetch starts there. Without one, nothing changes.

Part of jaysbeekay/sure#670 (Track B, Lunch Flow convergence). Stacked on C1a (jaysbeekay/sure#726) in fork stack #687.

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

Behaviour delta (Lunch Flow)

SyncBeforeAfter
no window (scheduled and manual syncs)the start date from the account's history and the chosen start dateunchanged
with window_start_datethe window was ignoredeach fetch starts at the window's start, overriding the incremental start, as Brex's importer does
a windowed fetch of an account that still needs historyrecorded history_synced_fromno history marker is recorded, because the fetch didn't start at the chosen start date, so the next unwindowed sync still fetches the history

transactions_synced_through is still recorded after every successful fetch: a windowed fetch runs from the window start to now.

What changed

  • LunchflowItem::Syncer passes sync.window_start_date to import_latest_lunchflow_data(sync_start_date:), which passes it to LunchflowItem::Importer.
  • LunchflowItem::Importer#determine_sync_start_date returns the window's start when given. fetch_and_store_transactions records the history marker only for an unwindowed fetch.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Tests (fail-first):

    • New LunchflowItem::ImporterSyncWindowTest:
      • a window sets where a later fetch starts, over the incremental start;
      • a window sets where a first fetch starts, over the chosen start date, and records no history marker;
      • the connection hands its import the window.
    • LunchflowItem::SyncerTest: "the import starts from the sync's window".

    Before the change they fail: unknown keyword: :sync_start_date, and the import was called without the window.

  • Existing tests unchanged: LunchflowItem::ImporterStartDateTest (the unwindowed start-date rules) passes unedited.

  • Mutations, each caught: the window ignored by the importer; a windowed fetch recording history; the connection dropping the window; the syncer dropping the window.

  • bin/rails test (full, at the C1b commit): 16,313 runs, 0 failures; the same 8 ReleaseNotesWorkflowTest errors (no node in the test image).

  • bin/rubocop on changed files: no offenses. bin/brakeman: no warnings.

  • Size: non-test +15 / -7.

  • Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.

Blast radius

  • import_latest_lunchflow_data has one caller, the syncer, and its keyword is optional.
  • LunchflowItem::Importer.new has one app caller.