feat(FN-3954): blocker staleness fanout and escalation for tasks

Merges FN-3954: adds a blocker fanout system where task staleness automatically escalates to upstream blocking tasks, with a new `blocker-fanout` core module, dashboard hooks wiring that surfaces escalation status on the board and executor status bar, and a new settings toggle to disable escalation.

Fusion-Task-Id: FN-3954
This commit is contained in:
Fusion
2026-05-10 19:47:07 -07:00
committed by gsxdsm
parent 0c5c47933a
commit 2aec3474b0
24 changed files with 411 additions and 143 deletions

View File

@@ -1,104 +1,34 @@
import { useMemo } from "react";
import { HIGH_FANOUT_BLOCKER_TODO_THRESHOLD, type Task } from "@fusion/core";
import { type Task } from "@fusion/core";
import {
computeBlockerFanoutMap as computeBlockerFanoutMapCore,
type BlockerFanoutEntry,
} from "../../../core/src/blocker-fanout";
export interface BlockerFanoutEntry {
totalCount: number;
activeTodoCount: number;
dependentIds: string[];
staleBlockedByDependentIds: string[];
isHighFanout: boolean;
}
export type { BlockerFanoutEntry };
// Keep in sync with packages/engine/src/self-healing.ts
export const MAX_AUTO_MERGE_RETRIES = 3;
const ACTIVE_COLUMNS = new Set<Task["column"]>(["triage", "todo", "in-progress", "in-review"]);
function isStaleBlockedByBlocker(blocker: Task | undefined): boolean {
if (!blocker) {
return true;
}
if (blocker.column === "done" || blocker.column === "archived") {
return true;
}
if (blocker.column === "in-review" && blocker.paused === true) {
return true;
}
if (
blocker.column === "in-review" &&
blocker.status === "failed" &&
(blocker.mergeRetries ?? 0) >= MAX_AUTO_MERGE_RETRIES
) {
return true;
}
return false;
export interface UseBlockerFanoutOptions {
staleHighFanoutAgeThresholdMs?: number;
}
interface MutableEntry {
dependentIds: string[];
blockedByDependentIds: string[];
activeCount: number;
activeTodoCount: number;
export function computeBlockerFanoutMap(
tasks: Task[],
options: UseBlockerFanoutOptions = {},
): Map<string, BlockerFanoutEntry> {
return computeBlockerFanoutMapCore(tasks, MAX_AUTO_MERGE_RETRIES, {
staleHighFanoutAgeThresholdMs: options.staleHighFanoutAgeThresholdMs,
});
}
export function computeBlockerFanoutMap(tasks: Task[]): Map<string, BlockerFanoutEntry> {
const taskById = new Map(tasks.map((task) => [task.id, task]));
const fanout = new Map<string, MutableEntry>();
const ensureEntry = (blockerId: string): MutableEntry => {
let entry = fanout.get(blockerId);
if (!entry) {
entry = { dependentIds: [], blockedByDependentIds: [], activeCount: 0, activeTodoCount: 0 };
fanout.set(blockerId, entry);
}
return entry;
};
for (const task of tasks) {
const active = ACTIVE_COLUMNS.has(task.column);
const isTodo = task.column === "todo";
const dependencyIds = task.dependencies ?? [];
for (const depId of dependencyIds) {
if (!depId) continue;
const entry = ensureEntry(depId);
entry.dependentIds.push(task.id);
if (active) entry.activeCount += 1;
if (isTodo) entry.activeTodoCount += 1;
}
if (task.blockedBy) {
const entry = ensureEntry(task.blockedBy);
entry.dependentIds.push(task.id);
entry.blockedByDependentIds.push(task.id);
if (active) entry.activeCount += 1;
if (isTodo) entry.activeTodoCount += 1;
}
}
const result = new Map<string, BlockerFanoutEntry>();
for (const [blockerId, entry] of fanout) {
const blocker = taskById.get(blockerId);
const staleBlockedByDependentIds = isStaleBlockedByBlocker(blocker)
? [...entry.blockedByDependentIds]
: [];
result.set(blockerId, {
totalCount: entry.activeCount,
activeTodoCount: entry.activeTodoCount,
dependentIds: entry.dependentIds,
staleBlockedByDependentIds,
isHighFanout: entry.activeTodoCount >= HIGH_FANOUT_BLOCKER_TODO_THRESHOLD,
});
}
return result;
}
export function useBlockerFanout(tasks: Task[]): Map<string, BlockerFanoutEntry> {
return useMemo(() => computeBlockerFanoutMap(tasks), [tasks]);
export function useBlockerFanout(
tasks: Task[],
options: UseBlockerFanoutOptions = {},
): Map<string, BlockerFanoutEntry> {
return useMemo(
() => computeBlockerFanoutMap(tasks, options),
[tasks, options.staleHighFanoutAgeThresholdMs],
);
}