refactor(dag): Audit and cleanup dag_engine.py

This commit is contained in:
2026-05-02 12:55:13 -04:00
parent 46baaeae89
commit f11a219b44
+10 -18
View File
@@ -61,6 +61,14 @@ class TrackDAG:
changed = True changed = True
break break
def is_ticket_ready(self, ticket: Ticket) -> bool:
"""Returns True if all dependencies of the ticket are completed."""
for dep_id in ticket.depends_on:
dep = self.ticket_map.get(dep_id)
if not dep or dep.status != 'completed':
return False
return True
def get_ready_tasks(self) -> List[Ticket]: def get_ready_tasks(self) -> List[Ticket]:
""" """
Returns a list of tickets that are in 'todo' status and whose dependencies are all 'completed'. Returns a list of tickets that are in 'todo' status and whose dependencies are all 'completed'.
@@ -69,15 +77,7 @@ class TrackDAG:
""" """
ready = [] ready = []
for ticket in self.tickets: for ticket in self.tickets:
if ticket.status == 'todo': if ticket.status == 'todo' and self.is_ticket_ready(ticket):
# Check if all dependencies exist and are completed
all_done = True
for dep_id in ticket.depends_on:
dep = self.ticket_map.get(dep_id)
if not dep or dep.status != 'completed':
all_done = False
break
if all_done:
ready.append(ticket) ready.append(ticket)
return ready return ready
@@ -172,15 +172,7 @@ class ExecutionEngine:
task_id: The ID of the task to approve. task_id: The ID of the task to approve.
""" """
ticket = self.dag.ticket_map.get(task_id) ticket = self.dag.ticket_map.get(task_id)
if ticket and ticket.status == "todo": if ticket and ticket.status == "todo" and self.dag.is_ticket_ready(ticket):
# Check if dependencies are met first
all_done = True
for dep_id in ticket.depends_on:
dep = self.dag.ticket_map.get(dep_id)
if not dep or dep.status != "completed":
all_done = False
break
if all_done:
ticket.status = "in_progress" ticket.status = "in_progress"
def update_task_status(self, task_id: str, status: str) -> None: def update_task_status(self, task_id: str, status: str) -> None: