From d0439dd11e7ba9cfc327d03c315c8020c3cf0a0c Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 7 Jul 2026 11:10:43 +0000 Subject: [PATCH] =?UTF-8?q?Completing=20a=20re-run=20failed=20batch=20un-f?= =?UTF-8?q?ails=20the=20task=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- tests/orchestration/test_task_orchestrator.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/orchestration/test_task_orchestrator.py b/tests/orchestration/test_task_orchestrator.py index 8767c8c15..dc822e00c 100644 --- a/tests/orchestration/test_task_orchestrator.py +++ b/tests/orchestration/test_task_orchestrator.py @@ -263,6 +263,29 @@ def test_run_subtasks_isolates_a_failing_item_and_continues( assert harness.tasks.get(task.id).status is TaskStatus.FAILED +def test_completing_a_rerun_failed_subtask_unfails_the_task( + harness: Harness, +) -> None: + """A failed batch is re-run by re-sending its own inputs; when the re-run + completes, the parent Task recomputes to COMPLETE (ADR-0055).""" + # arrange — two children: one failed (task FAILED), the other complete + task, failed_batch = harness.orchestrator.create_task_with_subtask( + task_source="manual:test" + ) + healthy_batch = harness.orchestrator.create_child_subtask(task.id) + harness.orchestrator.complete_subtask(healthy_batch.id) + harness.orchestrator.fail_subtask(failed_batch.id, RuntimeError("boom")) + assert harness.tasks.get(task.id).status is TaskStatus.FAILED + + # act — the re-run of the failed batch + harness.orchestrator.run_subtask(failed_batch.id, work=lambda: "fixed") + + # assert — no failed children remain, so the task un-fails to COMPLETE + task_after = harness.tasks.get(task.id) + assert task_after.status is TaskStatus.COMPLETE + assert task_after.job_completed is not None + + def test_cascade_short_circuits_once_task_already_failed(harness: Harness) -> None: """Once the Task is FAILED, completing another SubTask leaves it FAILED — the terminal state is not recomputed away."""