Repository navigation
feat: serve latest_version_at in the catalog - #1571
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1571Version: 🤖 Updated on each push. |
Review recordThis was a single-pass self-review of the diff through the pr-review-toolkit lenses (code, tests, errors, comments, types, simplification). It was not run with separate reviewer agents.
Known limit: a version row that an operator repaired or restored later carries that later date. The normal publish path is unaffected. |
Review findings and handling (Sonnet-model review of 3c19879)No blocking issues. All four catalog projections emit the pair with the same ordering, the plan for both subqueries uses
Tests after the changes: 4360 pass, 0 fail ( |
What
Adds
latest_version_atto the catalog: thecreated_atof the newestdataset_versionsrow, as SQLite UTC (YYYY-MM-DD HH:MM:SS, the same form ascreated_at). It isnullwhen the dataset has no version row.It is served by the four catalog projections that already serve
latest_version: the public list,?mine=true, the degraded fallback list, andGET /datasets/:id.Why
The website "Updated" badge reads
datasets.updated_at. That column is bumped by any row write: enrichment reindex (admin/doi.ts), finalize (upload.ts), and the DOI callbacks. The 0.10.10 re-enrichment sweep therefore made every swept dataset look freshly updated. Live example: nm000279 was released 2026-09-16 and re-enriched 2026-09-29, and shows 2026-09-29.latest_version_atmoves only when a new version is released, so it is the honest date for that badge. The website consumes it in nemarOrg/website#384.Changes
shared/contract/dataset.ts:latest_version_at: z.string().nullable().optional(), with the regeneratedshared/openapi.json(the drift guard compares it byte for byte).src/lib/api/datasets.ts: the CLI-sideDatasettype gains the optional field.backend/src/routes/datasets/catalog.ts: oneLATEST_VERSION_AT_SQLfragment, used in all four projections. It orders bycreated_at DESC LIMIT 1, exactly as thelatest_versionsubqueries do. Rows that tie oncreated_atshare the date either way, so the two values cannot disagree (which row a tie names is unchanged by this PR).Not changed
updated_atsemantics and every writer that bumps it.describe_datasetrow and output schema. It has its own contract (shared/contract/mcp.ts), and no consumer needs the date there yet.data.tsanddata-router.ts. The data-plane index already carries the same quantity aslatest_published_at(wire keypublished), so there are now two spellings; aligning them is a separate cleanup.CHANGELOG.md, which is written in per-release PRs. The 0.10.11 entry should mention this API addition.Compatibility and deploy order
Additive and optional: older consumers ignore it. The website deliberately does not fall back to
updated_at(that is the bug), so until this ships to an environment, the website omits "Updated" there. Deploy this todevbefore QA of website#384 on staging, and to production beforestagingis promoted tomainon the website.The value is a zone-less UTC string;
new Date("2026-09-16 17:22:05")parses as local time in JavaScript, so consumers must normalize to UTC (the website helper does).Testing
backend/test/catalog-latest-version-at.test.tsdrives the real routes against a real bun:sqlite D1 (no mocks):latest_version;null(key present);updated_atdoes not move it;?mine=truebranch serve it;Without the
catalog.tschange, 9 of these 10 fail; removing the fragment from the fallback query alone fails exactly the fallback test.test/contract-schemas.test.ts: optional, nullable, string-only.bun run typecheck, biome on the changed files, andbun test backend/test(4360 pass, 0 fail, run twice on the final code). An earlier full run by the author showed 11 failures that did not reproduce in any later run; the tests were not identified, and the log points at network-touching tests such as ORCID and bucket policy.Review
A Sonnet-model review found no blocking issues. Findings and handling are in the comment below.