Skip to content

🐛 server: fix repeat options on maturity queue - #1182

Open
aguxez wants to merge 1 commit into
mainfrom
maturity-repeat
Open

🐛 server: fix repeat options on maturity queue#1182
aguxez wants to merge 1 commit into
mainfrom
maturity-repeat

Conversation

@aguxez

@aguxez aguxez commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Set explicit startDate values for 24-hour and 1-hour maturity schedulers.
  • Reuse one timestamp and scheduler interval when calculating offsets and start dates.
  • Extend tests to verify the scheduler upsert arguments.

Testing

  • Added assertions for both scheduler configurations in the maturity utility tests.
  • Not run (not requested).

Summary by CodeRabbit

  • Bug Fixes
    • Improved maturity-check scheduling for both 24-hour and 1-hour reminder windows, ensuring jobs are created with the correct timing and payload.
    • Maturity reminders now use a non-negative ttl based on the current time, avoiding incorrect suppression of delayed notifications.
  • Tests
    • Updated and expanded scheduler and delayed-processing scenarios to assert the exact scheduler configuration and expected notification behavior.
  • Release
    • Patch update for repeat/delayed maturity reminders behavior.

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e020098

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@exactly/server Patch

Not sure what this means? Click here to learn what changesets are.

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

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@aguxez, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 31ea75fd-8d61-4f10-af96-541a1359dd33

📥 Commits

Reviewing files that changed from the base of the PR and between 0bcc757 and e020098.

📒 Files selected for processing (3)
  • .changeset/long-carpets-cut.md
  • server/test/utils/maturity.test.ts
  • server/utils/maturity.ts

Walkthrough

Maturity reminder workers now process delayed jobs, notification TTLs clamp to zero for past maturities, and both schedulers use timestamp-aligned start dates. Tests verify delayed processing, notification behavior, scheduler timestamps, and direct scheduler upsert arguments.

Changes

Maturity reminders

Layer / File(s) Summary
Process delayed maturity jobs
server/utils/maturity.ts, server/test/utils/maturity.test.ts
Workers no longer drop jobs outside reminder windows; delayed scan and delivery tests verify processing, and notification TTLs are clamped to non-negative values.
Align maturity schedulers
server/utils/maturity.ts, server/test/utils/maturity.test.ts
Both schedulers derive aligned startDate values from one captured timestamp, with tests asserting upsert arguments and resulting next timestamps.
Record release change
server/test/utils/maturity.test.ts, .changeset/long-carpets-cut.md
Sentry mocks and cleanup are updated, and a patch changeset records the delayed reminder and repeat-options fix.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • exactly/exa#722: Both changes modify the maturity debt-reminder scheduler and worker flow.

Suggested reviewers: cruzdanilo, nfmelendez

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing maturity queue repeat options and scheduler alignment.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch maturity-repeat
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch maturity-repeat

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.

@cruzdanilo cruzdanilo changed the title Align maturity job scheduler start dates with the current interval 🐛 server: fix repeat options on maturity queue Jul 29, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b81546a4-859a-4981-8f6f-4f5a572bf266

📥 Commits

Reviewing files that changed from the base of the PR and between 836f057 and c69da84.

📒 Files selected for processing (2)
  • server/test/utils/maturity.test.ts
  • server/utils/maturity.ts

Comment thread server/utils/maturity.ts
@aguxez
aguxez marked this pull request as ready for review July 29, 2026 11:36
@aguxez
aguxez requested a review from nfmelendez as a code owner July 29, 2026 11:36
@cruzdanilo
cruzdanilo self-requested a review as a code owner July 29, 2026 11:39

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
server/utils/maturity.ts (1)

419-430: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use future maturity-window start dates.

Both sites encode start dates that are already past, causing BullMQ to schedule the initial job immediately rather than at the intended maturity boundary. (raw.githubusercontent.com)

  • server/utils/maturity.ts#L419-L430: remove - every and derive each startDate from maturity * 1000 + offset.
  • server/test/utils/maturity.test.ts#L302-L324: update both expected startDate values to match the corrected maturity-boundary calculation.

Source: MCP tools


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e22b165f-fb5e-4e3f-bd68-8037f49d387e

📥 Commits

Reviewing files that changed from the base of the PR and between c69da84 and bc3a972.

📒 Files selected for processing (3)
  • .changeset/long-carpets-cut.md
  • server/test/utils/maturity.test.ts
  • server/utils/maturity.ts

Comment thread server/test/utils/maturity.test.ts
Comment thread server/utils/maturity.ts
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.87%. Comparing base (836f057) to head (e020098).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
server/utils/maturity.ts 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1182      +/-   ##
==========================================
+ Coverage   70.69%   70.87%   +0.18%     
==========================================
  Files         263      263              
  Lines       11446    11524      +78     
  Branches     3833     3854      +21     
==========================================
+ Hits         8092     8168      +76     
- Misses       3059     3060       +1     
- Partials      295      296       +1     
Flag Coverage Δ
e2e 70.86% <83.33%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3297d808a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread server/utils/maturity.ts
@@ -119,15 +118,6 @@ const worker = observe(
case "check-debts": {
const check = parse(checkDebtsSchema, job.data);
const maturity = (Math.floor(Date.now() / 1000 / MATURITY_INTERVAL) + 1) * MATURITY_INTERVAL;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the scheduled maturity on delayed planner jobs

When a check-debts job is delayed across its maturity boundary, this recalculates maturity from the execution time rather than the scheduled occurrence. Since the stale-job guard was removed, a 24-hour planner resuming just after the original maturity now scans the next maturity and can send a “due in 24 hours” reminder nearly a full interval early. Include the intended maturity in the scheduled job data or reject planners that cross a maturity boundary.

Useful? React with 👍 / 👎.

Comment thread server/utils/maturity.ts
Comment thread server/utils/maturity.ts Outdated
@aguxez
aguxez force-pushed the maturity-repeat branch from e3297d8 to 0bcc757 Compare July 29, 2026 12:19
@aguxez
aguxez force-pushed the maturity-repeat branch from 0bcc757 to e020098 Compare July 29, 2026 12:34
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