fix(FN-2054): harden agent loop stuck-detection and self-healing

- Add defensive cleanup for in-memory task tracking when tasks move state or agents pause
- Improve stuck-detection and self-healing flow to reduce leaked state and missed recovery paths
- Add logging around previously swallowed errors and tighten executor cleanup behavior
- Expand restart and self-healing reliability tests to cover regression scenarios
This commit is contained in:
Fusion
2026-04-18 11:08:41 -07:00
committed by gsxdsm
parent eb04fd148d
commit 3977b38895
8 changed files with 290 additions and 91 deletions

View File

@@ -738,6 +738,8 @@ describe("Scheduler after restart", () => {
const todoTask = makeTask("FN-070", "todo");
store.listTasks.mockResolvedValue([todoTask]);
store.getSettings.mockResolvedValue({ ...DEFAULT_SETTINGS });
// Mock getTask for compare-and-swap verification in schedule()
store.getTask.mockResolvedValue(todoTask);
// Needs parseFileScopeFromPrompt for overlap checks
store.parseFileScopeFromPrompt.mockResolvedValue([]);
@@ -1320,6 +1322,8 @@ describe("Engine pause/unpause cycle", () => {
store.listTasks.mockResolvedValue([todoTask]);
store.getSettings.mockResolvedValue({ ...DEFAULT_SETTINGS, enginePaused: false });
store.parseFileScopeFromPrompt.mockResolvedValue([]);
// Mock getTask for compare-and-swap verification in schedule()
store.getTask.mockResolvedValue(todoTask);
const onSchedule = vi.fn();
const scheduler = new Scheduler(store, {