TL;DR
CTGov Viz Agent is a backend service. You give it a clinical-trials question in English — plus, optionally, structured fields like condition or start_year — and it returns a structured visualization specification whose every value was computed from the ClinicalTrials.gov Data API v2, and whose every datum carries deep citations: the nct_id of a contributing trial, and the exact field value that put it in that bucket.
One rule governs the whole design: the model decides what to compute; deterministic code computes it — the model never emits a number. That is not a prompt instruction with a prompt instruction's reliability. It is a property of a type. The planner returns one closed Pydantic object, and that object declares no count, no total, and no value field, so a fabricated number has nowhere to live in the first place.
Three things make that claim checkable rather than assertable, and this page is organised around them. One: the same question planned by GPT and by Claude produces byte-identical charts — 35 numeric leaves on each side, 0 of them different. Two: one offline command re-checks every shipped run against five invariants with no API key, no network and no cost, and prints 16/16 examples passed. Three: the harness has teeth — the suite includes tamper tests proving a fabricated excerpt, an inflated bar and a broken chart-type/data-shape pairing each make it fail.
Scale, for calibration: 11,409 lines of application Python across 44 modules against 8,100 lines of tests, 602 tests collected with zero failures (three skip by design; further live-registry tests skip when the registry does not answer), ruff clean. Fifteen recorded end-to-end runs plus a cross-provider twin ship as raw JSON in the repo. It was built in 21 hours against a 24-hour take-home box, for a Seoul AI company building an AI-native OS for pharma and life sciences. The implementation landed in the repository's first commit on 2026-07-16, followed that morning by six small presentation commits, with hardening and documentation passes on 07-21, 07-22 and 08-01 — the second of those is where this page's least flattering section comes from.
The invariant, and the type that enforces it
The failure mode this system is built against is specific and boring: a language model asked to summarise data produces a plausible number that no data produced. Prompting against it works most of the time, which is the worst possible reliability profile for a number a clinician might act on. So the number was taken away from the model entirely.
The planner makes exactly one structured-output call, with tools=None — no tool loop lives in the planner. It classifies the question into one of six query classes and fills that recipe's slots. Its return type is the whole of its authority, and here it is in full:
PlannerOutput app/llm/planner.py ├─ query_class distribution · timeseries · compare │ geographic · network · single_value ├─ entities (str|None) condition · drug · sponsor │ country · term ├─ filters (str|None) overall_status · study_type │ sponsor_class · intervention_type │ country │ list[str] phase │ int|None start_year <- selects a population │ int|None end_year <- selects a population ├─ field · date_field · grain · chart_type ├─ alternates · series · network ├─ interventional_only bool └─ answer_kind · notes # no count. no total. no value. # the only two integer fields in the whole object are those year # bounds, and a year bound selects a population — it is never # rendered as data.
That is the argument. A fabricated bar height cannot be returned by this function because the function has no field of that shape. The set of filter keys is closed — there is no dict[str, Any] anywhere in the object — so a hallucinated filter key is not merely rejected, it is unrepresentable. Be precise about where that guarantee stops, because it is exactly the kind of thing this page should not overstate: a filter’s value is typed as a plain string. What constrains it is the token set enumerated into the system prompt, and then the deterministic Checker, which rejects any token that is not real. The type closes the shape; the Checker closes the vocabulary. The system prompt does also say“HARD INVARIANT: You NEVER count, page, aggregate, or state a number”, but that sentence is belt to the type's braces; if the model ignored it entirely the guarantee would still hold.
The other half of the invariant is the oracle. A registry has no canonical right answer to “how many trials, by phase” — so correctness here means internal consistency against the one server number you can check. For each query the executor issues a countTotal=true call to get the exact matching total, then pages and aggregates client-side, and the Output Reviewer asserts that the distinct trials it counted equal that total. The count call and every page route through the same parameter builder, so a filter is applied to both populations or to neither and the two can never quietly desynchronise.
On the phase distribution of interventional pancreatic cancer trials, that reconciliation reads: eight buckets, Σ distinct nctId == countTotal == 3,950. Not approximately. There is also a fifth verifier invariant whose name is worth quoting because it closes the obvious loophole — NO-LLM-NUMBER: notes cannot launder numbers — a check that a digit appearing in a free-text note is a computed value and not a model-authored one, tested with a planted sentinel.
Nine nodes, three back-edges into plan, one budget
The figure at the top of this page is the graph. Nine nodes are registered; the spine is linear and the split between them is the invariant made structural — blue nodes are the ones a model touches, green nodes are deterministic code.
START
|
v
merge_inputs -> plan -> check -> review_intent -> execute
(code) (LLM) (code) (LLM) (code)
^ |
| v
| build_spec (code)
| |
| v
| review_output (code+LLM)
| |
| v
| respond (code) -> END
|
+-- escalate, at most ONCE, from any of three gates:
check rejects the plan as illegal
review_intent asks for a revision
execute returns zero results
check --illegal--> error -> respond There is exactly one Checker and two Reviewers, and the two families never blur. A Checker is deterministic code asking a mechanical question: is every token and field in this plan real? A no comes back as one of 18 distinct machine-readable rejection codes. A Reviewer applies model judgment to a semantic one: did the planner understand the question, and does the output faithfully answer it? Neither reviewer has a numeric field to put a count in — but a reason is prose, and prose can carry digits, so a deterministic gate drops any Output-Reviewer note whose digit-runs do not already appear in the computed envelope. The repo records that gate as a defect it found, not as the original design. Both reviewers are gates that emit approve, revise or flag over data that is already typed or already computed.
The dashed edges back to plan are the only reason this is LangGraph rather than a plain DAG runner. There are three, one per router — a checker reject, an intent revision, zero results — and all three guard on the same shared counter with the same condition, escalation_count < 1. The counter is zeroed once on entry and incremented once on re-plan, so the budget is one escalation for the whole request, not one per trigger, and every trace is finite. The rejection reason is threaded into the next prompt as feedback, which makes the single retry a correction rather than a blind re-roll.
Progress is exposed as a fixed eight-stage status enum over SSE — planning · validating · plan_approved · fetching · aggregating · building_spec · verifying · done — so a frontend can render the pipeline without ever being shown the model's private reasoning. The stream runs the graph exactly once, so the streamed stages and the terminal envelope come from one execution and cannot diverge. The detail I like best there is an import-time contract check: the set of statuses the node map can actually emit must equal the declared enum, or the application raises at startup. A stage enum that has silently drifted from the graph is a documentation bug that ships; here it is a boot failure.
Underneath is one engine, not five handlers: every query class routes through the same page → count → dedupe → bucket → cite core plus a small per-class helper. Six query classes; eight tools registered, six live (two are documented stubs that raise rather than pretend); eight chart types declared, seven reachable — scatter is in the enum but no recipe lists it and the checker will not accept it, because clinical trials offer no honest generic pair of continuous axes; a study-duration histogram ships in its place. Breadth comes from composing that core, which is why fifteen very different questions — one of them a refusal, one a declined graph and one a clarification — all come out of one code path.

