Skip to content

feat(scheduler): cron-scheduled sweep#6

Merged
mortik merged 1 commit into
mainfrom
feat/cron-sweep
May 28, 2026
Merged

feat(scheduler): cron-scheduled sweep#6
mortik merged 1 commit into
mainfrom
feat/cron-sweep

Conversation

@mortik
Copy link
Copy Markdown
Member

@mortik mortik commented May 28, 2026

Summary

  • Adds src/scheduler.ts with sweepAll(cfg, rest) (factored out of ready.ts) and scheduleSweep(cfg, rest) (wires node-cron to the configured cron expression).
  • events/ready.ts now runs the startup sweep (if sweep.on_startup) and then registers the cron. This ordering matters: the cron only starts ticking after the gateway is up, so timer firings always have a logged-in client to use.
  • 3 new unit tests cover iteration over verifications, error isolation (one verification failing doesn't stop the next), and empty-array safety.

Test plan

  • pnpm test — 35 tests pass (3 new in test/scheduler.test.ts).
  • pnpm lint, pnpm typecheck, pnpm build clean.
  • Live smoke with cron: "* * * * *": bot started → READY at T+1scron sweep scheduled log → scheduled sweep starting fired at the next minute boundary (T+15s). Confirmed via the structured JSON log.

Follow-ups

  • Step 7: /healthz HTTP endpoint.
  • Step 8–11: Dockerfile finalize, Kamal deploy, AppSignal wiring, README polish.

🤖 Generated with Claude Code

Extracts the verifications loop into sweepAll() and adds scheduleSweep()
that wires node-cron to the configured `sweep.cron` expression. The READY
handler runs the startup sweep (when enabled) and then registers the
cron — so the scheduler only starts ticking after the gateway is up.

- src/scheduler.ts: sweepAll + scheduleSweep
- src/events/ready.ts: uses sweepAll for the startup pass, calls
  scheduleSweep at the end
- test/scheduler.test.ts: 3 unit tests covering iteration, error
  isolation between verifications, and empty-array safety

Verified live with cron "* * * * *": fired at the next minute boundary
~15s after start.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mortik mortik merged commit 7bfe788 into main May 28, 2026
1 check passed
@mortik mortik deleted the feat/cron-sweep branch May 28, 2026 08:11
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