feat: expose foreach context paths

This commit is contained in:
lda
2026-09-05 00:16:25 +07:00 Verified
parent 0c0dcbce49
commit f6e5190696
4 changed files with 129 additions and 0 deletions
+19
View File
@@ -273,3 +273,22 @@ def test_workflow_builder_subgraph_adds_native_subgraph_node() -> None:
assert workflow.nodes[0].id == "run_child"
assert workflow.nodes[0].outcomes == child.outcomes
assert workflow.validate_structure().errors == []
def test_foreach_ref_works_in_subgraph_input_binding() -> None:
from wf_authoring import state_path
child = build_demo_workflow()
parent = WorkflowBuilder(
name="foreach_subgraph_parent",
input_schema={"type": "object"},
state_schema={"type": "object"},
output_schema={"type": "object"},
)
each = parent.foreach(id="orders", over=state_path("orders"), as_="order")
step = parent.subgraph(
workflow=child,
id="run_child",
input=[input_from(each.item, "order")],
)
assert str(step.input[0].path) == "context.foreach.orders.item"