Repository navigation
Description
Summary
The CapacityManager refactor (commit 76a6a10, shipped in 202e2d4) deleted services/slot_service.py and replaced it with services/capacity_manager.py. The unit tests in test_orphaned_execution_recovery.py still mock services.slot_service, so all four recovery scenario tests now fail with 'Mock' object can't be awaited. The orphaned execution recovery code has no working unit test coverage as a result.
Component
Backend / Cleanup Service / Tests
Priority
P3 — no runtime impact; tests fail locally and in CI
Error
ERROR cleanup_service.py:772 [Recovery] Error recovering execution exec-1:
'Mock' object can't be awaited
assert 0 == 1 # recovered count
Location
- File:
tests/unit/test_orphaned_execution_recovery.py - Line: ~30 (
_SYS_MOCKSdefinition) - Function:
_SYS_MOCKSdict /TestRecoverOrphanedExecutions
Root Cause
test_orphaned_execution_recovery.py injects a sys-module mock for services.slot_service:
_SYS_MOCKS = {
...
'services.slot_service': Mock(get_slot_service=Mock(return_value=_mock_slot_service)),
...
}After the refactor, cleanup_service.py no longer imports from services.slot_service. It now calls get_capacity_manager() from services.capacity_manager and awaits capacity.release(agent_name, execution_id). The test's mock dict doesn't include services.capacity_manager, so capacity is an un-mocked None-like object and await capacity.release(...) raises TypeError: 'Mock' object can't be awaited.
Affected Tests
All four orphaned-recovery scenario tests fail:
test_container_down_marks_orphanedtest_not_in_registry_marks_orphanedtest_multiple_agents_mixedtest_agent_unreachable_treats_as_orphaned
(test_no_running_executions still passes because the recovery path is never entered.)
Suggested Fix
Replace the stale slot_service mock with a capacity_manager mock:
# REMOVE:
_mock_slot_service = AsyncMock()
...
'services.slot_service': Mock(get_slot_service=Mock(return_value=_mock_slot_service)),
# ADD:
_mock_capacity = AsyncMock()
_mock_capacity.release = AsyncMock()
_mock_capacity.release_if_matches = AsyncMock(return_value=True)
...
'services.capacity_manager': Mock(get_capacity_manager=Mock(return_value=_mock_capacity)),Any assertions that previously checked _mock_slot_service.release_slot calls should be updated to check _mock_capacity.release instead.
Reproduction Steps
- Check out commit
202e2d4or later - Run:
cd tests && python -m pytest unit/test_orphaned_execution_recovery.py -v - Observe 4 failures with
'Mock' object can't be awaited
Environment
- Trinity version:
202e2d4 - Introduced by:
76a6a10(CapacityManager consolidation)
Related
src/backend/services/cleanup_service.py— function_recover_execution()(usescapacity.release)src/backend/services/capacity_manager.py— new consolidated servicetests/unit/test_capacity_manager.py— new test file (all passing)
Activity
vybe commentedon Apr 27, 2026
/claim
github-actions commentedon Apr 27, 2026
Claimed by @vybe. Label
status-in-progressadded.Next steps:
feature/533-<short-slug>Fixes #533fix(tests): update orphaned-recovery mocks to CapacityManager (#533) (#…
Release: v0.5.0 (Abilityai#608)