Skip to content

Add EZID DOI provider integration and ORCID support - #110

Merged
neuromechanist merged 6 commits into
devfrom
feature/issue-107-phase2-ezid-integration
Feb 11, 2026
Merged

neuromechanist merged 6 commits into
devfrom
feature/issue-107-phase2-ezid-integration

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

  • Add DOI provider dispatch layer (backend/src/services/doi.ts) that routes concept and version DOI creation to EZID or Zenodo based on per-dataset doi_provider setting
  • Add ORCID collection at user registration (optional field, auto-injected into DataCite creator metadata)
  • Add database migration for orcid on users table and ezid_identifier, ezid_status, doi_provider on datasets table
  • Update admin concept DOI route, publication orchestrator, and webhook version DOI handler for dual-provider support
  • Add CLI --provider option to doi create and new doi update command for EZID metadata refresh/status changes
  • 13 new tests covering ORCID validation, DataCite enrichment, and version relations

Test plan

  • bun test passes (283 pass, 17 skip, 0 fail)
  • bunx tsc --noEmit type-checks clean
  • bun run build produces working CLI bundle
  • Manual: nemar auth signup collects ORCID, nemar auth status --refresh shows it
  • Manual: nemar admin doi create nm099999 --provider ezid mints on test shoulder
  • Deploy migration 0007_ezid.sql to D1
  • Set EZID secrets via wrangler secret put

Closes #107

Integrate EZID as the default DOI provider with per-dataset
provider selection. Add ORCID collection at user registration
for automatic DataCite creator metadata enrichment.

- Add DOI provider dispatch layer (backend/src/services/doi.ts)
- Add database migration for ORCID and EZID columns
- Update signup flow to collect optional ORCID
- Update concept DOI route to support EZID and Zenodo
- Update webhook version DOI with dual-provider routing
- Add CLI --provider option and doi update command
- Add tests for ORCID validation and DataCite enrichment

Closes #107
@github-actions

github-actions Bot commented Feb 11, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR110

Version: 0.3.11-PR110.8f20291
Commit: 8f20291


🤖 Updated on each push.

- Fix webhook default provider to "ezid" (was "zenodo", inconsistent)
- Add EZID credential validation before DOI operations
- Make concept DOI update non-fatal in version DOI creation
- Add BIDS metadata warning to concept DOI response
- Validate JSON.parse result shape for dataset_description.json
- Add NaN guard for Zenodo providerRecordId parseInt
- Fix inaccurate JSDoc on concept DOI route
@neuromechanist

Copy link
Copy Markdown
Contributor Author

PR Review Summary

Ran 6 specialized review agents in parallel (code, errors, tests, types, comments, simplify).

Critical Issues (6 found, all fixed)

  1. Webhook default provider "zenodo" inconsistent with DB default "ezid" and admin routes - Fixed: changed to "ezid"
  2. Missing EZID credential validation - undefined creds silently become btoa("undefined:undefined") - Fixed: added upfront check
  3. No transactional safety in createEzidVersionDoi - if makePublic succeeds but concept update fails, orphaned public DOI - Fixed: concept update is now non-fatal with logging
  4. Inaccurate JSDoc on concept DOI route (said "Zenodo" when it now dispatches to either provider) - Fixed
  5. Number.parseInt on providerRecordId without NaN check - Fixed: added NaN guard
  6. JSON.parse with as cast but no runtime shape validation for BIDS metadata - Fixed: added object shape check

Important Issues (documented, deferred to Phase 3)

  • HasVersion relations overwritten on each new version DOI (only latest version referenced). Will need DB-tracked version list or EZID metadata read-back. Tracked for Phase 3.
  • BIDS metadata failures silently degrade DOI quality - Added metadata_warning field to response. Full solution (require BIDS or fail) deferred.
  • Test coverage gaps - dispatch routing and version DOI orchestration untested (no-mock policy requires live EZID calls). Will expand sandbox tests in Phase 3.

Improvements Applied (by code-simplifier)

  • Extracted buildOrcidEnrichment helper (was duplicated inline)
  • Removed unused getDoiUrl import
  • Replaced dynamic imports with static imports in update DOI route
  • Removed redundant type cast on Zod-validated body.provider

Type Design Notes (deferred)

  • DoiResult and CreateConceptDoiResponse are candidates for discriminated unions on provider - will improve in Phase 3
  • ezid_status should use EzidStatus type instead of bare string - minor, deferred

Strengths

  • Clean dispatch layer pattern separating EZID/Zenodo concerns
  • ORCID validation correct (regex + Zod)
  • Migration handles backwards compatibility (existing Zenodo datasets preserved)
  • Good error propagation in EZID service layer
  • Appropriate confirmation prompts for permanent --make-public action

- Fix HasVersion overwrite: add dataset_versions table to track all
  version DOIs; concept DOI update now includes all versions
- Add parseDoiProvider() to replace unsafe `as` casts at DB boundary
- Add EZID credential validation to DOI update endpoint
- Make refresh_metadata fail explicitly when repo/file missing
- Surface manifest errors in webhook JSON responses
- Refactor DoiResult to discriminated union on provider field
- Refactor CreateConceptDoiResponse to discriminated union
- Type ezid_status as literal union instead of bare string
- Add 18 new tests: parseDoiProvider, buildOrcidEnrichment matching,
  credential rejection, multiple HasVersion preservation
