Skip to content

feat: sort ErrWorkflow output by execution finish order#73

Merged
xuxife merged 11 commits intomainfrom
xuxife/26/05/05/sort-error-workflow
May 6, 2026
Merged

feat: sort ErrWorkflow output by execution finish order#73
xuxife merged 11 commits intomainfrom
xuxife/26/05/05/sort-error-workflow

Conversation

@xuxife
Copy link
Copy Markdown
Collaborator

@xuxife xuxife commented May 5, 2026

Summary

Fixes #68.

ErrWorkflow.Error() previously iterated a map[Steper]StepResult directly, producing non-deterministic output on every run. This makes failure traces hard to read and impossible to diff across runs.

  • Add FinishedAt time.Time to StepResult, recorded via the workflow's injected clock.Clock at step termination
  • Record FinishedAt at both termination sites in workflow.go: the step goroutine defer (running steps) and the condition-skip branch (steps skipped before running)
  • ErrWorkflow.Error() and Unwrap() now sort by FinishedAt ascending — earliest-finishing step first, zero-time steps last, tie-break by step name for stability

Test plan

  • TestErrWorkflowOutputOrdering — 3-step serial chain (names chosen so alphabetical ≠ execution order), verifies output matches execution order
  • TestErrWorkflowTieBreakByName — two parallel steps finish at the same mock clock tick, verifies alphabetical tie-break
  • TestStepResultFinishedAtPopulated — verifies FinishedAt is non-zero after a step runs
  • go test ./... -count=1 — full suite passes

🤖 Generated with Claude Code

Copy link
Copy Markdown

@soeviturek soeviturek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xuxife xuxife added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit 2c88ec2 May 6, 2026
2 checks passed
@xuxife xuxife deleted the xuxife/26/05/05/sort-error-workflow branch May 6, 2026 01:21
xuxife pushed a commit that referenced this pull request May 7, 2026
docs/superpowers/plans/2026-05-05-errworkflow-execution-order.md and
openspec/changes/archive/2026-05-05-errworkflow-execution-order/ were
introduced by PR #73 (sort ErrWorkflow by FinishedAt) and merged
into main. The previous cleanup commit removed them by mistake — my
diff-against-main check listed them as additions on this branch, but
they were genuinely on main as well. Restore from 2c88ec2.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

ErrWorkflow error output is in random order

2 participants