feat(dag_engine): implement cascade_blocks and call in ExecutionEngine.tick

This commit is contained in:
2026-03-02 18:47:47 -05:00
parent dd882b928d
commit 5b8a0739f7
2 changed files with 78 additions and 0 deletions

View File

@@ -16,6 +16,23 @@ class TrackDAG:
self.tickets = tickets
self.ticket_map = {t.id: t for t in tickets}
def cascade_blocks(self) -> None:
"""
Transitively marks `todo` tickets as `blocked` if any dependency is `blocked`.
Runs until stable (handles multi-hop chains: A→B→C where A blocked cascades to B then C).
"""
changed = True
while changed:
changed = False
for ticket in self.tickets:
if ticket.status == 'todo':
for dep_id in ticket.depends_on:
dep = self.ticket_map.get(dep_id)
if dep and dep.status == 'blocked':
ticket.status = 'blocked'
changed = True
break
def get_ready_tasks(self) -> List[Ticket]:
"""
Returns a list of tickets that are in 'todo' status and whose dependencies are all 'completed'.
@@ -116,6 +133,7 @@ class ExecutionEngine:
Returns:
A list of ready Ticket objects.
"""
self.dag.cascade_blocks()
ready = self.dag.get_ready_tasks()
if self.auto_queue:
for ticket in ready: