Skip to content

fix(api): concept_versions enumerates the complete record set#22

Merged
jcschaff merged 1 commit into
mainfrom
fix/concept-versions-completeness
Jul 3, 2026
Merged

fix(api): concept_versions enumerates the complete record set#22
jcschaff merged 1 commit into
mainfrom
fix/concept-versions-completeness

Conversation

@jcschaff

@jcschaff jcschaff commented Jul 3, 2026

Copy link
Copy Markdown
Member

Problem

Zenodo's deposit search returns unstable, overlapping pages — a single paginated pass can return the same record twice and miss others. concept_versions did one pass and appended, so every caller that dedups or takes the latest version (archive/backfill dedup, apply-metadata, latest_version) could silently act on a partial slice.

This bit us for real: a whole-concept apply-metadata --license-only on vcell reported "490 updated, 0 failed" but left ~51 records untouched, and re-runs kept surfacing different subsets (51 → 15 → 7) because each enumeration was a different incomplete sample. The stragglers were only found by unioning reads until the count hit the known total (492).

Fix

concept_versions now unions records by id across repeated full passes until the set is complete:

  • target count from the public records API (which does report a total), so we know when we've seen every record — no unknown-unknowns;
  • converged pass (one that adds nothing new) as the fallback when the total is unavailable;
  • bounded by a pass cap so an ever-shifting search can't loop forever.

Dedup is by record id, so duplicates from overlapping pages collapse.

Verification

Live against the 492-record vcell concept: one call now returns 492 unique records, 0 duplicates (previously duplicated and missed records). This means apply-metadata and archive dedup now cover the full concept in a single pass.

ruff + mypy --strict clean; 43 unit tests pass (added overlapping-page union, target-stop, draft exclusion, and sort-order cases with stubbed pagination).

Follow-up from the vcell license normalization, where this incompleteness was diagnosed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BZx7w9BexQc9wWU5JoHYaF

Zenodo's deposit search returns unstable, overlapping pages: a single paginated
pass can hand back the same record twice AND miss others. Callers that dedup or
take the latest version (archive/backfill dedup, apply-metadata, latest_version)
were therefore acting on a partial slice — silently. In practice this made a
whole-concept `apply-metadata --license-only` cover only ~490 of 492 vcell
records per run, needing several rounds to converge.

Now concept_versions unions records by id across repeated full passes until the
set is complete: the target count comes from the public records API (which does
report a total), with a converged (nothing-new) pass as the fallback when that
total is unavailable, bounded by a pass cap. Verified live against the 492-record
vcell concept: one call now returns 492 unique records, 0 duplicates (was
duplicating/missing before).

- api: union-until-complete concept_versions (dedup by id)
- tests: overlapping-page union, target stop, draft exclusion, sort order

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BZx7w9BexQc9wWU5JoHYaF
@jcschaff jcschaff merged commit af3a9df into main Jul 3, 2026
1 check passed
@jcschaff jcschaff deleted the fix/concept-versions-completeness branch July 3, 2026 14:38
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