/** * WorthDoing.ai * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai * File: src/lib/agent/scoring.ts * Description: Worth Score computation — evidence-weighted aggregate with separate evidence-confidence figure. */ export type DimensionScore = { dimension: "demand" | "neglectedness" | "feasibility" | "why_now" | "impact" | "competition" | "risk"; score: number; // 0..100, higher = better for the opportunity (risk scored as "risk manageability") confidence: number; // 0..1 — how well the evidence supports this score }; const WEIGHTS: Record = { demand: 0.22, neglectedness: 0.16, feasibility: 0.16, why_now: 0.14, impact: 0.18, competition: 0.08, risk: 0.06, }; /** * Worth Score = weighted mean of dimension scores (weights renormalized over * the dimensions actually provided). Evidence confidence is the same weighted * mean over per-dimension confidences — reported separately, never blended in: * a 93 backed by 41% confidence must look different from an 84 backed by 91%. */ export function computeWorthScore(scores: DimensionScore[]): { worthScore: number; evidenceConfidence: number; } { const totalWeight = scores.reduce((sum, s) => sum + WEIGHTS[s.dimension], 0); if (totalWeight === 0) return { worthScore: 0, evidenceConfidence: 0 }; let worth = 0; let conf = 0; for (const s of scores) { const w = WEIGHTS[s.dimension] / totalWeight; worth += w * s.score; conf += w * s.confidence; } return { worthScore: Math.round(worth * 10) / 10, evidenceConfidence: Math.round(conf * 1000) / 1000, }; }