Skip to content

fix(timer): clamp Prime duration to prevent spurious completion#414

Merged
Splode merged 1 commit intomainfrom
bugfix/prime-elapsed-clamp
Apr 29, 2026
Merged

fix(timer): clamp Prime duration to prevent spurious completion#414
Splode merged 1 commit intomainfrom
bugfix/prime-elapsed-clamp

Conversation

@Splode
Copy link
Copy Markdown
Owner

@Splode Splode commented Apr 29, 2026

If a Prime command arrives while the engine is Running or Paused with a duration_secs value less than the current elapsed_secs, the next tick would immediately fire Complete — a silent no-op in normal use, but a real hazard if round duration is shortened in settings mid-round.

Clamp the new total_secs to elapsed_secs.saturating_add(1) in both the Running and Paused Prime handlers so the timer always advances at least one tick before completing.

Adds two regression tests: one for Prime undershooting in Running phase, one for Prime undershooting in Paused phase (verified on Resume).

If a Prime command arrives while the engine is Running or Paused with a
duration_secs value less than the current elapsed_secs, the next tick
would immediately fire Complete — a silent no-op in normal use, but a
real hazard if round duration is shortened in settings mid-round.

Clamp the new total_secs to elapsed_secs.saturating_add(1) in both the
Running and Paused Prime handlers so the timer always advances at least
one tick before completing.

Adds two regression tests: one for Prime undershooting in Running phase,
one for Prime undershooting in Paused phase (verified on Resume).
@Splode Splode merged commit 98d9ee5 into main Apr 29, 2026
8 checks passed
@Splode Splode deleted the bugfix/prime-elapsed-clamp branch April 29, 2026 16:21
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