fix(FN-5137): complete Step 2-3 — guard deleted tasks in snapshot and executor

Fusion-Task-Id: FN-5137
Fusion-Task-Lineage: bb2e2e56-d64c-46ca-a6c8-abda13029fc2
This commit is contained in:
Fusion (runfusion.ai)
2026-05-19 07:18:29 -07:00
committed by gsxdsm
parent 4eccbe2fb5
commit 9b6513af71
2 changed files with 10 additions and 1 deletions

View File

@@ -86,6 +86,7 @@ export class AutoClaimSnapshotManager {
&& candidate.paused !== true
&& !candidate.assignedAgentId
&& !candidate.checkedOutBy
&& !candidate.deletedAt
&& candidate.dependencies.every((dependencyId) => {
const dependency = tasksById.get(dependencyId);
return dependency?.column === "done" || dependency?.column === "archived";

View File

@@ -2573,6 +2573,7 @@ export class TaskExecutor {
for (const task of tasks) {
if (
task.assignedAgentId === agentId
&& !task.deletedAt
&& !task.paused
&& !this.executing.has(task.id)
&& !this.activeSessions.has(task.id)
@@ -2607,7 +2608,7 @@ export class TaskExecutor {
const tasks = await this.store.listTasks({ slim: true, column: "in-progress" });
const inProgress = tasks.filter(
(t) => t.column === "in-progress" && !this.executing.has(t.id) && !t.paused,
(t) => t.column === "in-progress" && !t.deletedAt && !this.executing.has(t.id) && !t.paused,
);
if (inProgress.length === 0) return;
@@ -2725,6 +2726,13 @@ export class TaskExecutor {
// consistent with the process-wide lock.
this.executing.add(task.id);
if (task.deletedAt) {
executorLog.warn(`${task.id}: refusing execute — task is soft-deleted`);
this.executing.delete(task.id);
executingTaskLock.release(task.id);
return;
}
const assignedAgentId = task.assignedAgentId;
if (assignedAgentId && await this.shouldDeferForHeartbeat(assignedAgentId)) {
executorLog.log(`${task.id}: skipping execute — agent ${assignedAgentId} has active heartbeat run (allowParallelExecution=false)`);