Skip to content

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

Merged
cruzdanilo merged 2 commits into
mainfrom
maturity-repeat
Jul 29, 2026
Merged

🐛 server: fix repeat options on maturity queue#1182
cruzdanilo merged 2 commits 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 schedule push timing using a non-negative TTL, preventing unintended suppression of delayed notifications.
    • Updated reminder-window behavior to process due work more reliably.
  • Tests
    • Strengthened scheduler and delayed-processing tests to validate exact job/scheduler configuration and expected notification outcomes.
  • Chores
    • Upgraded BullMQ to a newer version.
  • Release
    • Patch release for repeat/delayed maturity reminders improvements.

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6a3bc08

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: 53 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: 3dc0fb39-c562-4a30-91a6-532a79fd38d7

📥 Commits

Reviewing files that changed from the base of the PR and between 0b42a55 and 6a3bc08.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • .changeset/long-carpets-cut.md
  • .changeset/sunny-sites-shine.md
  • server/package.json
  • 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 arguments, and Sentry mock updates.

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, planner, and delivery tests verify processing, while notification TTLs are clamped to non-negative values.
Align maturity schedulers
server/utils/maturity.ts, server/test/utils/maturity.test.ts
Both schedulers use one captured timestamp, shared intervals, aligned startDate values, and explicit upsertJobScheduler assertions.
Validate and record the change
server/test/utils/maturity.test.ts, server/package.json, .changeset/*
Sentry mocks and cleanup are updated, BullMQ is upgraded, and patch changesets record the reminder and repeat-option changes.

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

Sequence Diagram(s)

sequenceDiagram
  participant CheckDebtsWorker
  participant ScanChunkWorker
  participant ReminderWorker
  participant OneSignal
  CheckDebtsWorker->>ScanChunkWorker: enqueue scan-chunk
  ScanChunkWorker->>ReminderWorker: enqueue reminder delivery
  ReminderWorker->>OneSignal: send notification with clamped ttl
Loading

Possibly related PRs

  • exactly/exa#722: Both changes modify maturity debt-reminder scheduling and worker behavior.

Suggested reviewers: nfmelendez, cruzdanilo

🚥 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 clearly matches the main change: fixing repeat options on the maturity queue.
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 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
📝 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 Outdated
@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 Outdated
@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.28%. Comparing base (836f057) to head (6a3bc08).
⚠️ Report is 2 commits behind head on main.
✅ 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.28%   -0.42%     
==========================================
  Files         263      262       -1     
  Lines       11446    11521      +75     
  Branches     3833     3851      +18     
==========================================
+ Hits         8092     8097       +5     
- Misses       3059     3128      +69     
- Partials      295      296       +1     
Flag Coverage Δ
e2e 70.28% <83.33%> (-0.42%) ⬇️

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 3 times, most recently from acaa74c to e020098 Compare July 29, 2026 16:39

@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: 0b42a553fe

ℹ️ 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

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server/utils/maturity.ts (1)

120-123: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Preserve the intended maturity for delayed planner jobs.

After the window gate was removed, a check-debts job that runs after its target maturity recomputes maturity as the next interval. It then scans and potentially notifies for the wrong maturity instead of delivering the overdue reminder. Carry the intended maturity in the scheduled job contract, or derive it from the job’s scheduled timestamp.

  • server/utils/maturity.ts#L120-L123: stop deriving the target maturity solely from processing time.
  • server/test/utils/maturity.test.ts#L1026-L1038: add a post-maturity delayed planner case that verifies the original maturity is queried and delivered.
♻️ Duplicate comments (1)
server/utils/maturity.ts (1)

370-375: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Set startDate at the maturity-window boundary.

The - every term shifts both start dates a full maturity interval backward: for normal timestamps this resolves to maturity + offset - every, which is already expired. Use maturity * 1000 + offset and update the expectations. This repeats the previously addressed finding.

  • server/utils/maturity.ts#L370-L375: remove the full-interval backdating from both startDate calculations.
  • server/test/utils/maturity.test.ts#L305-L320: assert maturity - 24h and maturity - 1h, without subtracting MATURITY_INTERVAL.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9ea95deb-0375-4be7-afe6-6f53581bb0a0

📥 Commits

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

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • .changeset/long-carpets-cut.md
  • .changeset/sunny-sites-shine.md
  • server/package.json
  • server/test/utils/maturity.test.ts
  • server/utils/maturity.ts

@aguxez
aguxez force-pushed the maturity-repeat branch from 0b42a55 to 65b9656 Compare July 29, 2026 20:08

@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: 65b9656339

ℹ️ 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/script/reset-maturity-schedulers.ts Outdated
@aguxez
aguxez force-pushed the maturity-repeat branch from 65b9656 to 6a3bc08 Compare July 29, 2026 20:14
@cruzdanilo
cruzdanilo merged commit 6a3bc08 into main Jul 29, 2026
11 of 12 checks passed
@cruzdanilo
cruzdanilo deleted the maturity-repeat branch July 29, 2026 21:52
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