Repository navigation
Description
Sub-task of #601.
Scope
Move llm-enrichment.yml out of every dataset repo and into a single central workflow on nemarDatasets/.github. The Worker becomes the single source of truth for "this push needs enrichment."
Deliverables
1. Central workflow — nemarDatasets/.github/.github/workflows/run-enrichment.yml
Mirrors the existing generate-manifest.yml pattern:
- Triggers:
repository_dispatchtyperun-enrichment+workflow_dispatch(manual recovery). - Inputs (workflow_dispatch) / client_payload (repository_dispatch):
dataset_id(required),ref(defaultmain),force(bool, default false). - Mints App installation token via
actions/create-github-app-token@v1withrepositories: ${{ ... dataset_id }}— narrow scope per run. - Checks out the target dataset repo at the given ref (NOT
.githubitself). - POSTs to
https://api.nemar.org/webhooks/llm-enrichwith{dataset_id, force, client_commits: true, ref}andX-Webhook-Token: $NEMAR_WEBHOOK_TOKEN. - Retry contract from Workflow template: retry HTTP 5xx and fail loud on persistent enrichment failure #598/feat(workflow): retry HTTP 5xx and fail loud in llm-enrichment.yml #599: 3 attempts with 5s/10s/15s backoff, 4xx terminal (except 401 carve-out for token rotation), exits 1 on persistent failure.
- Commits the returned
.nemar/metadata.json+.bidsignoreupdates back to the dataset repo on the same ref. Push-rebase retry loop already there.
2. Worker push dispatcher
Update backend/src/routes/webhooks.ts (or the existing /webhooks/github handler) to:
- Receive GitHub App push events for any dataset repo in
nemarDatasets. - Filter: branch is
mainORrelease/**, AND modified-paths intersect{README.md, dataset_description.json, .nemar/metadata.json}. - If match: POST
repository_dispatchatnemarDatasets/.githubwithevent_type: "run-enrichment",client_payload: { dataset_id, ref, force: branch.startsWith('release/') }. - If no match: existing behavior.
- Use
triggerEnrichment(env, datasetId, ref, force)helper analogous totriggerManifestGeneration(consistent surface).
3. Strip per-repo template
In backend/src/services/github.ts:
- Delete the
llmEnrichmenttemplate string. - Remove
.github/workflows/llm-enrichment.ymlfrom thegetWorkflowTemplates()array. - Update
test/workflow-yaml.test.tsto no longer expect this file.
4. One-time cleanup of existing repos
Script (committed under scripts/) that loops every dataset repo and removes the per-repo .github/workflows/llm-enrichment.yml via DELETE /repos/<owner>/<repo>/contents/<path> once the central workflow is live. Idempotent.
5. Tests
- New unit test for the dispatcher: given a push payload mentioning README.md, asserts
repository_dispatchis called with the right shape. - Update existing
workflow-yaml.test.tsto match the new template set (no llm-enrichment). - Smoke test plan in PR body:
gh workflow run run-enrichment.yml -f dataset_id=nm099999should mint a token, fetch, post, and commit cleanly on the sandbox dataset.
Ship order (atomic window matters)
- Land + deploy central workflow on
nemarDatasets/.github(idle: no Worker dispatches it yet). gh workflow runagainstnm099999to confirm green.- Land + deploy Worker dispatcher. Now both old (per-repo) AND new (central) fire on every README push — the Worker's
/webhooks/llm-enrichalready dedupes viasource_hash, so the second run no-ops at Stage-2 enrichment. Window cost: one duplicate workflow run per push, no data corruption. - Run the cleanup script to remove
llm-enrichment.ymlfrom all 123 dataset repos. After this, only the central workflow fires. - Land + deploy the
deployWorkflows()strip — new imports stop shipping the per-repo file.
Steps 1-4 can happen on a single PR + post-merge runbook. Step 5 can land in the same PR (it's harmless until deployed because old repos already have the file, and new imports don't exist between steps 4 and 5).
Out of scope
- Other workflows (Phase 2+ in Epic: centralize per-repo dataset workflows on nemarDatasets/.github #601).
- Changes to
/webhooks/llm-enrichitself — same contract.
Acceptance
nm099999enrichment fires on README push, runs the central workflow, commits.nemar/metadata.jsonback. No per-repo workflow file required.gh api repos/nemarDatasets/on002778/contents/.github/workflows/llm-enrichment.ymlreturns 404.- New
nemar admin import-openneuro <id>creates a repo with nollm-enrichment.ymlunder.github/workflows.
Activity
feat(centralize): replace per-repo llm-enrichment with /webhooks/gith…
feat(centralize): replace per-repo version-doi with /webhooks/github …