diff --git a/domain/tasks/tasks.py b/domain/tasks/tasks.py index ead253ab6..992ae8d71 100644 --- a/domain/tasks/tasks.py +++ b/domain/tasks/tasks.py @@ -70,11 +70,12 @@ class Task: def recalculate_from_subtasks(self, statuses: list[SubTaskStatus]) -> None: """Recompute Task.status from its SubTasks' statuses. - Rule (preserved from legacy _update_task_progress): - - any FAILED → FAILED - - all COMPLETE → COMPLETE - - any IN_PROGRESS → IN_PROGRESS - - otherwise → WAITING + Rule: + - any FAILED → FAILED + - all COMPLETE → COMPLETE + - any IN_PROGRESS or COMPLETE → IN_PROGRESS (finished batches plus + queued batches is a run in progress, not a waiting one — ADR-0055) + - all WAITING → WAITING Empty list is a no-op (newly-created task with no subtasks). """ @@ -87,7 +88,10 @@ class Task: elif all(s is SubTaskStatus.COMPLETE for s in statuses): self.status = TaskStatus.COMPLETE self.job_completed = now - elif SubTaskStatus.IN_PROGRESS in statuses: + elif ( + SubTaskStatus.IN_PROGRESS in statuses + or SubTaskStatus.COMPLETE in statuses + ): self.status = TaskStatus.IN_PROGRESS self.job_completed = None else: