end node is real

This commit is contained in:
lda
2026-05-25 02:04:29 +07:00 Verified
parent 2af0b3357f
commit 6ef2620602
15 changed files with 249 additions and 19 deletions
+2
View File
@@ -90,6 +90,8 @@ def advance_frame(
def finalize_run(workflow: Workflow, run: RunState) -> RunState:
if run.outcome is None:
run.outcome = "ok"
run.output = project_output(workflow, run.state)
validate_payload_against_schema(
workflow.output_schema, run.output, "workflow output"
+44 -1
View File
@@ -7,6 +7,7 @@ from typing import Any
from wf_core.errors import WorkflowExecutionError
from wf_core.models.steps import (
ConditionNode,
EndNode,
ForeachNode,
InterruptNode,
JoinNode,
@@ -37,7 +38,8 @@ from wf_core.runtime.scheduler import (
select_next_frame,
wake_parent_for_child_progress,
)
from wf_core.run_state import ExecutionFrame, FrameStatus, RunState
from wf_core.run_state import ExecutionFrame, FrameStatus, RunState, StepExecutionResult
from wf_core.tokens import END
from .preparation import prepare_step
@@ -74,6 +76,33 @@ def complete_step(
return run
def complete_end_step(
*,
run: RunState,
frame_id: str,
node_id: str,
outcome: str,
) -> RunState:
"""Record an explicit workflow terminal and complete the active frame."""
result = StepExecutionResult(outcome=outcome)
run.outcome = outcome
append_step_result_trace(
run,
frame_id=frame_id,
node_id=node_id,
step_type="end",
next_node_id=END,
result=result,
)
advance_frame(
run,
run.frames[frame_id],
outcome=outcome,
next_node_id=END,
)
return run
def step_workflow(
workflow: Workflow,
run: RunState,
@@ -112,6 +141,13 @@ def step_workflow(
step_result = handle_condition_step(run, step)
elif isinstance(step, JoinNode):
step_result = handle_join_step()
elif isinstance(step, EndNode):
return complete_end_step(
run=run,
frame_id=frame.id,
node_id=frame.node_id,
outcome=step.outcome,
)
elif isinstance(step, InterruptNode):
return handle_interrupt_step(run, step)
elif isinstance(step, ForeachNode):
@@ -211,6 +247,13 @@ async def step_workflow_async(
step_result = handle_condition_step(run, step)
elif isinstance(step, JoinNode):
step_result = handle_join_step()
elif isinstance(step, EndNode):
return complete_end_step(
run=run,
frame_id=frame.id,
node_id=frame.node_id,
outcome=step.outcome,
)
elif isinstance(step, InterruptNode):
return handle_interrupt_step(run, step)
elif isinstance(step, ForeachNode):