spb/worthdoing Public
Autonomous investigation agent that discovers, challenges, and ranks things genuinely worth doing — Claude + Firecrawl, Next.js 16, PostgreSQL
TypeScript 91.5%
SQL 5.8%
CSS 2.2%
1/**2 * WorthDoing.ai3 * Author: Simon-Pierre Boucher4 * Contact: contact@spboucher.ai5 * File: tests/scoring.test.ts6 * Description: Worth Score computation tests — weighting, renormalization, separate evidence confidence.7 */8import { describe, it, expect } from "vitest";9import { computeWorthScore, type DimensionScore } from "@/lib/agent/scoring";1011const dim = (12 dimension: DimensionScore["dimension"],13 score: number,14 confidence: number,15): DimensionScore => ({ dimension, score, confidence });1617describe("computeWorthScore", () => {18 it("returns the score itself when all dimensions are equal", () => {19 const { worthScore } = computeWorthScore([20 dim("demand", 80, 0.9),21 dim("neglectedness", 80, 0.9),22 dim("feasibility", 80, 0.9),23 dim("why_now", 80, 0.9),24 dim("impact", 80, 0.9),25 ]);26 expect(worthScore).toBe(80);27 });2829 it("keeps evidence confidence separate from the score", () => {30 const strong = computeWorthScore([dim("demand", 90, 0.95), dim("impact", 90, 0.95)]);31 const weak = computeWorthScore([dim("demand", 90, 0.3), dim("impact", 90, 0.3)]);32 expect(strong.worthScore).toBe(weak.worthScore); // same score...33 expect(strong.evidenceConfidence).toBeGreaterThan(weak.evidenceConfidence); // ...different confidence34 });3536 it("weights demand and impact more than risk", () => {37 const demandHeavy = computeWorthScore([dim("demand", 100, 1), dim("risk", 0, 1)]);38 const riskHeavy = computeWorthScore([dim("demand", 0, 1), dim("risk", 100, 1)]);39 expect(demandHeavy.worthScore).toBeGreaterThan(riskHeavy.worthScore);40 });4142 it("renormalizes weights over provided dimensions", () => {43 const { worthScore } = computeWorthScore([dim("demand", 60, 0.8)]);44 expect(worthScore).toBe(60);45 });4647 it("handles the empty case defensively", () => {48 expect(computeWorthScore([])).toEqual({ worthScore: 0, evidenceConfidence: 0 });49 });50});51