feat(conductor): Populate abort_events when spawning workers
This commit is contained in:
@@ -211,6 +211,9 @@ class ConductorEngine:
|
||||
)
|
||||
context_files = ticket.context_requirements if ticket.context_requirements else None
|
||||
|
||||
# Initialize abort event before spawning
|
||||
self._abort_events[ticket.id] = threading.Event()
|
||||
|
||||
spawned = self.pool.spawn(
|
||||
ticket.id,
|
||||
run_worker_lifecycle,
|
||||
|
||||
32
tests/test_conductor_abort_event.py
Normal file
32
tests/test_conductor_abort_event.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import pytest
|
||||
from unittest.mock import MagicMock, patch
|
||||
from src.multi_agent_conductor import ConductorEngine
|
||||
from src.models import Ticket, Track
|
||||
import threading
|
||||
|
||||
def test_conductor_abort_event_populated():
|
||||
"""
|
||||
Test that ConductorEngine populates _abort_events when spawning a worker.
|
||||
"""
|
||||
# 1. Mock WorkerPool.spawn to return a mock thread
|
||||
with patch('src.multi_agent_conductor.WorkerPool.spawn') as mock_spawn:
|
||||
mock_spawn.return_value = MagicMock(spec=threading.Thread)
|
||||
|
||||
# 2. Mock ExecutionEngine.tick
|
||||
with patch('src.multi_agent_conductor.ExecutionEngine.tick') as mock_tick:
|
||||
ticket_id = "test-ticket"
|
||||
ticket = Ticket(id=ticket_id, description="Test description", status="todo")
|
||||
mock_tick.return_value = [ticket]
|
||||
|
||||
mock_track = Track(id="test-track", description="Test Track", tickets=[ticket])
|
||||
|
||||
# 3. Set auto_queue=True
|
||||
mock_queue = MagicMock()
|
||||
engine = ConductorEngine(track=mock_track, event_queue=mock_queue, auto_queue=True)
|
||||
|
||||
# 4. Call ConductorEngine.run(max_ticks=1)
|
||||
engine.run(max_ticks=1)
|
||||
|
||||
# 5. Assert that self._abort_events has an entry for the ticket ID
|
||||
assert ticket_id in engine._abort_events
|
||||
assert isinstance(engine._abort_events[ticket_id], threading.Event)
|
||||
Reference in New Issue
Block a user