Skip to content

fix(pulse): stop the catch-up sweep from pulsing manual and backfill runs - #774

Merged
gkhngyk merged 1 commit into
mainfrom
feature/pulse-catchup-cron-only
Aug 22, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/pulse-catchup-cron-only

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Every newly added brand received two Daily Pulse emails on its first morning: one at the very start of the daily cycle (~02:00 UTC) and one when its own daily run completed an hour or two later. From the second day on, only one arrived — which pointed straight at something that only runs once per run history.

Root cause: the catch-up sweep (runPulseCatchUp) recovers pulses for completed tracking runs that have no pulse row after them, but it never checked the run's source. The onboarding run a brand performs on creation is a full, stamped run with source: 'manual' — and it is deliberately unpulsed (the pulse trigger in job-runner skips immediate/manual runs). The sweep couldn't tell "skipped on purpose" from "missed", so at the start of the next daily cycle it "recovered" the onboarding run as a pulse dated to the creation day. The brand's own first cron run then pulsed normally the same morning with a different window key, so the #701 same-window guard (correctly) saw two different runs and let both through.

Confirmed against production data: 8 of the 9 brands created in the last week show the exact signature — first pulse at 02:00–02:01 with pulse_date = creation day and a window anchored to the onboarding run's completion time, second pulse later the same morning from the brand's own run.

The fix scopes the sweep to source = 'cron' runs: the pulse trigger only ever fires for cron runs, so only cron runs can have a missed pulse. This also excludes backfill runs. The sweep's actual job — recovering cron pulses eaten by a deploy/crash — is unchanged, and brands still get no email on the day they are created (existing intended behavior).

Related issue

None — reported directly.

Type of change

  • fix — Bug fix

How to test

  • cd server && yarn test — new runPulseCatchUp tests cover both directions: manual/backfill runs are never considered, cron runs still are.
  • End-to-end: add a new brand, let onboarding tracking complete; next morning exactly one pulse email should arrive (after the brand's own daily run), with nothing sent at cycle start.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/)
  • Commits follow Conventional Commits
  • yarn lint passes (server)
  • yarn format:check passes (server)
  • yarn test passes (server, 384 tests)
  • Changes are focused — one concern per PR

🤖 Generated with Claude Code

…runs

The pulse trigger only ever fires for cron runs, so a manual run is not a
missed pulse to recover. The sweep did not check the run source, so every
new brand's onboarding run (deliberately unpulsed) was "recovered" at the
start of the next daily cycle — and the brand's own first daily run pulsed
an hour or two later, delivering two emails on the first morning.
@gkhngyk
gkhngyk merged commit ed94396 into main Aug 22, 2026
5 checks passed
@gkhngyk
gkhngyk deleted the feature/pulse-catchup-cron-only branch August 22, 2026 21:40
@gkhngyk gkhngyk mentioned this pull request Aug 24, 2026
7 of 12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant