fix(dsl): compute cron wait at execution time, not at df.start() time#183
Open
Copilot wants to merge 3 commits into
Open
fix(dsl): compute cron wait at execution time, not at df.start() time#183Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Store target_timestamp (RFC 3339) in WAIT_SCHEDULE node config instead of pre-computing wait_seconds at df.start() time. Add compute_cron_wait activity that receives the target timestamp and computes max(0, target - now()) at actual execution time. The orchestration node schedules this activity first, then passes the result to schedule_timer. This keeps the orchestration deterministic (no wall-clock I/O inside orchestration code) while correctly measuring remaining time at the moment the background worker actually processes the WAIT_SCHEDULE node — preventing early wake-ups when there is a delay between df.start() and BGW execution. Changes: - src/dsl.rs: store target_timestamp instead of wait_seconds - src/activities/compute_cron_wait.rs: new activity for wall-clock I/O - src/activities/mod.rs: register new module - src/orchestrations/execute_function_graph.rs: schedule compute_cron_wait activity before scheduling the timer - src/registry.rs: register compute_cron_wait activity - src/explain.rs: show target timestamp in WAIT_SCHEDULE node output - src/lib.rs: update unit test to assert target_timestamp is present Co-authored-by: pinodeca <32303022+pinodeca@users.noreply.github.com>
- compute_cron_wait.rs: mention RFC 3339 in invalid timestamp error message - dsl.rs: add comment documenting RFC 3339 format contract with activity Co-authored-by: pinodeca <32303022+pinodeca@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix df.wait_for_schedule to compute wait at execution time
fix(dsl): compute cron wait at execution time, not at df.start() time
May 27, 2026
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.
df.wait_for_schedule()pre-computedwait_secondsat graph construction time. Any delay betweendf.start()and when the BGW actually runs theWAIT_SCHEDULEnode caused the timer to fire early — potentially before the intended cron tick.Approach
The orchestration must stay deterministic, so wall-clock reads must happen inside an activity. The fix captures the target timestamp (next cron tick) at DSL time for replay stability, then delegates the actual duration computation to a new activity that runs
max(0, target - now())at true execution time.Changes
src/dsl.rs— storetarget_timestamp(RFC 3339) in node config instead ofwait_seconds; cron expression is still validated eagerlysrc/activities/compute_cron_wait.rs(new) — activity that receivestarget_timestamp, computes remaining seconds at execution timesrc/orchestrations/execute_function_graph.rs—execute_wait_schedule_nodeschedulescompute_cron_waitactivity first, feeds the result intoschedule_timersrc/registry.rs— register new activitysrc/explain.rs— update WAIT_SCHEDULE display:WAIT '<cron>' (until <timestamp>)instead of(<secs>s)src/lib.rs— update unit test to asserttarget_timestamppresent andwait_secondsabsentConfig shape change
Before:
{"cron_expr": "*/5 * * * *", "wait_seconds": 142}After:
{"cron_expr": "*/5 * * * *", "target_timestamp": "2026-05-27T14:45:00+00:00"}