@neuromechanist

neuromechanist commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Final Review Summary

All critical, important, and suggested issues from the 6-agent review have been addressed across 3 commits.

Commit 1: Implementation (4a18316)

Phase 2 EZID DOI provider integration and ORCID support (13 files, 1081 insertions).

Commit 2: Initial review fixes (c3c011f)

  • Fixed webhook default provider "zenodo" -> "ezid"
  • Added EZID credential validation
  • Made concept DOI update non-fatal in version DOI creation
  • Added BIDS metadata warning to response
  • Validated JSON.parse result shape
  • Added NaN guard for parseInt

Commit 3: All remaining review findings (80de83a)

  • Fixed HasVersion overwrite bug: new dataset_versions table tracks all version DOIs; concept DOI now includes all HasVersion relations
  • Added parseDoiProvider() helper to replace unsafe as casts at DB boundary
  • Added EZID credential validation to DOI update endpoint
  • Made refresh_metadata fail explicitly when repo or file is missing
  • Surfaced manifest errors in webhook JSON responses
  • Refactored DoiResult and CreateConceptDoiResponse to discriminated unions on provider
  • Typed ezid_status as "reserved" | "public" | "unavailable" | null instead of string
  • Added 18 new tests (301 total pass, 0 fail):
    • parseDoiProvider: 7 tests (valid, invalid, null, fallback)
    • buildOrcidEnrichment: 7 tests (matching, no-match, missing inputs, first-match-only)
    • Dispatch credential rejection: 3 tests (EZID concept, Zenodo concept, EZID version)
    • Multiple HasVersion preservation: 1 test

Review Agent Results

Agent Critical Important Suggestions Status
code-reviewer 2 1 0 All fixed
silent-failure-hunter 4 5 4 All fixed
pr-test-analyzer 3 4 3 All addressed
type-design-analyzer 0 3 5 All addressed
comment-analyzer 3 4 3 All fixed
code-simplifier 0 0 4 All applied

Verification

  • bun test: 301 pass, 17 skip, 0 fail
  • bunx tsc --noEmit: clean
  • bun run build: 1.32 MB bundle
  • Manual: nemar auth signup collects ORCID
  • Manual: nemar admin doi create nm099999 --provider ezid on test shoulder
  • Deploy migration 0007_ezid.sql to D1
  • Set EZID secrets via wrangler secret put

Closes #107

Separate sandbox credentials (EZID_SANDBOX_USERNAME, EZID_SANDBOX_PASSWORD)
so --sandbox uses the test account instead of production credentials.
resolveEzidAuth() picks the right credentials based on sandbox flag.
- Export resolveEzidAuth from doi.ts, use in /doi/update route
  (fixes bug where inline credential logic didn't throw on empty creds)
- Fix inaccurate comments: DOI permanence, "Zenodo as fallback",
  uploaderName purpose, handler descriptions, DoiResult docstring
- Add sandbox credential routing tests (5 new)
- Add wrangler.toml sandbox secret comments
@neuromechanist

Copy link
Copy Markdown
Contributor Author

PR Review v2 Summary (Post-Sandbox Credential Changes)

All 6 specialized review agents ran. All findings addressed in commit d57c498.

Critical Issues Fixed (2)

  • [code-reviewer] Missing sandbox credentials in publish/approve route -- added EZID_SANDBOX_USERNAME/PASSWORD passthrough
  • [type-design] Duplicated credential resolution in /doi/update route didn't throw on empty creds -- replaced with exported resolveEzidAuth()

Important Issues Fixed (5)

  • [comment-analyzer] "Zenodo as fallback" misleading -- reworded to "or Zenodo if explicitly requested"
  • [comment-analyzer] DOI permanence warning inaccurate for reserved DOIs -- clarified reserved DOIs are deletable
  • [comment-analyzer] uploaderName JSDoc said "fallback creator" -- corrected to "ORCID matching + Zenodo creator"
  • [comment-analyzer] resolveEzidAuth comment omitted sandbox-to-production fallback behavior -- updated
  • [comment-analyzer] "(existing flow)" stale language in Zenodo handler -- removed, expanded description

Tests Added (5)

  • [test-coverage] Sandbox credential routing: sandbox with sandbox creds, sandbox fallback to production, sandbox without any creds, Zenodo sandbox missing key

Suggestions Deferred (not blocking)

  • [type-design] Server response Record<string, unknown> could use typed response objects (nice-to-have, no runtime risk)
  • [type-design] parseDoiProvider could log warning for unrecognized non-null provider values
  • [silent-failure] DB write failure after DOI mint is logged but could surface in response (medium risk, non-fatal)
  • [comment-analyzer] Remove redundant // Validate webhook token and // Parse request body comments

Test Results

305 pass, 17 skip, 0 fail (596 expect() calls across 14 files)

@neuromechanist
neuromechanist merged commit 6143dd3 into dev Feb 11, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-107-phase2-ezid-integration branch March 6, 2026 23:56

This branch was previously deployed

1 inactive deployment
npm — 8f20291b Deployed Feb 11, 2026 by neuromechanist via publish #182
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