Repository navigation
Stop equal polling and action intervals skipping a tick in FromLastCompletion [patch] - #96
Merged
Merged
Conversation
…mpletion [patch] A FromLastCompletion run is stamped when it finishes, but the polling wait started as soon as the run was dispatched. The next tick therefore fell short of the run being due by however long the run took, so with equal polling and action intervals every run slipped a whole polling interval and the default mode ran the action at half the requested rate. The polling wait now also lasts until a full polling interval has passed since a run that finishes while it is in progress. The completion is recorded on the real Stopwatch clock, apart from the replaceable GetTimestamp the scheduling check reads, because the wait sleeps in real time. The equal-intervals regression test now covers both interval types, with actions that take 0, 5 and 20 ms. Fixes #93 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24pNCmCLDhz6z3ZdY
…il it On the macOS runner every case of EqualPollingAndActionIntervalsSkipNoTicks failed, the pre-existing FromLastStart one included, with Task.Delay oversleeping by up to about 200 ms: gaps of 335-427 ms against a 300 ms bound, none of them a skipped tick. At 500 ms the 750 ms bound absorbs that oversleep, while a skipped tick, about twice the interval, still exceeds it: without the fix the FromLastCompletion cases still fail locally, with runs 1000 ms apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24pNCmCLDhz6z3ZdY
matt-edmondson
pushed a commit
that referenced
this pull request
Oct 31, 2026
…il it The macOS runner failed EqualPollingAndActionIntervalsSkipNoTicks twice on this PR, which does not touch scheduling, with Task.Delay oversleeping by up to about 140 ms (gaps of 339-352 ms against a 300 ms bound, none a skipped tick). At 500 ms the 750 ms bound absorbs that oversleep, while a skipped tick, about twice the interval, still exceeds it. The same change is on #96, which reworks this test, so the two merge cleanly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24pNCmCLDhz6z3ZdY
|
Contributor
Author
|
SonarCloud S2925 ("Do not use That sleep is the body of the action under test, not the test waiting for a condition. #93 only shows up when the action takes real time to run, so the test makes the action block for 5 or 20 ms, the way a synchronous action would. With the fix reverted, those cases fail. The quality gate passed, and CI is green on all three OSes. Generated by Claude Code |
matt-edmondson
added a commit
that referenced
this pull request
Nov 4, 2026
* Reject an undefined IntervalType in Start [patch] An IntervalType outside FromLastCompletion and FromLastStart, such as a stale number bound from configuration, matched neither branch that records a run. LastRunTimestamp stayed null, so the action ran on every poll and ignored ActionInterval. Start now throws ArgumentOutOfRangeException for it, the same way it rejects an out-of-range PollingInterval. Fixes #94 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24pNCmCLDhz6z3ZdY * Widen the equal-intervals test's interval so CI timer jitter can't fail it The macOS runner failed EqualPollingAndActionIntervalsSkipNoTicks twice on this PR, which does not touch scheduling, with Task.Delay oversleeping by up to about 140 ms (gaps of 339-352 ms against a 300 ms bound, none a skipped tick). At 500 ms the 750 ms bound absorbs that oversleep, while a skipped tick, about twice the interval, still exceeds it. The same change is on #96, which reworks this test, so the two merge cleanly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW24pNCmCLDhz6z3ZdY --------- Co-authored-by: Claude <noreply@anthropic.com>
This was referenced Nov 11, 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.



Fixes #93
Summary
PR #87 fixed skipped ticks for
FromLastStartonly. In the defaultFromLastCompletionmode, a run is stamped when it finishes (RecordRun), but the polling wait starts as soon as the run is dispatched. The next tick was therefore short of the run being due by however long the run took. With equal polling and action intervals, every run slipped a whole polling interval, so the action ran at half the requested rate.Fix:
WaitOutPollingIntervalAsyncalready tops its wait up to the fullPollingInterval. It now also extends the wait until a fullPollingIntervalhas passed since aFromLastCompletionrun that finished during the wait. In effect, the polling cadence re-anchors to the completion, which is what the mode measures from.LastCompletionTimestamp, set byRecordRunfrom the realStopwatch. The wait sleeps in real time, so it shouldn't mix clocks with the replaceableGetTimestampthat tests inject forLastRunTimestamp.FromLastStartnever callsRecordRun, so its behaviour is unchanged.completedAt > start), so a stale stamp from before a restart has no effect.Tests
EqualPollingAndActionIntervalsSkipNoTicksnow takes the interval type and the action's work time as parameters:FromLastStartwith 0 and 20 ms, andFromLastCompletionwith 0, 5 and 20 ms.FromLastCompletionwith 5 ms and with 20 ms both fail. Runs land at3, 405, 809, 1211, 1612 msand0, 404, 805, 1208, 1615 msagainst a 200 ms interval.IntervalAction.Testsuite: 51 of 51 pass locally (Linux, .NET 10 SDK).Generated by Claude Code