/**
 * Nexus Prime — Workflow Priors
 *
 * Tracks effective workflow pairings for task types.
 */
export function computeWorkflowPriors(history) {
    const key = (t, w) => `${t}::${w}`;
    const grouped = new Map();
    for (const entry of history) {
        const k = key(entry.taskType, entry.workflowName);
        let g = grouped.get(k);
        if (!g) {
            g = { taskType: entry.taskType, workflowName: entry.workflowName, effective: 0, total: 0 };
            grouped.set(k, g);
        }
        g.total++;
        if (entry.wasEffective)
            g.effective++;
    }
    return [...grouped.values()]
        .map(g => ({
        taskType: g.taskType,
        workflowName: g.workflowName,
        effectivenessRate: g.total > 0 ? g.effective / g.total : 0,
        sampleCount: g.total,
    }))
        .sort((a, b) => b.effectivenessRate - a.effectivenessRate);
}
