Skip to content

feat(ci): add central run-enrichment workflow - #5

Merged
neuromechanist merged 2 commits into
mainfrom
4-add-central-run-enrichment-workflow
May 23, 2026
Merged

neuromechanist merged 2 commits into
mainfrom
4-add-central-run-enrichment-workflow

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Closes #4. Phase 1 of nemarOrg/nemar-cli#601.

What

New .github/workflows/run-enrichment.yml — central LLM-metadata enrichment workflow for NEMAR datasets. Mirrors generate-manifest.yml (#1).

  • repository_dispatch[run-enrichment] from the new Worker endpoint api.nemar.org/webhooks/github (lands in Phase 1: centralize llm-enrichment workflow nemarOrg/nemar-cli#602).
  • workflow_dispatch with dataset_id, ref, force inputs for manual recovery and smoke-tests.
  • Mints per-repo App installation token, checks out the target dataset repo at the given ref.
  • POSTs to https://api.nemar.org/webhooks/llm-enrich with the retry contract from feat(workflow): retry HTTP 5xx and fail loud in llm-enrichment.yml nemarOrg/nemar-cli#599: 3 attempts, 5/10/15s linear backoff, 4xx terminal (401 carve-out), exit 1 on persistent failure.
  • Commits .nemar/metadata.json + .bidsignore back to the target dataset repo with git pull --rebase retry loop for the cutover window where the old per-repo workflow may briefly co-fire.

Why

llm-enrichment.yml currently ships per-dataset-repo, so every fix forks 123-way (just hit this twice: #596 stale-token, #598 silent failure). The OpenNeuro mass-import will multiply that surface. Centralization is the proven pattern from manifest (#564) — one workflow, one fix point, dataset repos stay pristine.

Ship order

  1. ✅ This PR — land workflow on .github (idle, no caller yet).
  2. Phase 1: centralize llm-enrichment workflow nemarOrg/nemar-cli#602 — Worker /webhooks/github endpoint that fires repository_dispatch run-enrichment here.
  3. Configure App webhook URL on nemar-publish-bot → https://api.nemar.org/webhooks/github. One-time operator action.
  4. Strip per-repo llm-enrichment.yml from all 123 dataset repos via the cleanup script in #602.

Between (3) and (4) both workflows briefly fire on the same push; the Worker's source_hash guard makes the duplicate a Stage-2 no-op, and the workflow's rebase loop handles git commit races. Window is short and bounded.

Test plan

After merge:

gh workflow run run-enrichment.yml --repo nemarDatasets/.github -f dataset_id=nm099999 -f force=true
gh run watch
curl -s https://api.nemar.org/datasets/nm099999 | jq .dataset.enrichment_json

Expect: green run, enrichment_json populated in D1, .nemar/metadata.json committed to nemarDatasets/nm099999@main.

Closes #4. Centralizes the per-repo llm-enrichment.yml (currently in 123 dataset repos) into a single shared workflow. Mirrors generate-manifest.yml structure (#1) — repository_dispatch[run-enrichment] + workflow_dispatch entry points, per-repo App token via actions/create-github-app-token@v1, identical Worker round-trip + rebase-retry commit semantics. Phase 1 of nemarOrg/nemar-cli#601.
@neuromechanist neuromechanist linked an issue May 23, 2026 that may be closed by this pull request
Code-review findings: 1) curl call had no --connect-timeout or --max-time, so a hung TLS handshake or stalled Worker could pin the runner for the full 20-min timeout-minutes budget. Match generate-manifest.yml's pattern with --connect-timeout 10 --max-time 180. 2) Add explicit job-level permissions:{} to zero out the default GITHUB_TOKEN scope; the push uses a per-repo App installation token, the default token is never used and shouldn't carry implicit write.
@neuromechanist
neuromechanist merged commit 04e0879 into main May 23, 2026
@neuromechanist
neuromechanist deleted the 4-add-central-run-enrichment-workflow branch May 23, 2026 14:54
neuromechanist added a commit that referenced this pull request May 23, 2026
Closes #7. Phase 2 of nemarOrg/nemar-cli#601. Sibling to #5 (run-enrichment.yml). Lifts the per-repo version-doi.yml into a single shared workflow. Triggered by repository_dispatch[run-version-doi] from /webhooks/github tag-push handler (lands in nemarOrg/nemar-cli#606).
neuromechanist added a commit that referenced this pull request May 23, 2026
Closes #9. Phase 3 of nemarOrg/nemar-cli#601. Sibling to #5 (run-enrichment) and #8 (run-version-doi). Lifts the per-repo generate-archive.yml template — already repository_dispatch-driven so the Worker just retargets the dispatch URL.
neuromechanist added a commit to nemarOrg/nemar-cli that referenced this pull request May 23, 2026
…ub dispatch

Closes #602. Phase 1 of epic #601.

Removes the per-repo .github/workflows/llm-enrichment.yml that shipped to
123 dataset repos via deployWorkflows() and replaces it with:

- A new Worker endpoint POST /webhooks/github that receives GitHub App
  push events, HMAC-verifies the signature, filters to nemarDatasets
  dataset repos pushing README.md/dataset_description.json/.nemar/
  metadata.json on main or release/** branches, and fires
  repository_dispatch[run-enrichment] at nemarDatasets/.github.

- A new triggerEnrichmentRun() helper mirroring triggerManifestGeneration().

- A new webhook-signature service implementing HMAC-SHA256 verification
  with a constant-time compare (no crypto.timingSafeEqual on Workers).

- The central run-enrichment.yml workflow lives on nemarDatasets/.github
  (see nemarDatasets/.github#5). It mints a per-repo App token scoped to
  the target dataset_id, checks out the dataset repo at the given ref,
  and reuses the same Worker round-trip + retry contract as the legacy
  per-repo workflow (#599).

Tests added: webhook-signature.test.ts (11 cases), trigger-enrichment.test.ts
(4 cases), webhook-github-push.test.ts (19 cases) covering the dispatch
filter table. workflow-yaml.test.ts updated to assert the template is no
longer shipped.

Cutover script: scripts/strip-per-repo-llm-enrichment.ts deletes the
legacy file from every dataset repo. Idempotent. Operator runs once
after the App webhook URL is pointed at the new endpoint.
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.

Add central run-enrichment workflow

1 participant