Reference detail moved out of
CLAUDE.mdto keep that file a terse map. This is the full text for this subsystem.
tools/check_data.py (stdlib) runs over the emitted public/data/,
independent of generate_data.py. Exit 0 = no errors (warnings allowed), 1 =
errors. Functions take loaded data as args (unit-testable). Eight families:
- Quote table (referential integrity of the externalized
quotes.jsonl): every node's{quote_id, provenance}source must resolve to a quote node, and every quote node must be referenced by at least one node (no orphans) = error either way. The loader rehydrates each reference in place first (mirror of the viewer), so the families below see inline sources. - Duplicates (per collection + projections by
from -> to): exact or normalized id/key collision = error (normalize_for_matchlowercases + strips non-alphanumerics, somao_a/mao-acollide); normalized display-name collision = warning. - Reachability: every cross-reference must resolve (drug binding
target, projection endpoints/kind, circuit/receptor/target structure refs, projection- groupkind/signkey, receptor classification keys, target type + region bases, every receptor also adrug_targetskey). The region-base check is what guarantees the panels' "Found in" rows are clickable. Dangling refs = error. - TODOs (provenance-aware): a literal
"TODO"outside a source url, or a focusable target with nowikipedia, = warning. A source url left"TODO"is[ok]for anllmcitation (expected) but warned if the source claims a higher grade. TODOs never fail the run. - Provenance grades: every
provenance(incl. per-binding sources,nbn_sources, circuit + projection-group sources), everyclassification_provenance, everywikipedia_provenancemust be a known grade (llm/sourced/verified) or error. Re-confirmsmeta.provenance_statsis self-consistent (per-kind sums, totals, recomputedpct_backed) or error. - Source quotes (the heart of sourcing): each quote-level drug source
(
{corpus,page,quote,provenance}):corpusmust resolve tometa.source_corpora, averifiedsource must carry page + quote, and the normalized quote must be an exact substring of the normalized cited page text. Page material is author-side (see CLAUDE.local.md); the quote check is skipped + warned on a clone without it. A quote not on its page = error (the gate that keeps the LLM extraction honest). Also checks each binding'ski: its source corpus resolves, anaffinity_onlybinding carries aki, and (author-side, skipped on a clone) the citedki_idrow is really in the corpus CSV with that value (the PDSP analogue of the quote gate). - Structure connectivity (warns, never errors): isolated / inward-only /
outward-only structures from the projection endpoints (
bidirectionalcounts both ways). Source nuclei + olfactory bulb are expected outward-only, pituitary inward-only; the point is to flag a region wired one-way (e.g. a missing return pathway). - Measured-affinity (Ki) coverage (warns, never errors): lists each drug with
bindings but zero PDSP Ki across all of them (combos excluded), and cross-checks
meta.provenance_stats.ki_coverageagainst a recompute. A quote-only binding is still sourced, so this is not a grade gate: it surfaces where a measured affinity was never looked up, the honest complement to "% sourced".