Repository navigation
Fix #535: stop seeding OpenNeuro placeholder; route provenance to README - #536
Merged
Merged
Conversation
…nance to README The OpenNeuro importer used to set the D1 datasets.description column to 'Imported from OpenNeuro <ds>' at import time. buildDatasetMetadata then prioritized that catalog row over the LLM-enriched v2 description, so the placeholder survived every successful enrichment cycle and the public metadata.json endpoint kept returning it forever — defeating the whole point of the enrichment pipeline that v0.8.20 unblocked. Three coordinated changes: src/lib/import-openneuro.ts: drop the description: 'Imported from OpenNeuro <ds>' arg from importDataset(). Provenance is already encoded by source: 'openneuro', source_id, and the on* dataset_id prefix; the website renders the attribution badge from those fields. Add a new appendOpenNeuroProvenance helper that writes a deterministic '## Provenance' section to README.md at import time (idempotent; re-running the importer is a no-op once the marker is present). The README is the right place for human-readable provenance — it ships with the GitHub repo, is visible without hitting any API, and stays out of the LLM enrichment write path. backend/src/services/data-router.ts: flip buildDatasetMetadata's description-priority order so the LLM-enriched v2 (or v1) description wins over row.description, with row.description as the fallback for datasets that have not been enriched yet. The existing v2 fallback test stays; new tests pin the placeholder→enrichment substitution and the no-enrichment fallback. test/import-openneuro.test.ts: new describe block for appendOpenNeuroProvenance covering creation, append-to-existing, idempotency, and the no-trailing-newline edge case. The fix is forward-looking (new on* imports never get the placeholder) and backward-compatible (existing on* datasets in D1 still have the stale placeholder, but the metadata.json endpoint now correctly serves the enrichment when present).
The pr-review-toolkit code-reviewer flagged that the readReadme() helper in test/import-openneuro.test.ts used a dynamic require() call instead of the ES module import already present at the top of the file. Add readFileSync to the existing destructure and use it directly. No behavior change; consistent with .rules/javascript.md (ES modules only).
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR536Version: 🤖 Updated on each push. |
3 of 6 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.
Closes #535.
Problem
The OpenNeuro importer seeded
datasets.descriptionwith"Imported from OpenNeuro <ds>"at import time.buildDatasetMetadatathen prioritized that catalog row over the LLM-enrichedv2.description, so the placeholder survived every successful enrichment cycle andhttps://data.nemar.org/<id>/metadata.jsonkept returning it forever — defeating the whole point of the enrichment pipeline that v0.8.20 unblocked.Verified after v0.8.20 ship: enrichment for
on000117runs cleanly, D1enrichment_jsonhaspipeline_stage: validated+ the real LLM description, but the public endpoint's rootdescriptionfield is still"Imported from OpenNeuro ds000117".Resolution
Three coordinated changes:
1. Stop seeding the placeholder.
src/lib/import-openneuro.tsno longer passes adescriptionargument toimportDataset(). OpenNeuro provenance is already encoded bysource: "openneuro",source_id, and theon*dataset_id prefix; the website renders the attribution badge from those fields. Future on* imports leavedatasets.descriptionblank.2. Route provenance to the README instead. New
appendOpenNeuroProvenancehelper writes a deterministic## Provenancesection toREADME.mdat import time. The README is the right place for human-readable provenance — it ships with the GitHub repo, is visible without hitting any API, stays out of the LLM enrichment write path, and is idempotent (uses an HTML-comment marker so re-running the importer is a no-op).3. Flip
buildDatasetMetadatadescription priority.backend/src/services/data-router.tsnow prefersv2.description(orv1.description) overrow.description. This protects the ~50 existing on* datasets whose D1 row still carries the legacy placeholder.Why not just delete the placeholder from D1?
Considered, but the priority flip makes the placeholder harmless (always overridden after enrichment) and the import flow change ensures no new datasets get one. A D1 cleanup migration is a separate, lower-priority chore.
Test plan
bun run typecheckclean (root + backend)bun test test/import-openneuro.test.ts test/data-route.unit.test.ts: 151/151 passappendOpenNeuroProvenance: creation, append-to-existing, idempotency, no-trailing-newline edge casebuildDatasetMetadata: placeholder→enrichment substitution (the exact data.nemar.org metadata.json prioritizes stale row.description over LLM-enriched v2.description #535 scenario), no-enrichment row.description fallbacknemar admin reindex --missing-metadata: verifydata.nemar.org/<id>/metadata.jsondescriptionfield returns LLM content for on* datasets (the user-visible payoff)Related