Fix stable totals for age-filtered clinical trial search#195
Merged
Conversation
Age-filtered trial searches reported inconsistent totals because the count was derived from a prefix of the result set rather than the full verified population. The reported total changed with --limit. - Add `count_all` which pages through all CTGov results with a 1000-row page size and applies age verification across the complete set, then returns the definitive verified count - Route `--count-only` through `count_all` instead of `search_page`, so count-only calls always return the true verified total - Paginated (`search_page`) age-filtered calls now return `total=None` when traversal does not exhaust all pages, surfacing "total unknown" in the CLI footer instead of a misleading lower bound - Expose `ClinicalTrialsClient::new_for_test` under `#[cfg(test)]` - Add age-filter count stability spec section to `spec/04-trial.md`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--count-onlyoutput changed with--limitcount_allwhich traverses all CTGov pages (1000 results/page) and applies age verification across the complete population, returning the definitive verified count--count-onlythroughcount_allso count-only calls always return the true verified total (e.g.Total: 472for melanoma/recruiting/age-51, stable across any--limit)search_pagecalls now returntotal=Nonewhen traversal does not exhaust all pages, surfacing "total unknown" in the CLI footer instead of a misleading lower boundClinicalTrialsClient::new_for_testunder#[cfg(test)]for unit testingspec/04-trial.mdTest plan
cargo testpasses (574 tests)make specpasses (96 passed, 5 skipped)biomcp search trial -c melanoma -s recruiting --age 51 --count-onlyreturnsTotal: 472--limit 10,--limit 20,--limit 50all returnTotal: 472biomcp search trial -c melanoma -s recruiting --age 51 --limit 10showstotal unknownfooterbiomcp search trial -c melanoma -s recruiting --age 51 --limit 10 --offset 20shows paginated rows withtotal unknown