Deep citations, and where they stop
A citation on a chart is usually a link to a dataset. Here it is a link to the specific record, and to the specific value in that record, that made this bar one taller. Each citation is two-part, on purpose:
excerpt— the readable half. The trial's brief title, string-extracted from the record, never model-authored. It is what makes a citation legible to a human scanning a list.matched_value— the rigorous half. The exact value atfield_paththat decided membership:"PHASE1","France", a date. This is the anti-fabrication anchor, and it is re-verified element-precise: not “is this string somewhere in the record” but “is this exactly one element of the array at this path”.
Composite buckets are where element-precision earns its keep. The registry's phase field is a list, so a Phase 1/2 trial carries ["PHASE1", "PHASE2"]; the engine emits the bucket as the pipe-joined token PHASE1|PHASE2 (the pipe is the engine's own discriminator, never a wire token), splits it back, and re-verifies each member, so the citation carries matched_tokens: ["PHASE1", "PHASE2"]. The slash form “Phase 1/2” is only a display label.

A “Recruiting: 120,000” bucket cannot ship 120,000 citation objects, so citations are sampled — and the sampling is disclosed at every datum rather than in a footnote. Each bucket carries its exact contributing_count (always the true size), a deterministic sample of up to K = 20 citations taken in sorted nctId order so it is stable across runs, and a citations_truncated flag when the true set exceeds K. On the count-at-any-scale path the per-bucket sample is 10, pulled in the same request as that bucket's count, so provenance costs no extra call. K is a deploy-time constant, not something the agent can turn up.

