fix(FN-5256): skip cycle preflight when new task has no deps

The unconditional listTasks() in assertNoDependencyCycle was wasted work
for the common no-dependency write and broke the same-agent duplicate
intake fail-open path: tests that stub listTasks to throw had the cycle
check consume the rejection before _maybeAutoArchiveSameAgentDuplicate's
try/catch could swallow it, propagating the error out of createTask.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-05-21 06:40:15 -07:00
parent e12adeb3fa
commit 97e6a0cc0e
2 changed files with 6 additions and 0 deletions

View File

@@ -3311,6 +3311,7 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
source: "createTask" | "createTaskWithReservedId" | "updateTask" | "replication",
overrides?: Map<string, readonly string[]>,
): Promise<void> {
if (dependencies.length === 0 && !overrides) return;
const lookup = await this.buildActiveTaskDependencyLookup(overrides);
const cyclePath = detectDependencyCycle(taskId, dependencies, (candidateId) => lookup.get(candidateId));
if (!cyclePath) return;