even more code review

This commit is contained in:
lda
2026-05-22 22:10:44 +07:00 Verified
parent 6c1c8abc52
commit 9fe9c1452b
8 changed files with 51 additions and 53 deletions
+6 -4
View File
@@ -154,10 +154,11 @@ def execute_node_use(
f"no handler registered for node def {node.node!r}"
)
frame = run.current_frame()
resolved_input, context, state_view = _resolve_node_execution(
workflow=workflow,
run=run,
frame=run.current_frame(),
frame=frame,
node=node,
node_def=node_def,
)
@@ -165,7 +166,7 @@ def execute_node_use(
return _finalize_node_execution(
workflow=workflow,
run=run,
frame=run.current_frame(),
frame=frame,
node=node,
node_def=node_def,
resolved_input=resolved_input,
@@ -189,10 +190,11 @@ async def execute_node_use_async(
f"no handler registered for node def {node.node!r}"
)
frame = run.current_frame()
resolved_input, context, state_view = _resolve_node_execution(
workflow=workflow,
run=run,
frame=run.current_frame(),
frame=frame,
node=node,
node_def=node_def,
)
@@ -204,7 +206,7 @@ async def execute_node_use_async(
return _finalize_node_execution(
workflow=workflow,
run=run,
frame=run.current_frame(),
frame=frame,
node=node,
node_def=node_def,
resolved_input=resolved_input,
+2
View File
@@ -30,6 +30,8 @@ def state_view_for_frame(run: RunState, frame: ExecutionFrame) -> dict[str, Any]
if pending is None:
return run.state
# Correctness first: this full copy isolates sibling reads. If state grows
# large, replace this with a lazy/copy-on-write overlay.
state_view = deepcopy(run.state)
for destination, value in pending.patch.changes.items():
path = StatePath.parse(destination)
+12 -12
View File
@@ -111,18 +111,18 @@ def enqueue_frame(run: RunState, frame_id: str, *, front: bool = False) -> None:
def select_next_frame(run: RunState) -> ExecutionFrame | None:
"""Select the next ready frame and update compatibility cursor fields."""
while run.ready_frame_ids:
frame_id = run.ready_frame_ids.pop(0)
frame = _frame(run, frame_id)
if frame.status != FrameStatus.PENDING:
raise WorkflowExecutionError(
f"ready frame {frame_id!r} has status {frame.status!s}"
)
frame.status = FrameStatus.RUNNING
run.current_frame_id = frame.id
run.sync_from_current_frame()
return frame
return None
if not run.ready_frame_ids:
return None
frame_id = run.ready_frame_ids.pop(0)
frame = _frame(run, frame_id)
if frame.status != FrameStatus.PENDING:
raise WorkflowExecutionError(
f"ready frame {frame_id!r} has status {frame.status!s}"
)
frame.status = FrameStatus.RUNNING
run.current_frame_id = frame.id
run.sync_from_current_frame()
return frame
def mark_frame_pending(run: RunState, frame_id: str, *, front: bool = False) -> None:
+1 -1
View File
@@ -237,7 +237,7 @@ async def _step_async_foreach_item_batch(
"""Run one batch of ready concurrent-foreach item node handlers.
Only handler awaits run concurrently. Finalization, tracing, and frame
advancement happen afterward in frame-id order so `RunState` is mutated
advancement happen afterward in ready-queue order so `RunState` is mutated
deterministically.
"""
frames = [first_frame, *_claim_matching_async_item_frames(run, index, first_frame)]