Two boundaries, both of which the code states about itself. First: the readable excerpt comes from a fixed identification path, so it is not a quote of the value that decided membership and it is not re-verified — the anchor is matched_value, and the docs say so rather than letting “deep citations” imply more than it delivers.
Second, and sharper: the Output Reviewer checks every citation's matched value against its own stored value at build time, then a second, independent pass re-checks the same literal against the actual fetched record — which defeats even a citation whose stored value was fabricated to match itself. That second pass is bounded to a 500-record index. On a wide board (the country ranking cites 566 distinct trials) roughly 12% of citations therefore fall outside the sample and are skipped rather than failed. The code names this: a strong spot-check, not a total gate. That the boundary is written in the module implementing it, and not only in a README, is the part worth noticing.
One more case, because it is the one that usually gets faked. When a trial lands in a bucket precisely because a field is missing, there is no value to quote — so it carries an absence citation: matched_value: "" against a value: null, valid only when the field is genuinely absent at that path. There is exactly one in the whole shipped ladder: NCT00003514, which has no startDateStruct.date and therefore sits in the study-duration histogram's undated bin. The NA phase bucket is deliberately not this case — NA is a real registry token and cites itself as one.
Three real runs, and what was trimmed
Below are three of the fifteen recorded runs, embedded in this page. Click any bar, node or edge and it opens the citations that run actually recorded, each linking out to the trial on clinicaltrials.gov. The natural-language questions are verbatim, as they were asked:
- “How are interventional pancreatic cancer trials distributed across phases?” — a bar chart; 8 buckets, Σ = 3,950 = countTotal.
- “Show a network of drugs studied together in melanoma trials” — a drug↔drug graph; 59 nodes, 194 edges, 388 citations.
- “How are recruiting, industry-sponsored interventional pancreatic cancer trials that started in 2020 or later distributed across phases?” — one sentence, four stacked filters — three of them new, since 3,950 already carries the interventional one; the population collapses to 229 and still reconciles exactly.
“How are interventional pancreatic cancer trials distributed across phases?”
/api/v2/studies · retrieved 2026-07-16T00:01:36.288422+00:00 · clinicaltrials.gov
Bar chart. Phase against Trials. NA (not applicable): 937; Early Phase 1: 109; Phase 1: 895; Phase 1/2: 505; Phase 2: 1,143; Phase 2/3: 58; Phase 3: 232; Phase 4: 71. Selecting a bar reveals the registry citations behind it.
Σ distinct nctId 3,950 = countTotal 3,950 across 8 buckets
Reconciles: the 8 buckets' distinct NCT ids sum to 3950, exactly the ClinicalTrials.gov countTotal of 3950 for this filtered population.
40 distinct trials are cited in this embed — a sample, not the population.
Phase 2 — 1,143 trials
showing 5 of the 20 citations this run sampled · 1,143 contributing trials · the run itself sampled rather than citing every trial
- NCT000011651 / 5
Combination Chemotherapy in Patients With Zollinger-Ellison Syndrome and Tumors of the Pancreas
counted because protocolSection.designModule.phases = PHASE2
- NCT000011912 / 5
The Use of Oral Omeprazole and Intravenous Pantoprazole in Patients With Hypersecretion of Gastric Acid
counted because protocolSection.designModule.phases = PHASE2
- NCT000012283 / 5
Interferon and Octreotide to Treat Zollinger-Ellison Syndrome and Advanced Non-B Islet Cell Cancer
counted because protocolSection.designModule.phases = PHASE2
- NCT000018054 / 5
A Phase II Clinical Trial of Suppression of Human Antimouse Antibody and Human Antitoxin Response to Immunotoxin LMB-1 by Rituximab
counted because protocolSection.designModule.phases = PHASE2
- NCT000024755 / 5
Cyclophosphamide Plus Vaccine Therapy in Treating Patients With Advanced Cancer
counted because protocolSection.designModule.phases = PHASE2
- The chart answers phase distribution for interventional pancreatic cancer trials, but the inclusion of an NA phase category suggests a sizable unspecified/not applicable bucket rather than a clean phase-only distribution, which may be misleading for the asked framing.
The exact request sent to the registry
- query.cond
- pancreatic cancer
- filter.advanced
- AREA[StudyType]COVERAGE[FullMatch]INTERVENTIONAL
- countTotal
- true
- pageSize
- 1000
- fields
- NCTId|Phase
- studyType
- INTERVENTIONAL
- interventional_only
- true
What’s trimmed in this embed
KEPT, verbatim and uncut: every bucket of both bar runs (8 + 8), every node (59) and every edge (194) of the network run, and every count on all of them — countTrials, countMentions, contributingCount, edge weight, node degree, countTotal. No number was rounded, binned or recomputed.
TRIMMED, and exactly how: (1) Bar citations are capped at 5 per bucket, taking the first 5 in the run's own NCT-id-ascending order — never reshuffled, never re-sampled. The run itself had already sampled K citations per bucket (K = sampledCitationCount, up to 20, with citationsTruncated flagging where the service sampled); 76 of 263 sampled bar citations ship here. (2) Edge citations are capped at 2, which is all the source carries — one per endpoint — so all 388 of 388 ship, and all 194 edges kept their citations; none were dropped for budget. (3) Per-datum source_ids arrays (the sampled NCT-id lists) are not shipped; their length is preserved as sampledCitationCount / sampledTrialCount so the UI can say truthfully how many of how many it is showing. (4) Each citation keeps nct_id, excerpt, field_path and matched_value byte-for-byte; the raw `value` array (all values at that field_path) and `matched_tokens` are dropped — and `matched_tokens` was NOT always empty: 66 of the 263 sampled bar citations carried a real token array, all of them in the composite phase buckets (PHASE1|PHASE2, PHASE2|PHASE3), and 20 of those are among the 76 shipped here. Dropping it removed real evidence, not an empty field; the composite buckets' tokens are visible in Figure 3's screenshot and in the full run JSON in the repo. (5) The run's vega_lite block and its flat top-level citation index are dropped — both are redundant with what is here.
NOT IMPLIED: this file is a faithful subset, not a complete one. It shows a sample of citations per datum, and it says so at every datum. Separately, the network run's own graph is itself a documented subset of the underlying co-occurrence graph — the service capped nodes at the top 60 by degree and pruned edges below weight 2 — which is why it is 59 nodes and 194 edges. That cap is the service's, not this file's, and it is stated verbatim in each run's sourceNotes.
This page's whole claim is that no number on it is fabricated, so a silent trim that implied completeness would break exactly the thing it is arguing. Stated plainly here, and restated in full inside the widget itself under “What's trimmed in this embed”:
Kept, uncut: every bucket of both bar runs (8 and 8), every node (59) and every edge (194) of the network run, and every count on all of them — distinct-trial counts, mention counts, contributing counts, edge weights, node degrees, and each run's countTotal. Nothing was rounded, re-binned or recomputed.
Trimmed: bar citations are capped at 5 per bucket, taking the first 5 in the run's own ascending NCT-id order — never reshuffled, never re-sampled — so 76 of the 263 citations the runs themselves sampled ship here. Edge citations are capped at 2, which is all the source carries, so all 388 of 388 ship. The per-datum lists of sampled NCT ids are dropped but their lengths are kept, so the panel can say truthfully how many of how many it is showing. Each surviving citation keeps its nct_id, excerpt, field_path and matched_value byte-for-byte — but it loses two things worth naming: its raw value array, and its matched_tokens. That second one is not an empty field. 66 of the 263 sampled bar citations carried a real token array, every one of them in a composite phase bucket, and 20 of those are among the 76 shipped here. Dropping it dropped real evidence — the tokens Figure 3 shows as PHASE1/PHASE2 chips. Each run's vega_lite projection and its flat top-level citation index are dropped too, as redundant with what is rendered.
Not implied: this is a faithful subset, not a complete one. Separately, the network run's own graph is itself a documented subset of the underlying co-occurrence graph — 59 nodes and 194 edges is what survived the service's top-60-by-degree cap and weight-≥-2 prune. That cap is the service's, not this page's. The complete, untrimmed JSON for all fifteen runs is in the repository.
Knowing when not to answer
A charting service that always charts is a charting service that will eventually chart something misleading. Four of the fifteen runs exist to demonstrate what happens when the obvious chart is the wrong answer. The pair I find most convincing is 08 against 09, because they are the same population twice.
Rung 08 refuses. “How are cancer trials distributed across phases overall?” matches 121,770 trials. Phase lives on the study record, so charting it means paging the whole match set, and the paging budget is 20 pages of 1,000 — 20,000 trials, the same number as the too-large threshold. The system could have paged the first 20,000 and drawn a chart. It refuses instead, and returns the exact total, because a sorted prefix of a registry is not a sample of it: it is a biased slice with a chart's authority. The envelope comes back status: "too_large", kind: "answer", visualization: null — never a half-populated chart.

