Skip to content

Phase 3: QA artifact sync from hallu + data.nemar.org/<id>/qa/* route (#511) - #517

Merged
neuromechanist merged 2 commits into
feature/issue-514-epic-website-followupsfrom
feature/issue-511-phase3-qa-sync
May 16, 2026
Merged

neuromechanist merged 2 commits into
feature/issue-514-epic-website-followupsfrom
feature/issue-511-phase3-qa-sync

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Closes #511. Phase 3 of epic #514.

Summary

Two pieces in one PR — sync producer + Worker consumer:

scripts/hallu-qa-sync.sh

Mirrors /data/qumulo/openneuro/processed/<id>/ → s3://nemar/<id>/qa/ for every nm*/on* dataset present on hallu.

  • Cron: 15 * * * * (offset 15 min from the bytes sync at 0 * * * * so the two jobs don't compete for the same flock).
  • Excludes pipeline internals (code/, logs/, *.mat, dotfiles, backup files).
  • Idempotent via newest-mtime fingerprint stored in /data/qumulo/openneuro/.nm-qa-sync-manifest.json. Datasets with unchanged trees skip the aws s3 sync call entirely.
  • Manual: ./scripts/hallu-qa-sync.sh --dataset nm000132 --verbose.
  • Shellcheck clean.

Worker route: GET data.nemar.org/<id>/qa/*

New route in backend/src/routes/data.ts, registered BEFORE /:datasetId/:version/* so Hono doesn't match qa as a version param.

  • 302 to a presigned S3 GET for files (the QA tree's keys are already BIDS-shaped, so no Content-Disposition override is needed; that fix in data.nemar.org file downloads return SHA-named files instead of BIDS-shaped filenames #513 only applies to annex-keyed dataset files).
  • Directory listings: JSON or HTML based on Accept / ?format=. Reuses renderIndexHtml.
  • Visibility gate identical to the version route — private/unknown datasets 404 with no leak.
  • Cache-Control: public, max-age=300.
  • HEAD support mirrors the version-route semantics (200 with metadata headers, no presign round-trip) so rclone sync :http:... can size+mtime+ETag cheaply.

Supporting helpers

  • backend/src/services/s3.ts: new listObjectsWithDelimiter(prefix) helper for one-level S3 listing (single round-trip). Returns { contents, commonPrefixes, truncated }.
  • backend/src/services/data-router.ts: new resolveQaPath() async resolver + pure qaListingToDirectory() helper for shaping S3 results into DirectoryEntry[]. The pure half is exported so the file/dir partitioning matrix is unit-testable without an S3 round-trip. normalizeBidsPath() is now exported and reused so both routes share one traversal-rejection contract.

Test plan

  • bun test test/data-route.unit.test.ts → 109 pass / 0 fail
  • Backend tsc --noEmit passes
  • bash -n + shellcheck clean on the sync script
  • After deploy: aws s3 ls s3://nemar/<live-id>/qa/ shows the synced tree
  • After deploy: curl https://data.nemar.org/<live-id>/qa/dataqual.json → 302 → JSON content with BIDS-shaped filename in the response
  • After deploy: curl -H 'Accept: text/html' https://data.nemar.org/<live-id>/qa/ returns a directory listing
  • After deploy: curl https://data.nemar.org/<private-id>/qa/anything → 404, no existence leak
  • After deploy: install cron entry on hallu, watch one tick complete in the log

Notes

  • The QA tree is NOT version-locked (reflects whichever pipeline run last published). Phase 3 punts per-version QA per the issue's "out of scope" line. If/when needed, adding a qa/<v>/ sub-prefix is non-breaking.
  • HED summary endpoint (issue mentioned as "Optional") not included — metadata.json already surfaces hed_summary via the existing data-router path.

This is Phase 3 of 4. Next: Phase 4 (#503, publisher canary for git: refs).

Companion to hallu-sync.sh that mirrors /data/qumulo/openneuro/processed/<id>/ to s3://nemar/<id>/qa/ on an hourly cron (offset 15 min from the bytes sync). Skips pipeline internals (code/, logs/, *.mat) and uses a newest-mtime fingerprint to skip unchanged datasets idempotently.

Worker route exposes the tree at data.nemar.org/<id>/qa/*: 302 to a presigned S3 GET for files (whose keys are already BIDS-shaped, so no Content-Disposition override is needed), directory listings with the same JSON / HTML content negotiation as the version route, and the visibility gate that suppresses any leak for private/unknown datasets. resolveQaPath uses ListObjectsV2 with delimiter=/ to distinguish files from directories in a single round-trip and rejects path traversal via the same normalizeBidsPath contract the manifest-backed route uses.
@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR517

Version: 0.8.18-PR517.3170ce8
Commit: 3170ce8


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit b04f342 into feature/issue-514-epic-website-followups May 16, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-511-phase3-qa-sync branch May 18, 2026 11:10

This branch was previously deployed

1 inactive deployment
npm — 3170ce88 Deployed May 16, 2026 by neuromechanist via publish #936
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