Skip to content

feat: implement cron window spread backend - #4566

Merged
carderne merged 22 commits into
mainfrom
feat/cron-windows
Aug 12, 2026
Merged

feat: implement cron window spread backend#4566
carderne merged 22 commits into
mainfrom
feat/cron-windows

Conversation

@carderne

@carderne carderne commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add the backend plumbing for cron schedule spreading/delaying.

Changes

  • New DB fields on Schedule and ScheduleInstance
  • Use queueTimestamp for the "effectiveAt" delayed start time, propagate it to Clickhouse TaskRun table
  • Disable fastpath for delayed jobs
  • Add schedule timing logic, API endpoints with windows, persistence
  • Calculate phase for every schedule, only persist when window is non-null
  • Additional o11y for phased rollout

Flag

  • default off, window will still be accepted by API inert
  • phase will still be calculated and logged but no effect

When switched on:

  • ALL schedules will get phased within a 60s delay
  • Schedules with a non-null window will get phased within that window

TODO:

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 28d307a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The change adds schedule windows with duration and percentage formats, validation, persistence, and API presentation. The schedule engine now calculates nominal and effective schedule times, derives deterministic phases, and propagates both timestamps through scheduling and triggering. Task runs now store nullable queue timestamps in ClickHouse. Queue handling records queue wait time and prevents fast-path delivery for future messages. Tests cover schedule timing, recovery, queue timestamps, and future queue eligibility.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description summarizes the implementation but omits the required checklist, Testing, Changelog, Screenshots, and issue reference sections. Add the required template sections, include testing steps and results, provide a changelog entry, and add the issue reference or state that none applies.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: backend support for cron window spreading.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cron-windows

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@6d46620

trigger.dev

npm i https://pkg.pr.new/trigger.dev@6d46620

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@6d46620

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@6d46620

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@6d46620

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@6d46620

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@6d46620

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@6d46620

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@6d46620

commit: 6d46620

coderabbitai[bot]

This comment was marked as resolved.

@carderne
carderne marked this pull request as ready for review August 11, 2026 14:17
coderabbitai[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Observability map

As of 28d307a.

Nothing in this pull request moves the report any more. The findings an earlier push reported are gone.

The score and findings here are report-only and never gate the merge. Separately, a required test suite keeps this tool's symbol and route lists in sync with the code they name, and can fail a pull request that renames or removes a symbol they reference, or that adds the first route with a segment they anticipate. Each failure names the list to edit. The rules and their reasons: internal-packages/observability-map/README.md.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@carderne
carderne changed the base branch from main to fix/tailwind-dep August 12, 2026 09:44
Base automatically changed from fix/tailwind-dep to main August 12, 2026 09:52
The merge with #4577 (scope declarative schedule sync to the current
environment) narrowed the existingDeclarativeSchedules findMany to a
select that omitted generatorExpression, timezone, windowDurationSeconds
and windowPercentage. The timingChanged comparison reads those fields to
decide whether to preserve the existing Redis job, so they must be
selected.
devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment thread internal-packages/schedule-engine/src/engine/index.ts
@carderne
carderne merged commit ed1bb72 into main Aug 12, 2026
52 checks passed
@carderne
carderne deleted the feat/cron-windows branch August 12, 2026 11:24
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.

2 participants