Skip to content

fix(workflows): align nextFire interval calculation with dispatcher clock (#2788) - #2799

Closed
isihussain wants to merge 1 commit into
danielmiessler:mainfrom
isihussain:fix/workflow-next-interval-clock
Closed

isihussain wants to merge 1 commit into
danielmiessler:mainfrom
isihussain:fix/workflow-next-interval-clock

Conversation

@isihussain

Copy link
Copy Markdown

Summary

Fixes #2788.

For an interval trigger, workflow next and the dispatcher previously computed different fire times:

  • workflow next computed lastStart + period (
    extFire, interval case).
  • The dispatcher finds due occurrences with occurrencesBetween / occurrencesIn, placing interval occurrences at multiples of the period counted from the Unix epoch.

This caused workflow next to diverge whenever a run started with latency or off-grid (e.g. reporting 23:45Z when the dispatcher fires at 00:00Z).

Solution

  1. Updated
    extFire in LIFEOS/WORKFLOWS/engine/schedule.ts (interval case) to query occurrencesBetween for the next epoch-grid occurrence, aligning it directly with the dispatcher's clock.
  2. Added LIFEOS/WORKFLOWS/engine/schedule.next.test.ts covering off-grid last runs, execution latency, and on-grid controls.

Signed-off-by: isihussain isihussain@users.noreply.github.com

…lock (danielmiessler#2788)

For interval triggers, nextFire previously computed lastStart + period,
drifting whenever runs started off-grid or with tick latency. The dispatcher
fires on multiples of the period counted from the Unix epoch via
occurrencesIn/occurrencesBetween.

Update nextFire interval case to query occurrencesBetween for the next
epoch-grid occurrence, ensuring workflow next and the dispatcher agree.
Add schedule.next.test.ts covering off-grid and tick latency scenarios.

Closes danielmiessler#2788

Signed-off-by: isihussain <isihussain@users.noreply.github.com>
@danielmiessler

Copy link
Copy Markdown
Owner

Note

🤖 Kai (AI assistant) responding on behalf of Daniel Miessler

Thanks @isihussain. We used this as the reference for #2788: workflow next now takes interval triggers from the same epoch-grid clock the dispatcher fires on, with your cases as engine tests.

The fix lands in the next LifeOS release. Our public repo is generated from the private source at each release, so we port a PR there rather than merging it, and you are credited at the fix site, in the commit as a co-author, and in the README credits. Closing this now.

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.

workflow next and the dispatcher disagree on when an interval trigger fires

2 participants