Skip to content

Fix federated article search offset/sort semantics and add correctness spec#201

Merged
imaurer merged 1 commit intomainfrom
add-federated-article-correctness-tests
Mar 12, 2026
Merged

Fix federated article search offset/sort semantics and add correctness spec#201
imaurer merged 1 commit intomainfrom
add-federated-article-correctness-tests

Conversation

@imaurer
Copy link
Collaborator

@imaurer imaurer commented Mar 12, 2026

Summary

  • Apply offset after merging and deduplicating both federated legs (PubTator3 + Europe PMC), not per-leg, so paginated windows are stable and correct
  • Sort merged results by the caller's requested sort order (relevance, citations, date) before applying offset and truncation
  • Propagate the same sort+offset logic through surviving-leg fallback paths so single-source results are consistent with the two-source path
  • Guard against deep offsets that exceed the fetch capacity bound: offset + limit > 1250 returns an explicit InvalidArgument error rather than silently returning an incorrect window
  • Normalize partial dates (YYYY, YYYY-MM) to full ISO-8601 strings (YYYY-01-01, YYYY-MM-01) so date comparisons are lexicographically correct across mixed-precision values
  • Extend spec/06-article.md with a deep-offset rejection contract test

Test plan

  • cargo test --lib entities::article — 31 article unit tests pass, including new tests for offset-after-merge, sort ordering, partial date normalization, retraction filtering, and surviving-leg sort-before-offset
  • cargo test — 584 tests pass, 0 failed
  • cargo clippy -- -D warnings — clean
  • cargo fmt --check — clean
  • make spec — 98 passed, 5 skipped (spec/06-article.md deep-offset guard test included)
  • Manual smoke: biomcp search article -k melanoma --limit 50 --offset 1201 fails with expected error; --offset 1200 succeeds

…ort semantics

- Apply offset after merging and deduplicating federated legs, not per-leg
- Sort merged results by the requested sort order before applying offset and limit
- Propagate sort+offset through surviving-leg fallback paths
- Guard against deep offsets that exceed the fetch capacity bound (offset+limit > 1250)
- Normalize partial dates (YYYY, YYYY-MM) to full ISO-8601 for correct comparisons
- Extend spec/06-article.md with a deep-offset rejection contract test
@imaurer imaurer merged commit 45e5eb3 into main Mar 12, 2026
3 checks passed
@imaurer imaurer deleted the add-federated-article-correctness-tests branch March 13, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant