Skip to content

Phase 3: channel/montage backfill sweep (#859) - #862

Merged
neuromechanist merged 1 commit into
feature/issue-854-epic-channel-montagefrom
feature/issue-859-phase3-backfill
Jun 28, 2026
Merged

neuromechanist merged 1 commit into
feature/issue-854-epic-channel-montagefrom
feature/issue-859-phase3-backfill

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

One-time backfill of n_channels / electrode_system for existing EEG datasets.

  • Migration 0055 — channel_montage_checked_at resumability marker (mirrors archive_checked_at).
  • POST /admin/datasets/channel-montage-sweep?limit=N — candidates are repo-backed (nm*/on*), EEG (modalities LIKE '%eeg%'), non-sandbox, unchecked. Runs the Phase 2 getBidsTreeStats probe and writes the two columns directly — crucially not via writeDatasetMetadataColumns, so the backfill does not bump updated_at/metadata_updated_at (which would make every EEG dataset read "updated today" and jump the newest-first sort). Idempotent (marks each row checked, success or not), bounded per call (≤30) under the Worker subrequest cap.
  • scripts/backfill-channel-montage.sh — polls the endpoint until remaining reaches 0.

Running it (answers "does it need prod?")

The sweep writes whichever env's D1 the worker is bound to. The public site reads prod D1, so:

  1. Validate against dev first: NEMAR_API_BASE=<dev-worker> NEMAR_ADMIN_KEY=... ./scripts/backfill-channel-montage.sh --dry-run
  2. Then prod: NEMAR_ADMIN_KEY=... ./scripts/backfill-channel-montage.sh

Migrations 0054/0055 reach each env automatically on deploy.

Testing

  • test/channel-montage-sweep.unit.test.ts — applies the real migrations against in-memory SQLite, pins the candidate predicate (excludes no-repo/sandbox/non-eeg), and asserts the write sets the two columns + marker while leaving updated_at untouched, and converges (checked rows drop out). 4 tests.
  • root + backend tsc --noEmit green.

Closes #859. Part of epic #854.

Phase 3 of epic #854. One-time backfill for the columns added in
phase 1/2 across existing EEG datasets:

- migration 0055 adds channel_montage_checked_at (resumability
  marker, mirrors archive_checked_at).
- POST /admin/datasets/channel-montage-sweep?limit=N: candidates are
  repo-backed (nm*/on*), EEG, non-sandbox, unchecked rows. Runs the
  phase-2 getBidsTreeStats probe and writes n_channels +
  electrode_system DIRECTLY (no updated_at bump, so the backfill
  doesn't re-sort every EEG dataset to "newest"). Idempotent;
  bounded per call (<=30) under the Worker subrequest cap.
- scripts/backfill-channel-montage.sh drives it until remaining=0.

Real-SQLite test applies migrations 0054+0055 and pins the candidate
scoping + the no-updated_at-bump write.

Closes #859. Part of #854.
@neuromechanist
neuromechanist merged commit 0b70fc3 into feature/issue-854-epic-channel-montage Jun 28, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-859-phase3-backfill branch June 28, 2026 21:47

This branch was previously deployed

1 inactive deployment
npm — 95a784af Deployed Jun 28, 2026 by neuromechanist via publish #1613
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.

1 participant