papertrail/db/migrations/0055_validation-status.sql
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

33 lines
1.6 KiB
SQL

-- VALIDATION / COMPLIANCE STATUS framework. A per-evidence-run record of which
-- verification engines ran, which primary sources were reachable, the resulting
-- coverage, and a documented deterministic quality score. This lets a submission
-- carry its own validation report: a regulated-pharma buyer (medical-affairs /
-- regulatory) can show, for any evidence run, exactly what was checked, what was
-- reachable, and how complete the run was — an auditable "was this defensible?"
-- artifact rather than an opaque verdict.
--
-- * subject — the claim / submission the run validates (denormalized)
-- * engines_run — jsonb list of engine keys that actually executed
-- * sources_reachable — jsonb map/list of source -> reachable boolean
-- * coverage — ran/required engines, in [0,1]
-- * quality_score — documented weighting of coverage + source reachability
-- * status — complete | partial | insufficient
--
-- Idempotent: safe to run repeatedly. org_id on the table (uuid FK); uuid pk;
-- created_at timestamptz default now(); index (org_id, created_at desc).
create table if not exists validation_runs (
id uuid primary key default gen_random_uuid(),
org_id uuid not null references orgs(id) on delete cascade,
subject text not null,
engines_run jsonb not null default '[]'::jsonb,
sources_reachable jsonb not null default '{}'::jsonb,
coverage numeric not null default 0,
quality_score numeric not null default 0,
status text not null,
created_at timestamptz not null default now()
);
create index if not exists validation_runs_org_id_idx
on validation_runs(org_id, created_at desc);