You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite. Learn more
This PR refactors the overdue alarm check in handle_stopped by hoisting it out of the Decision::Sleep match arm and evaluating it before the stopped_res dispatch. The logic is correct and the refactor significantly reduces duplication.
Correctness
The logic change is correct. The previous Decision::Sleep arm duplicated the full Decision::Reallocate dispatch inline. The new approach converts decision from Sleep to Reallocate before the dispatch match, so the overdue-alarm path falls through to the single shared Decision::Reallocate arm. This avoids code duplication while preserving identical observable behavior.
state.alarm_ts is correctly cleared when the alarm has fired, consistent with the existing pattern elsewhere in the file.
The check is correctly scoped to Decision::Sleep only, so alarms do not interfere with Reallocate, Backoff, or Destroy decisions.
Potential Gap: Decision::Backoff with an Overdue Alarm
When an actor stops due to a failed allocation while an alarm is already overdue, both old and new code leave state.alarm_ts set and transition to Reallocating. This is not a regression introduced by this PR, but the intent is undocumented. Consider adding a comment above the alarm check explaining why Backoff is excluded.
Code Quality
The comment // Check alarm (line 564) is a sentence fragment. Per CLAUDE.md conventions, comments should be complete sentences. Suggested replacement: // Check whether an alarm fired while the actor was stopping and wake it immediately.
Workflow Replay Safety
Since GetTsInput {} is an existing #[activity] used in this workflow, hoisting it out of the Decision::Sleep arm changes the activity call order for workflows that previously hit this code path. Any in-flight workflow interrupted after computing Decision::Sleep but before or during the old overdue-alarm allocation block will replay with the new code and encounter GetTsInput at a different position in the event log.
Whether this is safe depends on how Gasoline handles activity sequencing during replay (strict position vs. type+input matching). Please confirm replay safety, or note that this is deployed only after draining any in-flight workflows in the affected state.
PR Description
The description is the default template with no context. For a deterministic workflow change it would be helpful to document: what the original bug was, how this was tested, and whether workflow replay safety was considered.
Overall
The refactor is clean and reduces real duplication. Main items to address: (1) confirm workflow replay safety, (2) optionally add a comment clarifying why Backoff is excluded from the alarm check, (3) expand the sentence-fragment comment on line 564 to a complete sentence.
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
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.
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: