Skip to content

Phase 1: centralize llm-enrichment workflow #602

Closed

Description

@neuromechanist

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_dispatch type run-enrichment + workflow_dispatch (manual recovery).
  • Inputs (workflow_dispatch) / client_payload (repository_dispatch): dataset_id (required), ref (default main), force (bool, default false).
  • Mints App installation token via actions/create-github-app-token@v1 with repositories: ${{ ... dataset_id }} — narrow scope per run.
  • Checks out the target dataset repo at the given ref (NOT .github itself).
  • POSTs to https://api.nemar.org/webhooks/llm-enrich with {dataset_id, force, client_commits: true, ref} and X-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 + .bidsignore updates 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 main OR release/**, AND modified-paths intersect {README.md, dataset_description.json, .nemar/metadata.json}.
  • If match: POST repository_dispatch at nemarDatasets/.github with event_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 to triggerManifestGeneration (consistent surface).

3. Strip per-repo template

In backend/src/services/github.ts:

  • Delete the llmEnrichment template string.
  • Remove .github/workflows/llm-enrichment.yml from the getWorkflowTemplates() array.
  • Update test/workflow-yaml.test.ts to 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_dispatch is called with the right shape.
  • Update existing workflow-yaml.test.ts to match the new template set (no llm-enrichment).
  • Smoke test plan in PR body: gh workflow run run-enrichment.yml -f dataset_id=nm099999 should mint a token, fetch, post, and commit cleanly on the sandbox dataset.

Ship order (atomic window matters)

  1. Land + deploy central workflow on nemarDatasets/.github (idle: no Worker dispatches it yet).
  2. gh workflow run against nm099999 to confirm green.
  3. Land + deploy Worker dispatcher. Now both old (per-repo) AND new (central) fire on every README push — the Worker's /webhooks/llm-enrich already dedupes via source_hash, so the second run no-ops at Stage-2 enrichment. Window cost: one duplicate workflow run per push, no data corruption.
  4. Run the cleanup script to remove llm-enrichment.yml from all 123 dataset repos. After this, only the central workflow fires.
  5. 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

Acceptance

  • nm099999 enrichment fires on README push, runs the central workflow, commits .nemar/metadata.json back. No per-repo workflow file required.
  • gh api repos/nemarDatasets/on002778/contents/.github/workflows/llm-enrichment.yml returns 404.
  • New nemar admin import-openneuro <id> creates a repo with no llm-enrichment.yml under .github/workflows.

Activity

  1. added
    feature
    on May 23, 2026
  2. added 2 commits that reference this issue on May 23, 2026
    dd6fead
    b79d7bd
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