Skip to content

Re-import Step 4c: add upstream drift-detection guard (same-version assumption) #993

Open

Description

@neuromechanist

Fast-follow to #990 (epic #989 Phase 2). Step 4c in src/lib/import-openneuro.ts resets a re-import's local main onto origin/main so the metadata seed + push fast-forwards. It assumes the re-import is the SAME dataset version as the first import (the #967 recovery case: re-copy empty S3 data for a version already imported once).

If OpenNeuro published a genuinely NEW snapshot between the first import and the retry, bidsDesc/openNeuroDoi (read from the fresh clone before Step 4c) reflect the NEWER content, but Step 6 commits that metadata on top of origin/main's OLDER (reset-restored) tree. Net effect is orphaned S3 copies (the copy-phase manifest references keys not pointed to by any file in the pushed tree) rather than tree corruption. Today this is a comment-only contract: nothing loudly fails if the assumption is violated.

Bounded in practice: prepareImport is only re-entered via the admin-triggered import retry / sharded-CI-workflow path (auto-import cron is disabled since #967), so the window is deliberate recovery ops on datasets flagged for a data-only re-copy. But a cheap loud guard would be safer than a silent reset.

Proposed: before trusting the Step 4c reset, compare a content/version fingerprint (e.g. the upstream default-branch SHA, or a hash of dataset_description.json) between the fresh clone and origin/main; if they differ, refuse the silent reset and fail loud (this is a new-version import, out of the recovery path's scope). Low-risk, no migration.

Found in the Phase 2 code review; explicitly deferred as a fast-follow rather than blocking #990.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions