From 235c5c5322c6817d38e3b96f2dae2b77880ff78f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2026 19:47:52 +0000 Subject: [PATCH 1/2] fix: source sector compliance baseline from DB instead of hardcoded scores Replace the hardcoded BASELINE_SCORES map (and its 'migrate to DB' TODO) in SectorComplianceDetail with the DB-driven sectorBenchmarks.list query, so the sector baseline reflects the latest sector_benchmarks snapshot rather than static values baked into the bundle. Co-Authored-By: Patrick Munis --- client/src/pages/SectorComplianceDetail.tsx | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/client/src/pages/SectorComplianceDetail.tsx b/client/src/pages/SectorComplianceDetail.tsx index 1d69914d07..780fc4eeba 100644 --- a/client/src/pages/SectorComplianceDetail.tsx +++ b/client/src/pages/SectorComplianceDetail.tsx @@ -27,17 +27,6 @@ import { } from "lucide-react"; // Rendered inside DashboardLayout via App.tsx router -// ─── Sector compliance baseline scores (last audit cycle) ──────────────────── -// TODO: migrate to DB-driven config (e.g. /api/trpc/sectorConfig.baselines) -// so scores update per audit cycle without redeploying. -const BASELINE_SCORES: Record = { - fintech: 87, - healthcare: 92, - energy: 78, - insurance: 85, - telecom: 81, -}; - // ─── Sector metadata ────────────────────────────────────────────────────────── const SECTOR_META: Record { + const rows = (benchmarkQuery.data ?? []) as Array<{ avg_compliance_score?: number | string }>; + const v = rows[0]?.avg_compliance_score; + return v != null && !Number.isNaN(Number(v)) ? Math.round(Number(v)) : null; + })(); + // ── Resolve active query ───────────────────────────────────────────────── type EntityRow = Record; let entities: EntityRow[] = []; @@ -371,8 +371,8 @@ export default function SectorComplianceDetail() {
Compliance Score
{score}%
- {BASELINE_SCORES[sector] && ( -
Baseline: {BASELINE_SCORES[sector]}%
+ {baselineScore != null && ( +
Sector baseline: {baselineScore}%
)} From 95cc89942e98335bdd3e4d4d41c0a7ab92ea0a71 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2026 19:57:10 +0000 Subject: [PATCH 2/2] test: assert sector baseline is DB-driven (phase21) Update the phase21 test that previously asserted the hardcoded baseline scores (fintech: 87, healthcare: 92) to instead assert the page sources the baseline from trpc.sectorBenchmarks.list, and guard against reintroducing the hardcoded BASELINE_SCORES map. Co-Authored-By: Patrick Munis --- server/phase21.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/phase21.test.ts b/server/phase21.test.ts index da2b363cf6..7f2119d97f 100644 --- a/server/phase21.test.ts +++ b/server/phase21.test.ts @@ -43,10 +43,13 @@ describe("SectorComplianceDetail page", () => { expect(c).toContain("trpc.insurance.listCompanies.useQuery"); expect(c).toContain("trpc.telecom.listOperators.useQuery"); }); - it("shows compliance score per sector", () => { + it("sources the sector baseline from the DB (sectorBenchmarks), not hardcoded scores", () => { const c = fs.readFileSync(detailPath, "utf-8"); - expect(c).toContain("fintech: 87"); - expect(c).toContain("healthcare: 92"); + expect(c).toContain("trpc.sectorBenchmarks.list.useQuery"); + expect(c).toContain("avg_compliance_score"); + // Guard against reintroducing the old hardcoded baseline map + expect(c).not.toContain("fintech: 87"); + expect(c).not.toContain("BASELINE_SCORES"); }); it("has pagination controls", () => { const c = fs.readFileSync(detailPath, "utf-8");