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:
5
.changeset/fix-fn-5256-cycle-check-empty-deps.md
Normal file
5
.changeset/fix-fn-5256-cycle-check-empty-deps.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@runfusion/fusion": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Skip the dependency-cycle preflight in `TaskStore.assertNoDependencyCycle` when the new task or update has no dependencies. The FN-5256 cycle-check rollout (e12adeb3f) added an unconditional `listTasks()` call on every write to build the dependency lookup, but an empty dependency list can never form a cycle so the query was wasted work. It also broke fail-open semantics in the same-agent duplicate intake path: tests that stubbed `listTasks` to throw saw the cycle check consume the rejection and propagate "boom" out of `createTask` before the duplicate-intake try/catch could swallow it.
|
||||||
@@ -3311,6 +3311,7 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
|
|||||||
source: "createTask" | "createTaskWithReservedId" | "updateTask" | "replication",
|
source: "createTask" | "createTaskWithReservedId" | "updateTask" | "replication",
|
||||||
overrides?: Map<string, readonly string[]>,
|
overrides?: Map<string, readonly string[]>,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
if (dependencies.length === 0 && !overrides) return;
|
||||||
const lookup = await this.buildActiveTaskDependencyLookup(overrides);
|
const lookup = await this.buildActiveTaskDependencyLookup(overrides);
|
||||||
const cyclePath = detectDependencyCycle(taskId, dependencies, (candidateId) => lookup.get(candidateId));
|
const cyclePath = detectDependencyCycle(taskId, dependencies, (candidateId) => lookup.get(candidateId));
|
||||||
if (!cyclePath) return;
|
if (!cyclePath) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user