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

53 lines
1.7 KiB
TypeScript

import type { NextRequest } from "next/server";
import { z } from "zod";
import { withOrg, type Ctx } from "@/lib/api/handler";
import { ok, fail } from "@/lib/api/response";
import { getPool } from "@/lib/db";
import { requireRole } from "@/lib/authz/rbac";
import { deleteExperiment, getExperiment } from "@/lib/labNotebook/repository";
export const runtime = "nodejs";
const idSchema = z.string().uuid();
// GET /api/lab-notebook/[id] — one full experiment record, org-scoped. Any member reads.
export const GET = withOrg(async (_req: NextRequest, ctx: Ctx, params) => {
try {
requireRole(ctx, "viewer");
const parsed = idSchema.safeParse(params?.id);
if (!parsed.success) {
return fail("Invalid experiment id.", 400);
}
const record = await getExperiment(getPool(), ctx.org.id, parsed.data);
if (!record) {
return fail("Experiment not found.", 404);
}
return ok(record);
} catch (err) {
console.error("[/api/lab-notebook/:id] get failed:", err);
return fail("Failed to load experiment.", 500);
}
});
// DELETE /api/lab-notebook/[id] — remove one experiment, org-scoped. Editor+.
export const DELETE = withOrg(async (_req: NextRequest, ctx: Ctx, params) => {
requireRole(ctx, "editor");
const parsed = idSchema.safeParse(params?.id);
if (!parsed.success) {
return fail("Invalid experiment id.", 400);
}
try {
const removed = await deleteExperiment(getPool(), ctx.org.id, parsed.data);
if (!removed) {
return fail("Experiment not found.", 404);
}
return ok({ id: parsed.data, deleted: true });
} catch (err) {
console.error("[/api/lab-notebook/:id] delete failed:", err);
return fail("Couldn't delete this experiment. Please try again.", 500);
}
});