import { traceValue } from '@cancerindex/ranking'; import { Section } from '@/components/ui/section'; import { JsonView } from '@/components/ui/json-view'; import { EmptyState } from '@/components/ui/empty-state'; import { db } from '@/lib/db'; import { str, type SP } from '@/lib/search-params'; const TABLES = ['rankings', 'epidemiology_observations', 'survival_observations', 'cancer_gene_frequencies', 'literature_counts']; /** Lineage trace tool (§252-253): value → inputs → observation → provenance → raw record. */ export default async function TracePage({ searchParams }: { searchParams: Promise }) { const sp = await searchParams; const table = str(sp, 'table'); const id = str(sp, 'id'); let result: Record | null = null; let error: string | null = null; if (table && id) { if (!TABLES.includes(table)) error = 'unsupported table'; else if (!/^\d{1,12}$/.test(id)) error = 'id must be a numeric row id'; else { try { result = await traceValue(db(), table, id); } catch (e) { error = (e as Error).message; } } } return (

Trace

Follow any derived or observed value back to its provenance row and raw source record.

{error ?

{error}

: null} {result ? (
{'error' in result ? : }
) : !table ? ( Ranking rows link here from every "Why this rank?" panel. ) : null}
); }