Skip to content

Metadata pipeline: staged enrichment with seed, LLM enrichment, and LLM validation #154

Closed

Description

@neuromechanist

Overview

.nemar/metadata.json should be the single source of truth for all dataset metadata that goes into a DOI. Currently, metadata is assembled on the fly from multiple sources during DOI minting (dataset_description.json, .nemar/metadata.json, D1 cache). This makes it impossible to review what will be minted before it happens.

Instead, the metadata file should be built through a staged pipeline where each stage adds or refines metadata, and the file tracks its current stage.

Pipeline Stages

Stage 1: Seed

Pull all base metadata from BIDS sources into .nemar/metadata.json:

  • All authors from dataset_description.json (even without ORCIDs)
  • Title (Name), license (License), data type (DatasetType: raw/derivative)
  • SourceDatasets -> IsDerivedFrom related identifiers
  • Funding references
  • ReferencesAndLinks -> related identifiers
  • HowToAcknowledge

Trigger: runs as part of dataset upload or on first push to main.

Stage 2: LLM Enrichment (current implementation)

Extract what BIDS doesn't provide from README:

  • Rich description/abstract
  • Methods description
  • Structured keywords with subject schemes (e.g., MeSH)
  • Additional funding details (award numbers found in text)
  • Additional related identifiers from README

Trigger: llm-enrichment.yml workflow on push to main when README.md or dataset_description.json change.

Stage 3: LLM Validation (judge)

A second LLM pass that reviews the assembled metadata:

  • Validates relation types (e.g., IsDerivedFrom vs IsVersionOf vs IsDescribedBy)
  • Checks author completeness against README mentions
  • Validates keyword relevance and scheme assignments
  • Flags inconsistencies between description and actual data
  • Produces a confidence score or list of concerns

Trigger: runs after enrichment completes, or on demand.

Schema Changes

Add pipeline_stage field to .nemar/metadata.json:

{
  "version": "2.0",
  "pipeline_stage": "validated",
  "authors": { ... },
  "description": "...",
  ...
}

Values: "seeded" | "enriched" | "validated"

DOI Gating

Update the enrichment gate on DOI concept creation:

  • Currently: checks enrichment_json IS NOT NULL
  • Target: checks pipeline_stage >= "enriched" (or "validated" once judge is reliable)

Changes to bidsToDataCite()

Currently assembles metadata from multiple sources. Should be refactored to read primarily from .nemar/metadata.json as the single source of truth, with dataset_description.json only as a fallback for unseeded datasets.

Motivation

  • The LLM incorrectly classified a PhysioNet DOI as IsVersionOf when it should be IsDerivedFrom. A validation stage would catch this.
  • Authors without ORCIDs are currently missing from .nemar/metadata.json because only ORCID-bearing authors are stored during upload. All authors should be present.
  • No way to review what metadata will go into a DOI before minting.
  • Data type (raw vs derivative) is in BIDS but never pulled into the metadata file.

Parent Issue

Sub-issue of #108 (Phase 3: Rich metadata enrichment for DataCite DOIs)

Activity

  1. added
    feature
    on Feb 18, 2026
  2. neuromechanist commented on Feb 18, 2026

    @neuromechanist
    ContributorAuthor

    LLM Validation Prompt Design (Stage 3)

    Modeled after Anthropic's pr-review-toolkit agents, which use structured evaluation criteria with confidence scoring and actionable output.

    System Prompt Structure

    The validation LLM receives three inputs:

    1. .nemar/metadata.json (the metadata to validate)
    2. README.md (ground truth for content)
    3. dataset_description.json (ground truth for BIDS fields)

    Validation Criteria (0-100 confidence scoring)

    Criterion Weight What it checks
    Author completeness High All authors from BIDS present? README mentions anyone missing?
    Related identifier accuracy High Correct relation types? (IsDerivedFrom vs IsVersionOf vs IsDescribedBy) Cross-check with SourceDatasets in BIDS.
    Description accuracy Medium Abstract matches actual dataset? Methods technically accurate?
    Keyword relevance Medium Keywords describe the dataset? MeSH terms are real MeSH?
    Funding accuracy Medium Real organizations? Award numbers from README/BIDS?
    Data type correctness Low raw/derivative matches DatasetType and README context?

    Output Format

    {
      "overall_pass": true,
      "criteria": {
        "author_completeness": {
          "confidence": 95,
          "pass": true,
          "issues": [],
          "suggestions": []
        },
        "related_identifiers": {
          "confidence": 40,
          "pass": false,
          "issues": ["10.13026/ym7v-bh53 has relation_type IsVersionOf but dataset_description.json lists this as a SourceDataset, suggesting IsDerivedFrom"],
          "suggestions": ["Change relation_type to IsDerivedFrom"]
        }
      },
      "blocking_issues": ["Incorrect relation type for 10.13026/ym7v-bh53"],
      "warnings": []
    }

    Blocking vs Warnings

    Blocking (must fix before DOI): missing authors, incorrect relation types, factually wrong description
    Warnings (should fix): missing keywords, imprecise descriptions, unconfirmed funding details

    Implementation Notes

    • Same OpenRouter API + Claude Haiku 4.5 model as enrichment
    • Runs as a separate step after enrichment completes
    • Updates pipeline_stage from "enriched" to "validated" on pass
    • If validation fails: stores issues in metadata file, leaves stage as "enriched"
    • Admin can review issues and either fix metadata or override
  3. neuromechanist commented on Feb 18, 2026

    @neuromechanist
    ContributorAuthor

    Implemented in PR #152. The staged metadata pipeline (seed -> enrich -> validate) is live on production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions