Skip to content

Fix #535: stop seeding OpenNeuro placeholder; route provenance to README - #536

Merged
neuromechanist merged 2 commits into
devfrom
fix/issue-535-description-priority
May 18, 2026
Merged

neuromechanist merged 2 commits into
devfrom
fix/issue-535-description-priority

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Closes #535.

Problem

The OpenNeuro importer seeded datasets.description with "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 https://data.nemar.org/<id>/metadata.json kept returning it forever — defeating the whole point of the enrichment pipeline that v0.8.20 unblocked.

Verified after v0.8.20 ship: enrichment for on000117 runs cleanly, D1 enrichment_json has pipeline_stage: validated + the real LLM description, but the public endpoint's root description field is still "Imported from OpenNeuro ds000117".

Resolution

Three coordinated changes:

1. Stop seeding the placeholder. src/lib/import-openneuro.ts no longer passes a description argument to importDataset(). OpenNeuro provenance is already encoded by source: "openneuro", source_id, and the on* dataset_id prefix; the website renders the attribution badge from those fields. Future on* imports leave datasets.description blank.

2. Route provenance to the README instead. New appendOpenNeuroProvenance helper writes a deterministic ## Provenance section to README.md at 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 buildDatasetMetadata description priority. backend/src/services/data-router.ts now prefers v2.description (or v1.description) over row.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 typecheck clean (root + backend)
  • bun test test/import-openneuro.test.ts test/data-route.unit.test.ts: 151/151 pass
  • New tests:
  • After merge → deploy → nemar admin reindex --missing-metadata: verify data.nemar.org/<id>/metadata.json description field returns LLM content for on* datasets (the user-visible payoff)

Related

…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).
@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR536

Version: 0.8.21-PR536.f9c22b4
Commit: f9c22b4


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit d9c12a9 into dev May 18, 2026
16 of 17 checks passed
@neuromechanist
neuromechanist deleted the fix/issue-535-description-priority branch May 18, 2026 10:19

This branch was previously deployed

1 inactive deployment
npm — f9c22b44 Deployed May 18, 2026 by neuromechanist via publish #969
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