Skip to content

Phase 5: DOI version-mint reconciliation (#900) - #940

Merged
neuromechanist merged 2 commits into
feature/issue-896-epic-arch-hardeningfrom
feature/issue-900-phase5-doi
Jul 6, 2026
Merged

neuromechanist merged 2 commits into
feature/issue-896-epic-arch-hardeningfrom
feature/issue-900-phase5-doi

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Fixes orphaned reserved version DOIs (permanent, non-resolving) and adds a backstop sweep.

  • Core fix (doi.ts createEzidVersionDoi): if createIdentifier (status reserved) succeeded but a prior attempt crashed before makePublic, the retry hit the "already exists" branch and returned the still-reserved identifier early — a permanent DOI that doesn't resolve, recorded as the dataset's latest version. Now it fetches the identifier and inspects status: return early only when already public; when still reserved, fall through to makePublic to finish the transition (returns public).
  • Backstop sweep (reconcileReservedVersionDois, daily cron, mirrors archiveRetrySweep): checks the most-recently-updated datasets carrying an EZID version DOI (a fresh mint-crash bumps updated_at), asks EZID each DOI's status, and completes any still stuck reserved. Per-DOI prod/sandbox shoulder routing.

Scope note

No new D1 column: a latest_version_doi_status column would collide on migration number 0057 with the paused #923 epic. The recency-biased sweep is sufficient (a stuck DOI is a fresh crash) and self-correcting; a status-column optimization can land later without the clash.

Test plan

  • backend/test/doi-reconcile.test.ts — version/shoulder parsing (versionFromVersionDoi, isSandboxDoi, isEzidNemarDoi).
  • Full backend unit suite (414) green; tsc + Biome clean. The core fix's makePublic-on-reserved path is exercised by the sandbox-EZID integration tests.

Closes #900. Part of epic #896.

Epic #896 Phase 5 (#900). In createEzidVersionDoi, if createIdentifier
(reserved) succeeded but a prior attempt crashed before makePublic, the
retry hit the 'already exists' branch and returned the still-reserved
identifier early -- a permanent, non-resolving DOI recorded as the
dataset's latest version.
- Core fix: on 'already exists', fetch the identifier and inspect status.
  Only return early when it's already public; when still reserved, fall
  through to makePublic to finish the transition.
- Backstop: reconcileReservedVersionDois daily cron sweep (mirrors
  archiveRetrySweep) checks the most-recently-updated datasets carrying an
  EZID version DOI, and completes any still stuck reserved. No new D1 column
  (avoids a migration-number clash with the paused #923 epic's 0057).
- Pure helper tests (version/shoulder parsing). Full backend unit green.
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR940

Version: 0.8.76-PR940.ff43f8a
Commit: ff43f8a


🤖 Updated on each push.

- Reconcile sweep now day-rotates over ALL version-DOI datasets
  (rotationOffset) instead of ORDER BY updated_at DESC LIMIT 25. A stuck
  reserved DOI is exactly the row that stops being updated, so the recency
  window could permanently starve it under unrelated churn; rotation
  guarantees full coverage within ceil(total/batch) days.
- classifyExistingVersionDoi() makes the already-exists branch explicit:
  public->return, reserved->complete, anything else (unavailable/tombstone)
  ->throw, so a deliberately-tombstoned DOI is never silently resurrected.
- Dropped the redundant, silently-swallowing getDatasetsToken gate
  (per-row resolveEzidAuth already guards missing secrets).
- Pure tests for classifyExistingVersionDoi + rotationOffset coverage.
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review (sonnet) — findings addressed in 6cc5492

  • [important] the recency-biased sweep (ORDER BY updated_at DESC LIMIT 25) could permanently starve a stuck DOI — that DOI is exactly the row that STOPS being updated, and unrelated churn (auto-import etc.) pushes it out of the window. Replaced with a day-rotated offset (rotationOffset) that guarantees every version-DOI dataset is checked within ceil(total/batch) days.
  • [moderate] the fallthrough treated unavailable like reserved -> makePublic would resurrect a tombstoned DOI. Extracted classifyExistingVersionDoi(): public->return, reserved->complete, anything else->throw. Explicit + unit-tested (closes the test-gap suggestion too).
  • [moderate] dropped the redundant, silently-swallowing getDatasetsToken gate (per-row resolveEzidAuth already guards).
  • Reviewer confirmed clean: no use-before-assign, target in scope, final return always public, per-row error isolation, cron in the daily (not */30) branch + dev has no triggers, doi: reconstruction matches the stored (lowercased, prefix-stripped) form. Full backend suite (420) green.

@neuromechanist
neuromechanist merged commit 68406af into feature/issue-896-epic-arch-hardening Jul 6, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-900-phase5-doi branch July 6, 2026 23:30

This branch was previously deployed

1 inactive deployment
npm — 6cc54922 Deployed Jul 6, 2026 by neuromechanist via publish #1703
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