Skip to content

fix(workflow-executor): use last step from history (orchestrator as source of truth)#1582

Closed
Scra3 wants to merge 2 commits into
feat/prd-214-server-step-mapperfrom
fix/workflow-executor-step-mapper-last-step
Closed

fix(workflow-executor): use last step from history (orchestrator as source of truth)#1582
Scra3 wants to merge 2 commits into
feat/prd-214-server-step-mapperfrom
fix/workflow-executor-step-mapper-last-step

Conversation

@Scra3
Copy link
Copy Markdown
Member

@Scra3 Scra3 commented May 18, 2026

Summary

  • Replace workflowHistory.find(s => !s.done && !s.cancelled && !s.context?.error) with workflowHistory.at(-1) — the orchestrator is the source of truth for which step to execute next
  • Add if (pending.done) return null to handle completed runs gracefully (last step done = nothing to execute)
  • Remove tests that asserted the old filtering logic; update remaining tests to reflect the new contract

Test plan

  • yarn workspace @forestadmin/workflow-executor test passes
  • Empty history → null
  • Last step done: truenull (run complete)
  • Last step done: false → step is executed regardless of cancelled/error flags

🤖 Generated with Claude Code

Note

Fix pending step selection to use last workflowHistory entry as source of truth

  • toAvailableStepExecution in run-to-available-step-mapper.ts now selects the last entry in workflowHistory as the pending step, returning null if that step is done.
  • ForestServerWorkflowPort.toMalformedInfo in forest-server-workflow-port.ts applies the same logic for stepId/stepIndex resolution.
  • Behavioral Change: cancelled steps and steps with context.error are no longer skipped during pending step selection — only the position (last) in history matters now.

Macroscope summarized efc8559.

alban bertolini and others added 2 commits May 18, 2026 15:05
… 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>
@qltysh
Copy link
Copy Markdown

qltysh Bot commented May 18, 2026

Qlty


Coverage Impact

This PR will not change total coverage.

Modified Files with Diff Coverage (2)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
.../workflow-executor/src/adapters/forest-server-workflow-port.ts100.0%
Coverage rating: A Coverage rating: A
...workflow-executor/src/adapters/run-to-available-step-mapper.ts100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@Scra3 Scra3 closed this May 18, 2026
@Scra3 Scra3 deleted the fix/workflow-executor-step-mapper-last-step branch May 18, 2026 13:14
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