Repository navigation
Fix import README stub and enrichment self-loop (#642, #643) - #644
Conversation
Two bugs that compounded on on007827: (1) Import wrote a 7-line README.md stub when upstream shipped README (no extension), leaving the real upstream README orphaned. The downstream LLM enricher reads README.md first, so it has been seeing only the stub. ensureReadmeMd now: rename README -> README.md if needed, keep any suffixed variant (.md, .rst, .txt) untouched, fall back to a stub only when no README exists upstream. Content is never modified. (2) Enrichment self-triggered: .nemar/metadata.json was on the push trigger paths AND the source-hash skip only fired at pipeline_stage == "validated". Datasets stuck at "enriched" (Stage 3 fails) looped every minute as Haiku's non-deterministic prose changed the file each run. Drop .nemar/metadata.json from triggers; extend the skip to short-circuit at "enriched" too when source_hash matches. Fixes #642, #643
Multi-agent review summaryRan 5 specialized reviewers in parallel. Aggregated findings below. VerdictCode review: Ship it. No critical or important blockers. Critical findings to address before merge
Important findings (worth addressing)
Minor (skip if time-pressed)
Positive observations
Stop-the-bleeding action (separate from PR)Force-pushed |
1. Case-sensitive regex bug (review crit #1): /^README(\.[A-Za-z0-9]+)?$/ is now /i so `Readme.md`, `readme`, and other case variants are detected. On case-insensitive filesystems (macOS APFS, Windows NTFS) the prior regex would miss `Readme.md`, fall through to the stub branch, and writeFileSync('README.md', stub) would silently overwrite the upstream-authored file. 2. README collision: when upstream ships BOTH `README` and `README.md`, the new preference rule picks the suffixed variant first. Renaming the bare `README` over an existing `.md` would have destroyed upstream content; the suffixed-first order is now explicit and deterministic regardless of OS listing order. 3. Skip-guard untested (review crit #2): extracted decideSkipEnrichment as a pure helper and pinned the full 5-arm decision table: - validated + matching hash → skip - enriched + matching hash → skip (the #643 fix) - validated/enriched + mismatch → proceed - source_hash undefined (migration arm) → proceed - seeded / unknown stages → proceed - forceReenrich=true → always proceed Plus edge cases for empty-string source_hash. 14 new test cases. Test counts: import-openneuro.test.ts 32→38, new enrich-skip-guard suite 14, full suite 1639/41 skip/0 fail.
Review crits addressed (cc5b137)1. Case-sensitive regex bug — fixed
2. README collision — fixedAdded an explicit preference rule: when multiple README variants exist, suffixed files ( 3. Skip-guard untested — fixedExtracted
Plus pinned edge cases: empty-string source_hash is distinct from undefined; both empty strings match (documented trade-off). Skipped (per request — only 3 criticals)
These remain as follow-ups if you want them in a separate PR. Test counts
|
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR644Version: 🤖 Updated on each push. |
Summary
Fixes two bugs that compounded on
nemarDatasets/on007827, causing a 60-runs/hr enrichment loop that burned through Actions minutes and OpenRouter calls until manually disabled.Bug 1: Import wrote a stub README that hid the upstream one (#642)
appendOpenNeuroProvenanceinsrc/lib/import-openneuro.tschecked forREADME.mdonly. OpenNeuro shipsREADME(no extension, BIDS-compliant), soexistsSyncreturned false and the importer wrote a fresh 7-line stub toREADME.md, leaving the upstreamREADMEorphaned. The LLM enricher (enrich-dataset.ts:281) looks atREADME.mdfirst, so it has been enriching against the stub — explaining the generic, content-freedescriptionfields on imported datasets.Confirmed on
on007827: source had 6515-byteREADME, mirror got a 366-byte stub.Fix (renamed function to
ensureReadmeMd):READMEexists, no extension →git mv README README.md. Content untouched.README.md/README.rst/README.txt/ any suffix → leave alone. Provenance is captured in.nemar/metadata.json(IsDescribedBy/IsIdenticalTo) and the website surfaces it from there.Matches the user's stated rule: "README change only is to add the DOI tag up top and add .md to it, no content should be changed."
Bug 2: Enrichment self-triggered until manually stopped (#643)
Two issues composed into an infinite loop:
ENRICHMENT_TRIGGER_PATHS(backend/src/routes/webhooks.ts:1438) included.nemar/metadata.json— but that file IS the enrichment output, not an input. Each enrichment commit re-triggered enrichment.enrich-dataset.ts:419only fired atpipeline_stage === "validated". Foron007827Stage 3 never reached validated (cascaded from Bug 1 — the stub didn't substantiate the LLM's description claims), so the skip never engaged. Haiku 4.5's non-deterministic prose ensured.nemar/metadata.jsonlooked "changed" on every cycle.Fix:
.nemar/metadata.jsonfromENRICHMENT_TRIGGER_PATHS. Manual recovery is still available viaworkflow_dispatchonnemarDatasets/.github/run-enrichment.yml.pipeline_stage === "enriched"when sources are unchanged. Belt-and-suspenders against any future trigger that gets through.Stop-the-bleeding action
Run Enrichmentworkflow onnemarDatasets/.githubhas been disabled manually while this PR is in flight. After merge + deploy, I'll re-enable and queue a manualworkflow_dispatchfor on007827 once its README has been restored fromOpenNeuroDatasets/ds007827/README.Affected datasets
Only
on007827is currently in an active loop (51 commits in 1.5h before the workflow was disabled). The README-stub bug was introduced inb5b75c3(2026-05-18);on005261(imported same day) was unaffected because the bug had not yet shipped to npm. All earlieron*imports predate the bug.Test plan
bun test test/import-openneuro.test.ts— 32 pass (added 7 new tests forensureReadmeMdcovering README-no-ext, README.md, README.rst, README.txt, no-README, no-DOI, and idempotency)bun test test/webhook-github-push.test.ts— 40 pass (updated the test that asserted the buggy.nemar/metadata.jsondispatch; added new positive case for "README + metadata.json together still dispatches")bun test(full suite) — 1619 pass, 41 skip, 0 fail across 88 filesRun Enrichmentworkflow and confirm a singleworkflow_dispatchon on007827 with force=true (a) restores rich metadata from the real README, (b) commits exactly once, (c) does not re-fire.Follow-ups
OpenNeuroDatasets/ds007827/READMEbefore re-enrichment.on*datasets for stub READMEs that should be restored from upstream..nemar/metadata.jsonso a dataset that fails Stage 3 repeatedly surfaces in the dashboard rather than silently re-firing on the next source change.