fix(workflow-executor): use last step from history (orchestrator as source of truth)#1582
Closed
Scra3 wants to merge 2 commits into
Closed
Conversation
… first non-done The orchestrator is the source of truth for which step to execute next. Always pick the last entry in workflowHistory rather than scanning for the first non-done/non-cancelled/non-errored step. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… run) at(-1) picks the orchestrator's current step but must still return null when that step is already done — the run is complete and nothing to execute. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (2)
🛟 Help
|
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
workflowHistory.find(s => !s.done && !s.cancelled && !s.context?.error)withworkflowHistory.at(-1)— the orchestrator is the source of truth for which step to execute nextif (pending.done) return nullto handle completed runs gracefully (last step done = nothing to execute)Test plan
yarn workspace @forestadmin/workflow-executor testpassesnulldone: true→null(run complete)done: false→ step is executed regardless ofcancelled/errorflags🤖 Generated with Claude Code
Note
Fix pending step selection to use last workflowHistory entry as source of truth
toAvailableStepExecutionin run-to-available-step-mapper.ts now selects the last entry inworkflowHistoryas the pending step, returning null if that step is done.ForestServerWorkflowPort.toMalformedInfoin forest-server-workflow-port.ts applies the same logic forstepId/stepIndexresolution.context.errorare no longer skipped during pending step selection — only the position (last) in history matters now.Macroscope summarized efc8559.