Repository navigation
Phase 3: Rich metadata enrichment for DataCite DOIs - #115
Merged
Merged
Conversation
Phase 3 of EZID DOI epic (#108): adds NemarMetadata type/parser, LLM-based enrichment from README via OpenRouter, upload-time ORCID collection for co-authors, admin doi enrich command, backend enrichment endpoint, DB migration, and 22 new tests.
- Add try-catch around LLM JSON.parse with contextual error message - Export validateLlmResult for testing; add 8 tests - Add isValidRelationType validator; filter invalid types in conversion - Replace empty catch blocks with logged warnings in dataset/admin CLIs - Add console.error to /files endpoint error handler - Remove duplicate formatDatasetSize, use shared formatBytes - Fix stale "placeholder" comment on DOI section
- Fix publication step count: CLI now shows all 14 orchestrator steps - Extract revertVisibilityChange helper (removes ~60 lines duplication) - Extract getS3Config helper (replaces 9 inline S3 credential objects) - Extract startStep helper (replaces 14 current_step DB updates) - Add handleCommandError helper for CLI error handling - Add isValidRelationType validator with Set lookup - Clean up type guards in llm-enrich.ts - Remove duplicate audit log comment - Replace nested ternary with lookup map in dataset.ts
Replace 3 duplicate error display patterns (spinner.fail + console.log of same message) with handleCommandError helper. Update tests to check stderr where ora spinner output lands.
Deduplicate ORCID regex (was in admin.ts and dataset.ts), error message extraction pattern (7+ instances), and GitHub file content fetching via gh api subprocess.
- Derive RelationType from const array (single source of truth) - parseNemarMetadata: reject unrecognized versions, validate relationType at parse time - nemarMetadataToEnrichment: merge funding (was overwrite), deduplicate related DOIs by doi+relationType - validateLlmResult: validate relationType, validate funding field types (awardNumber/awardTitle must be string) - Backend: add warnings array to DOI update response, surface enrichment parse failures in webhook response - Fix extension extraction for files without dots - Fix JSDoc claiming endpoint refreshes DOIs (it doesn't) - CLI: warn on BIDS parse failure, re-attempt DOI fetch before refresh, remove stale comments, wrap writeFileSync in try-catch - Add 13 new tests (version check, partial fields, merge/dedup, funding conversion, enrichFromReadme early return)
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR115Version: 🤖 Updated on each push. |
Contributor
Author
PR Review: Comprehensive Review with All Fixes AppliedRan 6 review agents in parallel. All findings addressed in 3 commits. Review Findings and Fixesdatacite.ts:
backend admin.ts:
webhooks.ts:
CLI admin.ts:
CLI dataset.ts:
llm-enrich.ts:
Tests (13 new, 348 total):
CI StatusAll checks green: lint, unit-test, api-test, e2e-sandbox, zenodo-sandbox-test, publish, changes. Commits
|
1 of 5 tasks
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #108
Phase 3 of the EZID DOI epic (#105). Adds rich metadata enrichment for DataCite DOI records:
doi enrichcommand: Interactive enrichment with LLM + manual ORCID editingnemar_metadata.json: Canonical enrichment file stored in dataset reposPOST /admin/datasets/:id/enrichmentcommits to repo + caches in D1Code quality improvements (from 2 rounds of PR review)
handleCommandError,getS3Config,startStep,revertVisibilityChangeshelpersisValidRelationTyperuntime validator (no unsafe casts)Test plan
bun test- 335 pass, 0 fail, 20 skipbunx biome check- pre-existing issues only (not from this PR)nemar admin doi enrich nm099999 --sandboxnemar admin doi enrich nm099999 --sandbox --no-llmFiles changed
backend/src/services/datacite.tsNemarMetadata,parseNemarMetadata(),isValidRelationType(), sizes/formatsbackend/src/db/migrations/0008_enrichment.sqlenrichment_json,enrichment_updated_atcolumnsbackend/src/routes/admin.tsgetS3Config/startStep/revertVisibilityChangeshelpersbackend/src/routes/webhooks.tsnemar_metadata.jsonduring version DOI creationsrc/lib/llm-enrich.tssrc/lib/api.tssubmitEnrichment(),getDatasetFiles()src/commands/dataset.tssrc/commands/admin.tsdoi enrichcommand,handleCommandErrorhelper, publish fixestest/doi-provider.test.tstest/publish-workflow.test.ts