native subgraph execution

This commit is contained in:
lda
2026-05-25 04:28:06 +07:00 Verified
parent 3880a86c26
commit a4eeb506be
20 changed files with 746 additions and 146 deletions
+10 -1
View File
@@ -18,12 +18,20 @@ from wf_core.run_state import (
from wf_core.runtime.scheduler import add_frame
def create_run_state(workflow: Workflow, workflow_input: dict[str, object]) -> RunState:
def initial_state(
workflow: Workflow, workflow_input: dict[str, object]
) -> dict[str, object]:
"""Create one scope's committed state from defaults plus workflow input."""
state: dict[str, object] = {}
for field in workflow.state_schema.fields:
if field.default is not None:
set_nested_value(state, list(field.path.parts), deepcopy(field.default))
state.update(dict(workflow_input))
return state
def create_run_state(workflow: Workflow, workflow_input: dict[str, object]) -> RunState:
state = initial_state(workflow, workflow_input)
run = RunState(
workflow_name=workflow.name,
status=RunStatus.PENDING,
@@ -33,6 +41,7 @@ def create_run_state(workflow: Workflow, workflow_input: dict[str, object]) -> R
ROOT_SCOPE_ID: RuntimeScope(
id=ROOT_SCOPE_ID,
workflow_name=workflow.name,
workflow_input=dict(workflow_input),
committed_state=state,
)
},