Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
lokewate
added this pull request to stack #245
September 28, 2026 07:05
11 of 17 tasks
lokewate
force-pushed
the
feat/taskflow-guarded-writes-6-completion
branch
from
September 28, 2026 08:15
e643352 to
96ed4b0
Compare
lokewate
force-pushed
the
feat/taskflow-guarded-writes-6-completion
branch
from
September 28, 2026 08:33
96ed4b0 to
3202f41
Compare
lokewate
force-pushed
the
feat/taskflow-guarded-writes-6-completion
branch
from
September 28, 2026 08:35
3202f41 to
c7a8657
Compare
lokewate
force-pushed
the
feat/taskflow-guarded-writes-6-completion
branch
from
September 28, 2026 09:01
c7a8657 to
c19f1eb
Compare
lokewate
force-pushed
the
feat/taskflow-guarded-writes-6-completion
branch
from
September 28, 2026 09:28
c19f1eb to
3c2bc0b
Compare
lokewate
force-pushed
the
feat/taskflow-guarded-writes-6-completion
branch
from
September 28, 2026 09:37
3c2bc0b to
3686373
Compare
lokewate
force-pushed
the
feat/taskflow-guarded-writes-6-completion
branch
from
September 30, 2026 02:26
3686373 to
3c5b6c4
Compare
lokewate
force-pushed
the
feat/taskflow-guarded-writes-6-completion
branch
from
September 30, 2026 02:32
3c5b6c4 to
0801d84
Compare
lokewate
force-pushed
the
feat/taskflow-guarded-writes-6-completion
branch
from
September 30, 2026 04:54
0801d84 to
6d568ab
Compare
lokewate
marked this pull request as ready for review
September 30, 2026 04:54
HandleTaskCompletion woke the parent workflow first and only then saved COMPLETED, guarded by "already COMPLETED means done". A crash between the two left the parent awake and the task not completed, and a retry then called the parent's CompleteStep a second time, which fails because the parent step is no longer pending. The end of a top-level workflow now takes the next value of the step counter and reports it (WorkflowCompletion.Seq). HandleTaskCompletion writes COMPLETED at that seq first, guarded so it only matches if no later step exists, and then wakes the parent. Each half can be repeated: a completed row no longer short-circuits a retry, and a parent step that is no longer pending means an earlier attempt already woke it, which counts as success. Also drop TaskRecord.ParentRunID and the run parameter from TaskCompletedCallback: the parent workflow, like every workflow this engine runs, never has more than one run (no Continue-As-New, no workflow-level retry, no ID reuse — see the field's new doc comment), so "" always correctly addresses whichever run is current. This is the same reasoning CompleteTaskStep's wake-up already applies on the child side; this commit is what makes the parent side consistent with it, since it's the one rewriting how the parent is woken. Also rename TaskStore.SaveTask to InitTask: this is the commit that removes its last non-init caller (HandleTaskCompletion's own write, now CompleteTask), so from here on its only caller is StartTask, creating the row. It's still an upsert, not insert-only — StartTask is a Temporal Activity and can be retried — so InitTask must stay safe to call twice for the same TaskID; the doc comment says so. BREAKING CHANGE: WorkflowCompletionHandler takes a WorkflowCompletion (workflow ID, seq, final variables) instead of two arguments, and TaskManager.HandleTaskCompletion takes the WorkflowCompletion. TaskCompletedCallback drops its run-ID parameter (parentWorkflowID, parentStepID, finalVariables) and TaskRecord.ParentRunID is removed. TaskCompletedCallback should return CompleteStep's error unchanged. TaskStore.SaveTask is renamed to InitTask. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
lokewate
force-pushed
the
feat/taskflow-guarded-writes-6-completion
branch
from
September 30, 2026 11:51
6d568ab to
baf56a2
Compare
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.
Summary
The task's own completion is now persisted before the parent workflow is woken, and the old buggy "already completed" short-circuit that a stale wake-up could match is removed.
Next PR: #244
Type of Change
Changes Made
HandleTaskCompletionnow writes the guardedCompleteTask(0 rows = logged, not an error — the parent is still woken) before calling back into the parent workflow, so the parent is never woken on a completion the DB never durably recorded.if record.State == "COMPLETED" { return nil }short-circuit — that was the buggy pattern this whole stack replaces (a stale wake-up could match it and silently no-op the wrong pass).TaskCompletedCallbackentirely (ParentRunIDno longer exists onTaskRecord— confirmed unused once addressing is by workflow ID + step ID, since the engine never uses Continue-As-New).Testing
completion_test.gocovers the persist-then-wake ordering and the already-resumed (ErrActivationNotPending) success path.Checklist
Related Issues
N/A
Screenshots/Demo
N/A
Additional Notes
Step 7 of 8 in the
taskflow-guarded-writesstack — see #237 for why this stack exists. Base:feat/taskflow-guarded-writes-5-wake-up.🤖 Generated with Claude Code