Repository navigation
Description
Symptom
Once enrichment runs on a dataset, it never stops. nemar-publish-bot commits Update NEMAR metadata (pipeline: enriched) [skip ci] to the dataset repo roughly every minute, indefinitely.
Observed on nemarDatasets/on007827: 51 commits in 1.5 hours, all touching only .nemar/metadata.json. The LLM rewrites `description`, `methods_description`, and `keywords` with semantically equivalent but textually different prose each run.
Burning Actions minutes on `nemarDatasets/.github` (the Team-plan allowance set up in epic #601), and pushing churn into the dataset history.
Root cause — two issues compose
(1) The trigger paths include the file enrichment writes.
`backend/src/routes/webhooks.ts:1438`:
```typescript
const ENRICHMENT_TRIGGER_PATHS: ReadonlySet = new Set([
"README.md",
"dataset_description.json",
".nemar/metadata.json", // ← enrichment writes this file
]);
```
Each enrichment commit modifies `.nemar/metadata.json` → push event → GitHub App webhook → `/webhooks/github` → `repository_dispatch[run-enrichment]` → enrichment runs again.
(`[skip ci]` does not block GitHub App push deliveries — only in-repo Actions workflow runs.)
(2) The source-hash skip only fires at the `validated` pipeline stage.
`backend/src/services/enrich-dataset.ts:419`:
```typescript
if (existingMetadata?.pipeline_stage === "validated" && !forceReenrich) {
if (existingMetadata.source_hash === sourceHash) {
// skip
}
}
```
If Stage 3 validation never returns `valid: true` after MAX_CORRECTIONS attempts, `pipeline_stage` stays at `enriched` and the skip never engages. The LLM (Claude Haiku 4.5 via OpenRouter) is non-deterministic, so each re-run produces different prose for `description`/`methods_description`/`keywords` — the file is always "changed", the webhook always fires, the loop never breaks.
For on007827 this is compounded by #642 — the LLM is reading the 7-line stub instead of the real OpenNeuro README, so Stage 3 validation likely fails consistently on missing claims.
Fix
- Drop `.nemar/metadata.json` from `ENRICHMENT_TRIGGER_PATHS`. Enrichment is the only writer of that file; external triggers (README/dataset_description) are the legitimate inputs. Alternative: filter pushes whose head_commit author is `nemar-publish-bot` — but the trigger-path approach is simpler and matches intent (enrichment runs on source change, not on its own output).
- Extend the skip guard in `enrich-dataset.ts:419` to also short-circuit when `pipeline_stage === "enriched"` AND `source_hash` matches. Belt-and-suspenders: even if (1) misfires, this stops the loop after one redundant run.
- Optional: add an attempt counter or stage-transition history to `.nemar/metadata.json` so a dataset that fails Stage 3 repeatedly surfaces in the dashboard rather than silently re-firing.
Defense-in-depth check
Confirm the legacy per-repo `llm-enrichment.yml` workflow is fully stripped on all dataset repos (`scripts/strip-per-repo-llm-enrichment.ts`) — if any repo still has it, both pipelines fire on every push and amplify the loop.
Stop-the-bleeding actions taken
- Disable `Run Enrichment` workflow on `nemarDatasets/.github` until the fix ships
- (Or) revoke / rotate `NEMAR_WEBHOOK_TOKEN` to fail-closed the API path
Related
- Surfaced while investigating Import overwrites OpenNeuro README with a 7-line stub instead of renaming #642 (import README stub on on007827)
- Centralized enrichment workflow lives in epic Epic: centralize per-repo dataset workflows on nemarDatasets/.github #601 / sub-issue Phase 1: centralize llm-enrichment workflow #602
Activity
review(#644): address three criticals from multi-agent review
Fix import README stub and enrichment self-loop (#642, #643) (#644)
Address review findings on LLM enrichment changes
Address review findings on LLM enrichment changes