feat(FN-5319): tighten scheduler queued-concurrency memo key to reduce fals

Add regression tests for queued concurrency in the scheduler and tighten the memo key used to track queued tasks, improving correctness of scheduler dispatch decisions.

Fusion-Task-Id: FN-5319
This commit is contained in:
Fusion (runfusion.ai)
2026-05-20 06:51:35 -07:00
committed by gsxdsm
parent 9efcf9375a
commit cee2c1385a
2 changed files with 107 additions and 16 deletions

View File

@@ -189,22 +189,13 @@ function formatConcurrencyLimitReason(diagnostic: ConcurrencyGateDiagnostic): st
return `queued — concurrency limit reached: gate=${gateLabel}; ${details.join("; ")}`;
}
function formatConcurrencyLimitMemoKey(diagnostic: ConcurrencyGateDiagnostic): string {
export function formatConcurrencyLimitMemoKey(diagnostic: ConcurrencyGateDiagnostic): string {
const gates = diagnostic.bindingGates.join(",");
const gateDetails = diagnostic.bindingGates.map((gate) => {
const snapshot = gate === "maxConcurrent"
? diagnostic.maxConcurrentGate
: gate === "maxWorktrees"
? diagnostic.maxWorktreesGate
: diagnostic.semaphoreGate;
const holders = diagnostic.holders[gate];
const holderKey = holders && holders.length > 0 ? holders.join(",") : "none";
if (!snapshot) {
return `${gate}:missing:${holderKey}`;
}
return `${gate}:${snapshot.used}/${snapshot.limit}:${holderKey}`;
});
return `queued-concurrency:${gates}:${gateDetails.join("|")}`;
const bindingHolders = [...new Set(
diagnostic.bindingGates.flatMap((gate) => diagnostic.holders[gate] ?? []),
)].sort();
const holderKey = bindingHolders.length > 0 ? bindingHolders.join(",") : "none";
return `queued-concurrency:${gates}:holders=${holderKey}`;
}
export interface SchedulerOptions {