caelum0x 174222bcaa feat: Builder-Track named-user tools, bio + evidence-intelligence platform, Apache-2.0
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).
2026-07-10 16:23:13 +03:00

86 lines
3.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { SynthesisReportView } from "./types";
// Client-side, dependency-free serialization of a synthesis review to plain text for
// the Export button. The engine numbers and grounded prose already live on the report
// object; this just lays them out linearly. Kept separate from the render components
// so it's trivially testable and reusable.
function factsLines(report: SynthesisReportView): string[] {
const f = report.facts;
const lines: string[] = ["ENGINE FACTS"];
if (f.poolable) {
lines.push(` Measure : ${f.measure ?? "—"}`);
lines.push(` Studies (k) : ${f.k ?? "—"}`);
lines.push(
` Pooled estimate : ${f.pooledPoint ?? "—"} (${f.pooledCiLower ?? "—"}–${f.pooledCiUpper ?? "—"})`
);
lines.push(` Reduction : ${f.pooledReductionPercent ?? "—"}%`);
lines.push(` Heterogeneity I² : ${f.iSquared ?? "—"}%`);
lines.push(` GRADE certainty : ${f.certainty ?? "—"}`);
lines.push(` Claim vs pool : ${f.verdict ?? "—"}`);
} else {
lines.push(` Pooling not possible: ${f.engineRationale}`);
}
return lines;
}
export function synthesisReportToText(report: SynthesisReportView): string {
const idx = new Map(report.usedSources.map((s, i) => [s.id, i + 1]));
const lines: string[] = [];
lines.push(report.title);
lines.push("=".repeat(72));
lines.push(`Topic: ${report.topic}`);
lines.push("");
lines.push(...factsLines(report));
lines.push("");
for (const section of report.sections) {
lines.push(section.heading.toUpperCase());
if (section.sentences.length === 0) {
lines.push(" (no source-grounded content)");
} else {
const paragraph = section.sentences
.map((s) => {
const cites =
s.grounding && s.citations.length > 0
? " " +
s.citations
.map((id) => `[${idx.get(id) ?? "?"}]`)
.join("")
: "";
return `${s.text}${cites}`;
})
.join(" ");
lines.push(` ${paragraph}`);
}
lines.push("");
}
lines.push("SOURCES");
report.usedSources.forEach((s, i) => {
lines.push(` [${i + 1}] ${s.title ?? "(untitled)"} · ${s.source_type}`);
});
lines.push("");
lines.push(
`Dropped ungroundable sentences: ${report.droppedSentenceCount}. ` +
"Every number above is computed by PaperTrail's deterministic evidence engine; " +
"the prose is drafted by Claude and grounded to source spans."
);
return lines.join("\n");
}
// Trigger a browser download of the given text as a .txt file. No-op on the server.
export function downloadText(filename: string, text: string): void {
if (typeof window === "undefined") return;
const blob = new Blob([text], { type: "text/plain;charset=utf-8" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}