fix(engine): recover orphaned tasks at startup
This commit is contained in:
@@ -8,11 +8,13 @@ const {
|
||||
mockSelfHealingStart,
|
||||
mockSelfHealingStop,
|
||||
mockSelfHealingCtor,
|
||||
mockRunStartupRecovery,
|
||||
mockExecutorCtor,
|
||||
} = vi.hoisted(() => ({
|
||||
mockSelfHealingStart: vi.fn(),
|
||||
mockSelfHealingStop: vi.fn(),
|
||||
mockSelfHealingCtor: vi.fn(),
|
||||
mockRunStartupRecovery: vi.fn().mockResolvedValue(undefined),
|
||||
mockExecutorCtor: vi.fn(),
|
||||
}));
|
||||
|
||||
@@ -92,6 +94,7 @@ vi.mock("../self-healing.js", async () => {
|
||||
return {
|
||||
start: mockSelfHealingStart,
|
||||
stop: mockSelfHealingStop,
|
||||
runStartupRecovery: mockRunStartupRecovery,
|
||||
};
|
||||
}),
|
||||
};
|
||||
@@ -184,6 +187,12 @@ describe("InProcessRuntime", () => {
|
||||
expect(mockSelfHealingStart).toHaveBeenCalled();
|
||||
}, 30000);
|
||||
|
||||
it("runs self-healing startup recovery immediately after orphan resume on startup", async () => {
|
||||
await runtime.start();
|
||||
|
||||
expect(mockRunStartupRecovery).toHaveBeenCalledTimes(1);
|
||||
}, 30000);
|
||||
|
||||
it("creates a stuck task detector and passes it to the executor", async () => {
|
||||
await runtime.start();
|
||||
|
||||
|
||||
@@ -360,6 +360,12 @@ export class InProcessRuntime
|
||||
// 9. Resume orphaned in-progress tasks
|
||||
await this.executor.resumeOrphaned();
|
||||
|
||||
// Some "stuck" tasks are already orphaned by the time the runtime boots:
|
||||
// they no longer have a tracked session/worktree, so the stuck detector
|
||||
// cannot recover them. Delegate the startup recovery pass to
|
||||
// SelfHealingManager so the policy lives in one place.
|
||||
await this.selfHealingManager.runStartupRecovery();
|
||||
|
||||
// 10. Start scheduler
|
||||
this.scheduler.start();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user