const STALE_THRESHOLD_DAYS = 7;
const MS_PER_DAY = 86_400_000;
/**
 * Find specs that have been in the same non-done status for more than 7 days.
 * Uses updatedAt as the reference timestamp.
 * Returns results sorted by staleDays descending (worst first).
 */
export function detectBottlenecks(specs) {
    const now = Date.now();
    const bottlenecks = [];
    for (const spec of specs) {
        if (spec.status === 'done') {
            continue;
        }
        const updatedMs = new Date(spec.updatedAt).getTime();
        if (isNaN(updatedMs)) {
            continue;
        }
        const staleDays = Math.floor((now - updatedMs) / MS_PER_DAY);
        if (staleDays >= STALE_THRESHOLD_DAYS) {
            bottlenecks.push({
                specId: spec.id,
                title: spec.title,
                status: spec.status,
                staleDays,
            });
        }
    }
    return bottlenecks.sort((a, b) => b.staleDays - a.staleDays);
}
//# sourceMappingURL=bottleneck-detector.js.map