feat(scheduler): cron-scheduled sweep#6
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/scheduler.tswithsweepAll(cfg, rest)(factored out ofready.ts) andscheduleSweep(cfg, rest)(wiresnode-cronto the configured cron expression).events/ready.tsnow runs the startup sweep (ifsweep.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.Test plan
pnpm test— 35 tests pass (3 new intest/scheduler.test.ts).pnpm lint,pnpm typecheck,pnpm buildclean.cron: "* * * * *": bot started → READY atT+1s→cron sweep scheduledlog →scheduled sweep startingfired at the next minute boundary (T+15s). Confirmed via the structured JSON log.Follow-ups
/healthzHTTP endpoint.🤖 Generated with Claude Code