CTGov Viz Agent mark: three pale bars standing on a baseline inside a dark navy circle, with a thin coral line running from the tallest bar up to a small coral dot.

CTGov Viz Agent

LLM · decides what to computecode · computes itboth · code proves it, LLM judges itSTARTclarificationrare short-circuitCODEmerge_inputsfield-precedence · NL + struct fieldsLLMplan1 structured call · tools = NoneCODEcheckplan checker · every token real?LLMreview_intentintent reviewer · did it understand?CODEexecutepage · count · dedupe · bucketcite · 2 SSE stagesCODEbuild_speccanonical viz spec · + Vega-LiteCODE+LLMreview_outputquote ≡ source · Σ ≡ countTotal+ LLM faithful?CODErespondstream the answer · SSE · done≤ 1errorany node can raisebounded escalation re-plan · budget ≤ 1one budget shared by checker reject · intent revise · zero resultsnever planner-initiated · every cycle returns to planSSE STATUS STREAM · EMISSION ORDERplanningvalidatingplan_approvedfetchingaggregatingbuilding_specverifyingdoneexecute emits two — fetching, then aggregatingimport-time check: the statuses nodes can emitmust equal this enum, or the app refuses to startplanno count · no total · no valueThe planner's typed output has no count, total or valuefield. Its only two integer fields — filters.start_yearand filters.end_year — select a population, never data.A fabricated number has nowhere to live.

The model decides what to compute. Code computes it. A number the model never held is a number the model cannot get wrong.

Author

  • Soren Nguia1

Affiliation

  1. Independent Researcher (Seoul)

Built

Jul 2026 · a 24-hour take-home, built in 21

Repository

GitHub

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.

The richest thing the core produces
Screenshot of the run viewer showing a force-directed graph: teal circles joined by pale grey edges, each circle labelled with a drug name — Pembrolizumab, Nivolumab, Ipilimumab, Paclitaxel, Carboplatin, Trametinib, Dabrafenib, Fludarabine, Cyclophosphamide, Temozolomide and around fifty more. Node size varies with the number of connections; the largest sit in a dense centre while sparsely connected nodes trail off toward the edges. A legend at the bottom left reads: drug · node size proportional to degree · edge width proportional to co-occurring trials. The deep-citations panel on the right is in its empty state, reading: trace any value to its trials.
Figure 1: “Show a network of drugs studied together in melanoma trials” — a drug↔drug co-occurrence graph over a population of 3,733 trials. What is drawn is 59 nodes and 194 edges after a top-60-by-degree node cap and a prune of every edge below weight 2; that is the service's documented interpretability subset, not the full co-occurrence graph, and the run's own notes say so. Every one of the 194 edges carries exactly two citations, one per endpoint. The heaviest, cyclophosphamide↔fludarabine at weight 84, cites a single trial twice — the same NCT id with matched_value “Cyclophosphamide” on one endpoint and “Fludarabine” on the other.

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:

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.

Eight bars that sum to the registry’s own total
Screenshot of the run viewer: a horizontal bar chart under the heading VISUALIZATION, with eight teal bars labelled NA (not applicable) 937 trials, Early Phase 1 109 trials, Phase 1 895 trials, Phase 1/2 505 trials, Phase 2 1,143 trials, Phase 2/3 58 trials, Phase 3 232 trials and Phase 4 71 trials. A line above the chart reads: click a bar, point, node or edge to open its citations. On the right, an empty deep-citations panel reads: trace any value to its trials — every count is backed by the exact NCTIds that produced it.
Figure 2: “How are interventional pancreatic cancer trials distributed across phases?” Eight buckets, and their distinct-trial counts sum to 3,950 — exactly the countTotal the registry returned for the same filtered population. Note the NA bucket: 937 trials, 23.7% of the total, given its own labelled bar rather than being silently dropped to make the distribution look cleaner.

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.

