Builds PaperTrail from the base skeleton into a full evidence-verification platform for the "Built with Claude: Life Sciences" hackathon (Builder Track). New named-user features (Build Beyond the Bench): - Lab Notebook Companion — rough bench notes -> structured, searchable, grounded experiment records (lib/labNotebook, /console/lab-notebook, migration 0059) - Clinical Trial Matcher — de-identified patient notes -> ranked eligible ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning (lib/trialMatcher, /console/trial-matcher, migrations 0060) Platform: - Deterministic verification moat (biostats recompute, exact-span grounding) - 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar, PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier) - Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise governance (RBAC, /api/v1 gateway, metering, audit chain, retention) - 17 OSS projects assimilated into native TypeScript on our stack (backend/engines retained + credited in NOTICE) - Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site - Next.js 16 upgrade, benchmark harness (honest smoke-test caveat) Licensing: Apache-2.0 (LICENSE + NOTICE).
56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { buildEvidenceReport } from "../lib/evidenceReport";
|
|
import {
|
|
evidenceReportToHtml,
|
|
evidenceReportToText,
|
|
} from "../lib/evidenceReportExport";
|
|
|
|
// Minimal serializer sanity test: the SoF export must surface the GRADE certainty,
|
|
// the pooled CI, and an ESCAPED claim in the HTML, and the synthesis verdict in the
|
|
// plain-text variant. Same three-study RR fixture the engines' oracles use.
|
|
const STUDIES = [
|
|
{ label: "Trial A", measure: "RR" as const, point: 0.5, ci_lower: 0.338, ci_upper: 0.74 },
|
|
{ label: "Trial B", measure: "RR" as const, point: 0.8, ci_lower: 0.606, ci_upper: 1.055 },
|
|
{ label: "Trial C", measure: "RR" as const, point: 0.6, ci_lower: 0.427, ci_upper: 0.843 },
|
|
];
|
|
|
|
// Claim carries markup-significant characters to prove the escaper runs.
|
|
const CLAIM = 'Drug X reduced events by 35% in <trial> "sub-group" & controls.';
|
|
|
|
describe("evidenceReportExport", () => {
|
|
const report = buildEvidenceReport({ claim: CLAIM, studies: STUDIES });
|
|
|
|
it("renders HTML containing the certainty, the pooled CI, and an escaped claim", () => {
|
|
expect(report.ok).toBe(true);
|
|
if (!report.ok) return;
|
|
|
|
const html = evidenceReportToHtml(report, CLAIM);
|
|
|
|
// Certainty (label form) appears in the badge.
|
|
const certLabel = { high: "High", moderate: "Moderate", low: "Low", very_low: "Very low" }[
|
|
report.certainty.certainty
|
|
];
|
|
expect(html).toContain(certLabel);
|
|
expect(html).toContain("certainty");
|
|
|
|
// The pooled random-effects CI bounds are rendered (2dp).
|
|
const r = report.pooled.random;
|
|
const lo = (Math.round(r.ciLower * 100) / 100).toString();
|
|
const hi = (Math.round(r.ciUpper * 100) / 100).toString();
|
|
expect(html).toContain(lo);
|
|
expect(html).toContain(hi);
|
|
|
|
// Claim is HTML-escaped — raw angle brackets / quotes must not leak through.
|
|
expect(html).toContain("<trial>");
|
|
expect(html).toContain("&");
|
|
expect(html).not.toContain("<trial>");
|
|
});
|
|
|
|
it("renders a text variant containing the synthesis verdict", () => {
|
|
if (!report.ok) return;
|
|
const text = evidenceReportToText(report, CLAIM);
|
|
expect(text).toContain("SYNTHESIS VERDICT");
|
|
expect(text).toContain("Pooled estimate");
|
|
});
|
|
});
|