more code review and plans

This commit is contained in:
lda
2026-05-22 14:10:15 +07:00 Verified
parent 0a6500daf2
commit b4623beb1d
7 changed files with 720 additions and 14 deletions
+1
View File
@@ -92,6 +92,7 @@ def test_sync_concurrent_foreach_respects_max_active_by_refill_trace() -> None:
]
assert loop_entries[0].resolved_input["active_count"] == 0
assert loop_entries[1].resolved_input["active_count"] == 1
assert any(entry.resolved_input["active_count"] > 0 for entry in loop_entries)
assert all(entry.resolved_input["active_count"] < 2 for entry in loop_entries)
+23
View File
@@ -70,7 +70,13 @@ def test_foreach_barrier_tracks_active_and_outstanding_children() -> None:
barrier = ForeachBarrierState()
barrier.start_child("child-0")
assert barrier.active_frame_ids == ("child-0",)
assert barrier.outstanding_frame_ids == ("child-0",)
barrier.start_child("child-1")
assert barrier.active_frame_ids == ("child-0", "child-1")
assert barrier.outstanding_frame_ids == ("child-0", "child-1")
barrier.finish_child("child-0")
assert barrier.active_frame_ids == ("child-1",)
@@ -85,6 +91,23 @@ def test_foreach_barrier_rejects_duplicate_child_start() -> None:
barrier.start_child("child-0")
def test_foreach_barrier_rejects_finishing_unknown_child() -> None:
barrier = ForeachBarrierState()
with pytest.raises(WorkflowExecutionError, match="not active"):
barrier.finish_child("child-0")
def test_foreach_barrier_rejects_duplicate_item_result() -> None:
barrier = ForeachBarrierState()
patch = StatePatch(changes={"state.count": 1})
barrier.add_success_patch(index=0, frame_id="child-0", patch=patch)
with pytest.raises(WorkflowExecutionError, match="already recorded"):
barrier.add_success_patch(index=0, frame_id="child-0", patch=patch)
def test_item_error_record_rejects_negative_index() -> None:
with pytest.raises(WorkflowExecutionError, match="index"):
ItemErrorRecord.from_metadata(