One bar, opened
The same eight-bar phase chart, now with the Phase 1/2 row highlighted, and the deep-citations panel on the right opened. The panel is headed Phase 1/2, then 505 trials, then a green pill reading 505 contributing trials next to an amber note reading showing 6 of 505 (truncated). Below are three citations. First: the title “Combination Chemotherapy Followed by Chemotherapy and Radiation Therapy and/or Surgery in Treating Patients Who Have Pancreatic Cancer”, the identifier NCT00003332 as a link, the quoted value PHASE1, the field path protocolSection.designModule.phases, and two chips reading PHASE1 and PHASE2. Second: “Radiolabeled Monoclonal Antibody Therapy Plus Peripheral Stem Cell Transplantation in Treating Patients With Metastatic or Recurrent Colorectal Cancer or Pancreatic Cancer”, NCT00004087, the same quoted value, path and chips. Third: “Endoscopic Placement of Metal Stents in Treating Patients With Cancer- Related Duodenal Obstruction”, NCT00004910, the same quoted value, path and chips.
Figure 3: clicking the Phase 1/2 bar. The panel states the true bucket size (505 contributing trials) and, in amber, that what it lists is a truncated sample of it — the disclosure is part of the datum, not a caveat elsewhere. Each entry gives the readable title, the NCT id linking out to clinicaltrials.gov, the exact matched value that decided membership, the field path it came from, and the composite tokens the bucket was built from.

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:

Click a datum, get its citations
Question asked, verbatim

“How are interventional pancreatic cancer trials distributed across phases?”

/api/v2/studies · retrieved 2026-07-16T00:01:36.288422+00:00 · clinicaltrials.gov

Phase distribution of interventional pancreatic cancer trialsbar

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.

PhaseTrials (trials)
Reconciliation

Σ 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.

Citations behind this bucket

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

  1. Combination Chemotherapy in Patients With Zollinger-Ellison Syndrome and Tumors of the Pancreas

    counted because protocolSection.designModule.phases = PHASE2

  2. The Use of Oral Omeprazole and Intravenous Pantoprazole in Patients With Hypersecretion of Gastric Acid

    counted because protocolSection.designModule.phases = PHASE2

  3. Interferon and Octreotide to Treat Zollinger-Ellison Syndrome and Advanced Non-B Islet Cell Cancer

    counted because protocolSection.designModule.phases = PHASE2

  4. 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

  5. Cyclophosphamide Plus Vaccine Therapy in Treating Patients With Advanced Cancer

    counted because protocolSection.designModule.phases = PHASE2

The run’s own caveats, verbatim
  • 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.

Figure 4: three real runs, with their real citations. Every count shown — bar height, node degree, edge weight, reconciliation total — is the number the run itself produced, read out of its JSON and not recomputed here. The citation lists are sampled; the panel says how many of how many at each datum.
What was trimmed to fit this page

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.

A refusal, rendered as prose and one number
Screenshot of the viewer for a refused query. At the top, an INPUT QUERY card shows the question “How are cancer trials distributed across phases overall?” with a chip below it reading condition = cancer. Under that, a card headed “Result too large to chart” carries two status pills, a red-outlined too_large and a green-outlined answer, above a meta row: reconciliation total 121,770 trials; source clinicaltrials.gov; retrieved at 2026-07-16 00:02:27 UTC; filters none; and effective wire params listing the endpoint /api/v2/studies with query.cond=cancer, countTotal=true, pageSize=1000 and fields=NCTId|Phase. A grey box headed “honest disclosures and interpretation notes” contains one bullet: 'overall' interpreted as no additional phase, status or date restriction. Two collapsed links offer the raw request JSON and the raw response JSON. At the bottom, in the visualization slot, a pink-bordered card headed with a warning triangle and the words OVER-BUDGET REFUSAL reads: 121,770 trials match this query — too large to chart faithfully within the paging budget. Narrow the query, for example by adding a phase, status or year range, to render a distribution. Beneath that sentence the figure 121,770 is printed very large, labelled matching trials. The citation panel to the right is in its empty state.
Figure 5: the refusal path. The result is still a fully-formed envelope with its provenance, its effective wire parameters and its interpretation notes — the meta row is not suppressed just because there is no chart. The only thing missing is the thing that could not be computed faithfully.

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.

16/16
examples pass, offline, no key, $0
0 / 35
numeric leaves differing, GPT vs Claude
602
tests collected · 596 passed, 6 skipped, 0 failed (re-run 2026-12-04)
3,950
Σ of 8 bars == the registry’s countTotal

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.

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

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.