Rung 09 charts the identical population, exactly. “How are cancer trials distributed across overall recruitment status?” is the same 121,770 trials — but status is a bounded token set, so the distribution can be computed with one countTotal query per token and no paging at all. Fourteen tokens are queried, thirteen bars render (WITHHELD has zero trials, and zero-count buckets are dropped rather than drawn), and the bars sum to 121,770 — the same number rung 08 refused, now computed exactly rather than sampled. Which distributions can be computed faithfully is a property of the field, and the system knows the difference.
Two more round it out, and the first is a partial refusal rather than a silence. Asked for a drug co-occurrence network over progeria trials, the engine finds no drug pair recurring across trials — a graph with no repeated co-occurrence is a hairball that implies structure it does not have — so it declines the graph and falls back to a cited bar chart of 9 trials, disclosing the fallback in its notes — which name two possible triggers, a too-sparse entity set or no repeated co-occurrence, without saying which fired. And asked “How many trials are there for this drug?” with no drug field, it neither guesses nor throws a validation error (the HTTP request is perfectly valid); it returns kind: "clarification" carrying a code-templated question: “Which drug do you mean? Please name the drug (e.g. in the drug_name field).” Nothing is fabricated to fill the gap.
Two ways to check it from outside
“The model never emits a number” is the kind of claim that is easy to make and easy to believe about your own system. Two artifacts ship specifically so a stranger can test it without taking my word for anything.
The first is a twin. The phase-distribution question was planned twice — once through the OpenAI adapter, once through the Anthropic one — and both envelopes ship side by side. OpenRouter is the third provider behind the same adapter; switching is a config string. Eight of the nine top-level values are byte-identical, including all three that matter: thevisualization block with all eight buckets and every citation, the vega_lite projection, and the top-level citation index. A sweep of every numeric leaf finds 35 on each side and 0 that differ.
Being exact about what did differ, because that is the interesting part: only meta, and only in three keys — the retrieval timestamp; one extra echoed filter key on the OpenAI side; and one Intent Reviewer flag that one run carried and the other did not. Two model families disagreed about how to annotate the result and agreed on every digit in it. And meta.query_provenance is identical across both, which means the extra filter key was a cosmetic echo: the actual parameters that went on the wire were the same. The number is the tool's.
The second is a command. scripts/verify_examples.py re-checks every shipped run against five invariants — schema validity, element-precise provenance, count coherence, reconciliation, and the no-laundered-numbers check — reusing the runtime's own verifier functions, so the shipped bytes are held to the same bar a live request is. It needs no API key, no network and no LLM provider, and it costs nothing. Here is its output for the four-stacked-filters run, and its last line:
$ uv run python scripts/verify_examples.py ... [PASS] I SCHEMA status=ok kind=visualization [PASS] II PROVENANCE 103 citations element-precise [PASS] III COUNT-COHERENCE 8 row data coherent [PASS] IV RECONCILIATION combine Σ == T == 229 [PASS] V NO-LLM-NUMBER notes cannot launder numbers (sentinel 9 rejected); … ... 16/16 examples passed
Sixteen is the fifteen runs plus the cross-provider twin. The harness is wired into the test suite, which loads it by path, asserts it finds at least 16 example files, parametrises over all of them and asserts an exit code of 0. And it has teeth, which is the part that would otherwise be an assumption: the suite carries negative tests that deliberately corrupt an example and require the harness to catch it — test_fabricated_excerpt_is_caught, test_inflated_bar_breaks_reconciliation, test_broken_schema_is_caught. A green verifier that cannot fail proves nothing; these prove it can.
On the suite, since a test count is worth stating honestly: 602 collected, and the skip count moves with the live registry. Re-run on 2026-12-04 with network access and no API key it read 596 passed / 6 skipped, zero failures; with the network blocked it read 577 passed / 25 skipped, zero failures. The three constant skips are golden-fixture parametrisations that legitimately do not apply; the others are live-registry tests that skip on a transport error or a rate limit, and in earlier runs (598 passed / 4 skipped, then 599 passed / 3 skipped) those live gates did fire and did hold.
The citation viewer also carries an ask bar. It is not a third way to check the claim from outside, because it needs the service. Opened from a running instance, a question goes to POST /visualize/stream, the eight-stage status enum lights up live, and the answer renders through the same chart and citation code as the saved runs. The public GitHub Pages copy has no backend. Its health probe finds nothing, the ask bar stays disabled and says live mode is off, and what it shows is the fifteen recorded runs.
An injection surface inside a field value
A user-supplied entity — a drug name, a condition, a sponsor — becomes the value of a query.<area> parameter. That value is not opaque. The registry parses those parameters with the Essie query language after URL-decoding, so a crafted value can smuggle operators and selectors, not just search terms. Probing it live turned up three shapes of problem, and I want to be careful about which parts of this I can prove.
- A boolean in a value. A condition value containing an
ORwas evaluated as a boolean operator, producing a union larger than either term alone — a scoped query silently widened into a bigger one. - Cross-field selection. A value of the form
AREA[Phase]…ignored the condition field it was sitting in entirely and selected on Phase instead. The parameter the caller set is not the dimension the query ran on. - Amplification. The union shape is also a cheap way to push a small query over the paging budget and into the refusal path — a denial-of-service amplification vector against exactly the guardrail described two sections up.
What I am not going to quote is the magnitudes. The three live totals recorded when I probed this in July 2026 exist only in prose — no test pins any of them, and I have not re-probed the live registry since. The one live test on this path deliberately asserts a relation rather than a number (the neutralised value must return fewer trials than the raw one) on a different pair, and it skips rather than fails on a transport error. The mechanism above is verifiable in the code and I will state it flatly; the numbers attached to it are unpinned observations and get no more authority than that. On a page arguing that a number must be traceable, quoting three numbers I cannot trace would be the wrong place to make an exception.
The fix is recall-preserving rather than blunt. Quoting every value would neutralise the attack and cost search recall, including the registry's own synonym expansion; rejecting anything containing punctuation would be user-hostile and would break legitimate drug names. So neutralize_query_value passes a clean value through unchanged and quotes only a value carrying an Essie metacharacter ([ ] ( ) ") or a standalone uppercase operator keyword, wrapping it as an inert string literal. Two things are load-bearing here, and they are different things: the operator keywords match only at word boundaries, which is what stops ANDROGEN and Organon from tripping the AND and OR rules; and the match is case-sensitive, so a lowercase “or” sitting inside a drug name stays an ordinary search term rather than becoming an operator. And which alternative to ship was chosen against live recall measurements rather than by picking the strictest — recorded in the same July probe session as the magnitudes above, and carrying the same standing: prose, not a test.
Rung 14 of the ladder is that fix end-to-end, and it is the part with an artifact. A boolean union was passed in as a condition value; the recorded provenance shows what actually reached the wire:
meta.query_provenance.params
query.cond = "cancer OR diabetes" <- quoted: one inert Essie string literal,
not an operator between two terms
result: status "empty" · 0 trials The value arrived as a literal and matched nothing, which is the correct outcome: no trial has that string as its condition. The repository states the raw union's size two different ways in two different files and neither is pinned by a test, so I am not quoting a figure for it either — what is verified is the quoting on the wire and the zero.
It sits on top of the standing controls rather than replacing them: a base-URL-pinned, GET-only client whose host is parsed and compared structurally rather than with a prefix match (the userinfo trick, https://clinicaltrials.gov@evil.com, and the suffix trick, …gov.evil.com, are called out by name in the comments); a two-destination egress partition, tools reaching only the registry and the adapter only its provider; a provider key read solely in the adapter and redacted from logs; structured logging through a closed 22-field allowlist, so the raw query has no key to be logged under; and an ^NCT[0-9]{8}$ guard on the one identifier that ever reaches a URL path.
The bug it disclosed on itself
Six days after shipping, an audit of the artifact against its own description found a real defect. The shape of that audit matters, because every number, inventory and file:line citation a codebase makes about itself is a claim with a truth value, and none of them are covered by tests. So it ran as a read-only fan-out: 38 agents over roughly 1,522 checkable anchors across the repo and five design docs, each anchor re-derived from the code rather than read back. It returned 119 documentation-versus-code mismatches, 26 dispositions where the audit itself was wrong, and exactly one real bug.
Those 26 are the reason every finding is dispositioned before it is fixed. An unaudited audit rewrites correct text into wrong text, confidently, at scale — a fan-out that trusts its own agents is a defect generator with good grammar. The one real bug is the instructive part. The provenance block stamps the field projection that was requested from the API — audit metadata, the “what did you actually ask for” line — and it was being written by a duplicate projection switch, hand-written alongside the real one and drifted from it. The flagship symptom: the status-distribution run is a distribution over recruitment status, and it stamped fields = NCTId|Phase.
The honest version is worse than the one-line summary, so here it is. Re-running the fixed projection function against every recorded run shows the stamps are wrong in three distinct ways, not one: on several runs the projection is simply missing BriefTitle; on the compare run it is also miscased (overallStatus where the authority says OverallStatus); on the sponsor-type run the token itself is wrong (sponsorClass where the authority says LeadSponsorClass). The repository's run-by-run document names the affected rungs individually rather than gesturing at them.
The caveat that travels with it, and it is a real caveat rather than a softener: no computed value was affected. The field is pure audit metadata. Every count, every citation and every reconciliation still verifies — the offline harness passes 16/16 on the unmodified bytes, and it does not read the provenance block at all, which is precisely why the defect survived a green suite for six days. That is the interesting part: the number was safe because the number was never the model's, but the record of how the number was obtained had no such guarantee, and nothing was checking it.
What was done about it is the part I would defend in a review. The duplicate switch was deleted and the projection now reads the single authority. A regression file was added with 7 test functions expanding to 15 collected tests, and — this is the bit that matters — those tests assert that the projection equals the authority itself (the field spec's own projection, the date projection, the duration fields) rather than equalling a plausible-looking string literal, because a literal would have to be updated by hand the next time the authority changes and would then be pinning the wrong thing. One is named test_status_distribution_is_not_the_old_hardcoded_phase, pinning the historical defect by name, and the documentation records that the guard was verified to fail against the reintroduced bug before it was kept — a test that has never been seen to fail is a test of nothing.
And then the recorded runs were deliberately not regenerated. They still carry the wrong stamp. They ship with a disclosure at the top of the runs document saying so, in bold, naming the field. Re-running the ladder would have taken one command and made everything look correct. But those files are a recording of what the system did on 2026-07-16, and editing a recording so that it looks right in hindsight is the exact failure mode this whole project exists to prevent. A system whose entire argument is “the number was not retrofitted” does not get to retrofit its own evidence.
There is a second, smaller instance of the same discipline sitting inside the four-stacked-filters run. Its four filters are correctly applied — the effective filters and the advanced wire parameter both prove it, and 229 reconciles exactly — but its title is byte-identical to the unfiltered run's: “Phase distribution of interventional pancreatic cancer trials”, with no mention of recruiting, industry-sponsored, or since 2020. The Intent Reviewer caught precisely that. Its flag shipped, verbatim, inside the run's own notes rather than being polished away:
meta.notes[0] "The chart answers phase distribution, but it does not reflect the user's restriction to recruiting, industry-sponsored interventional pancreatic cancer trials started in 2020 or later, and the title omits those filters."
That is a shipped artifact criticising itself, in the output, where a consumer will see it. The same is true of a smaller admission in the packaging: the project file explicitly declares that two of its declared dev dependencies are imported nowhere. None of these are impressive on their own. Collectively they are the only evidence that the honesty is structural rather than performed.
How it was built
The build ran as a multi-agent workflow I designed and drove, and every phase had the same shape. I froze an interface contract. I fanned role-scoped sub-agents out over disjoint files. I integrated the trunk serially, with a live run after each wire. Then I closed the phase with a read-only adversarial pass whose findings counted only if they came with a reproduction. That came to roughly 75–80 documented role invocations across 3 specification passes and 7 gated build phases, against a contract versioned v0 to v4. The rule underneath: parallelize the leaves, serialize the trunk. A pure function over records is the right unit to hand an agent. The integration seam is too coupled, so it stayed serial and mine.
The order mattered more than the fan-out. The model did not arrive until Phase 4, of seven phases numbered 0 to 6. Phase 1 ran a hardcoded plan against the live API under a written stop condition: no breadth work until Σ == distinct == countTotal held. It held at 3,950, drift 0, and every later phase inherited a spine that was already true.
The worst defect of the build was mine. An adversarial pass over the scaffold flagged an SSRF hole as critical: the client's base-URL pin accepted the userinfo trick. It traced to a loose line in my own wave brief — “assert the base_url is https://clinicaltrials.gov…” — which the agent implemented faithfully as a bypassable startswith. The asking was under-specified. A security requirement in a brief must state the exact check, not the goal. It also set the operating rule for the rest of the run: a sub-agent's green report is a hypothesis, so every finding was re-verified by re-running its reproduction before a fix was dispatched.
Authorship, stated precisely. The sub-agents wrote scoped implementation under contracts I specified. Every finding and every fix was re-verified by me before it landed. The architecture, the invariant, the phase gates and the orchestration design are mine.
Limitations
- The invariant protects the number, not the question. The model cannot emit a wrong count, but it can classify an ambiguous question into the wrong query class. The Checker rejects illegal plans and the Intent Reviewer flags mis-intented ones, but a subtly mis-scoped plan that is legal and looks intended will produce a correct count of the wrong population. The engine has a regression suite; the planner has no golden set of question-to-plan pairs, and that is the first thing I would add.
- Reconciliation certifies the population that was paged, not the one that was asked for. The gate proves the bars sum to the trials the engine fetched. A filter that never reaches the wire runs on a broader population and still reconciles. That happened during the build: the query layer dropped the phase and sponsor-class filters, so “interventional Phase 1&2 pancreatic trials run by industry” was answered over 3,950 trials instead of 928. A one-query-per-class gate was all green. A 15-query composite, ambiguous and adversarial battery surfaced it in one run. The drop was fixed before shipping and a regression test pins it; the limit of the gate itself is permanent, and rung 13 exists partly to show the filters bite.
- The network figure is a rendered subset. 59 nodes and 194 edges is what survives a top-60-by-degree cap and a weight-≥-2 prune. It is not “the melanoma drug graph” and should never be quoted as one.
- Entity display names are heuristic. The registry resolves synonyms for search recall; normalising them for display is a separate problem and
resolve_entityis a documented stub. It shows: in the melanoma graph the pembrolizumab node's canonical id is a biosimilar identifier and trametinib's is a development code, and on the labels themselves 5-FU and Fluorouracil survive as two separate nodes while four drugs render under their development codes. The alias-only merge picked the key with the most corroboration — the safe direction — but the labels stay rough until a real vocabulary pass lands. - The security magnitudes are unpinned. As stated above, the live totals I recorded when probing the injection surface are prose observations with no test behind them and no re-probe since. The mechanism and the fix are in the code and are testable; those three numbers are not, which is why they are not on this page.
- The escalation bound is verified in code, not observed in an artifact. All three routers share the one counter and the ≤ 1 condition, and that is checkable by reading them — but no shipped run happens to record an escalation, so the bound has no example demonstrating it end-to-end.
- The second citation pass is a spot-check above 500 records. Every citation is verified against its own stored value at build time; the independent re-check against the fetched record is bounded to a 500-record index, so on the widest run about 12% of citations are outside it. Skipped, not failed — and disclosed.
- The safety envelope is not perfectly uniform, and says so. Two of the declared character limits are inert because Pydantic literals on the request model bind first; the citation sample constant reaches the main aggregation paths but three builders keep their own literal; the count-path's per-bucket sample of 10 was never lifted into config; and the request timeout covers the registry client only, not the LLM adapters. All four are marked in the configuration file rather than glossed.
- The 24-hour box and the ~21 hours are my own account, not a repository fact. The repository was initialized at the end, so its log shows the publication pass, not the build. It can attest to when it shipped and not to how long it took. Treat the figure as I would any other unpinned number on this page: it is mine, and you cannot check it from the artifact. What the repo does corroborate is circumstantial — dependency bounds read off PyPI the previous day, and the entire fifteen-run ladder executed inside a 26-minute window. My own elapsed-time evidence is the file-mtime chain across one continuous overnight session, in a working tree that is not public. Hardening and documentation continued over the following fortnight.
- Out of scope, and named as such. A scatter mark is deferred pending an honest continuous field pair; conversational memory is a checkpointer away but not wired; an MCP surface is designed for and not built; the single-record drill-down is guarded and tested but has no caller. Sponsor↔drug and drug↔drug are the only two graph kinds; every node in the shipped melanoma graph is a drug.
Conclusion
The whole system is one idea applied consistently: decide where a number is allowed to come from, then make every other origin impossible rather than discouraged. The planner cannot return a count because its type has no count. A distribution cannot ship unreconciled because the reviewer compares it against the registry's own total — and where there is no single oracle, a two-population compare or a derived graph, the reviewer records that instead of pretending to one. A citation cannot be plausible-but-invented because the value that decided membership is re-verified against the fetched record. And when the sample is bounded — as it must be at 121,770 trials — the datum says so itself instead of implying completeness.
Three corollaries are worth keeping. A system that can refuse is more useful than one that always answers — the pair of runs where the same 121,770 trials are refused by one field and charted exactly by another is the cleanest version of that I managed. A verification harness means nothing until it has been shown to fail. And a recording of what a system did is worth more than a recording of what it should have done, which is why the runs on this page still carry a metadata field I found and fixed on 2026-07-22. It was built as a time-boxed take-home and submitted; everything above is in the repository, and the fastest way to disagree with any of it is the one command that needs no key and costs nothing.