function decideReason(signals, staleThresholdMs, now) {
    const ageMs = now.getTime() - signals.mtime.getTime();
    if (ageMs > staleThresholdMs) {
        return { kind: 'stale', ageMs, thresholdMs: staleThresholdMs };
    }
    if (signals.orphanLock?.present) {
        return {
            kind: 'orphan-git-lock',
            lockPath: signals.orphanLock.path,
            lockAgeMs: signals.orphanLock.ageMs,
        };
    }
    if (signals.unresolvedConflict) {
        return { kind: 'unresolved-conflict' };
    }
    return null;
}
export async function detectDegradedWorktrees(input, deps) {
    const now = input.now();
    const reports = [];
    for (const entry of input.entries) {
        const signals = await deps.healthProbe.probe(entry);
        const reason = decideReason(signals, input.staleThresholdMs, now);
        const health = reason === null ? { status: 'healthy' } : { status: 'degraded', reason, detectedAt: now };
        reports.push({ entry, health });
    }
    return reports;
}
//# sourceMappingURL=detectDegradedWorktrees.usecase.js.map