Repository navigation
Phase 7: importer scrubs in place and waits for the screen - #1639
Merged
neuromechanist merged 18 commits intoOct 7, 2026
Merged
neuromechanist merged 18 commits into
neuromechanist merged 18 commits into
Conversation
The importer's JSON half of the scrub (ADR 0087): the rule of ADR 0085's history rewrite for one document, text-preserving, proven by a re-scan. Tested with unit cases and a parity check against blank_json; bun test test/identifier-scrub.test.ts passes.
Moves the provenance file and README sentences of ADR 0085's git plan to shared/ so the importer writes the same words (ADR 0087). No behavior change; build-git-plan and provenance suites pass.
Adds import-scrubbed to the corrective-action ledger's closed vocabulary, the line the importer writes when it scrubs a tree before its first push (ADR 0087). Typecheck passes; exercised by the importer tests.
gitAnnexAdd and normalizeUnannexedData take an optional SHA256E backend, which outranks an inherited annex.backend attribute; the import scrub uses it so a replaced recording's key is one ADR 0085's tools follow. Typecheck passes.
Prepare's step 5b now runs the identifier scrub (ADR 0087) before the annex-policy step: flagged EDF/BDF headers are downloaded, verified against their key, patched, annexed as SHA256E, uploaded and their old keys retired; identifier JSON values are blanked; images and documents are counted for review; a ledger line is committed. The copy manifest is cut to the committed tree minus dead keys, so a re-import cannot copy back a replaced key. Refusals carry a marker and a fixed word. test/import-scrub.test.ts (22 tests, real git-annex and an HTTP stand-in) passes.
Finalize requests publication, polls the screen state for a bounded time (45 min default, --screen-wait-minutes), approves only a clear verdict, re-runs a stale screen once, and otherwise leaves the request for an admin with a fixed outcome word (published, already-published, blocked, review, unchecked). A held publication is not an import failure. A scrub that left originals in history, or a manifest with no scrub record, is held for a person. test/import-finalize-screen.test.ts (14 tests, real finalizeImport against an API stand-in) passes.
Adds the identifier_scrub cause (label identifier-scrub) for the import scrub's marker, after upstream_inaccessible so a refusal OpenNeuro caused stays retryable by the upstream rule. The marker copies are pinned through a refusal the scrub really raised. backend import-failure-cause tests and the CLI pin test pass.
The deployed onboard workflow's finalize job times out at 90 minutes, and its copy here must stay byte-identical to the deployed one, so the wait for the identifier screen is cut to what the job has left (at most 45 minutes, at least 5). A test pins the constant to the workflow's timeout. onboard-workflow, finalize-screen and workflow-parity tests pass.
Records the Phase 7 decisions (#1618) and amends ADRs 0060, 0085 and 0086 with their build status. adr-index test passes.
Prepare has staged root metadata of its own before step 5b; the privacy-correction commit now names only the paths the scrub changed, so that metadata lands in the commit that describes it. Also replaces an invisible BOM literal. test/import-scrub.test.ts (23) passes.
Two cases no fixture reached: the replacement key is SHA256E when the tree's attributes now name another backend, and the manifest cut refuses a replaced key the tree still names. Both pass.
The git-held case kept a sidecar to blank, which set the history flag by itself, so a mutant that ignored git-held recordings survived. Without the sidecar the flag comes from the recording alone. Passes; the mutant is now killed.
The retry engine blocklisted only upstream-inaccessible rows, so a deterministic scrub refusal (bound-exceeded, already-imported-unscrubbed, unsupported-key-backend, old-key-still-named, scrub-unverified, retire-failed) was re-dispatched to refuse again. It is now parked as identifier_scrub_refused; the slow re-check still recovers a row completed another way. Review finding. import-retry and import-failure-cause tests pass.
Review findings on the import scrub (ADR 0087): a re-import carries the history hold from the ledger (a later history rewrite clears it, an unreadable ledger keeps it); a recording whose whereis URL is not S3 is read at that URL, as the curl fallback copies it; a closing check refuses any upstream recording in the manifest whose header this run did not read; a short or unsized header read is a failure; an empty recording is not read; other errors become scrub-failed or upload-failed naming only their class; staging is chunked and the commit takes a pathspec file; refusals say the copy did not run. 35 tests pass, real git-annex and an HTTP stand-in.
Review findings on the wait (ADR 0087): a history or no-scrub-record hold is written on the request through the deny route before any approval is asked for, and finalize fails loudly if it cannot be; the privacy record must be exactly version 1 with a boolean; a refused status read and a re-run that cannot start end the wait with their own reason; a sandbox exemption is not a reason to approve; an already-open request is waited on, and one being approved is not approved again. Prepare warns when a re-import could not fetch the git-annex branch, and counts provenance files it could not annotate. 21 finalize tests pass.
ADR 0087 now says which recordings are not read and why, the two new refusal words, the parked retries, the holds written on the request, the re-run of finalize, the residuals the review found, and that the importer's log states an outcome. Adds a .memory entry on the byte-pinned onboard workflow. adr-index test passes.
Contributor
Author
Review record (pre-PR, 2026-10-06)Two independent read-only reviews ran on the branch before it was pushed: Critical
Important
Suggestions
|
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1639Version: 🤖 Updated on each push. |
test/setup.ts points TEST_API_URL at a blocked address when there is no live target, and in a single-process bun test that reached this file, whose guard then refused all 21 cases. The file now points TEST_API_URL at its own server for its duration and restores it after. Passes with TEST_API_URL=http://127.0.0.1:1 set and without.
This was referenced Oct 7, 2026
neuromechanist
merged commit Oct 7, 2026
0e7ee1d
into
feature/issue-1610-epic-identifier-screening
13 checks passed
This was referenced Oct 7, 2026
Merged
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of epic #1610. Closes #1618. Decision: ADR 0089 (amends 0060, 0085 and 0086 with their build status). Design note: #1618 (comment)
An OpenNeuro import now scrubs the cloned tree in prepare, with ADR 0085's rules, before anything is copied or pushed. The copy manifest is cut to what the scrubbed tree names, so a re-import cannot copy back a key a correction replaced. Finalize waits for the identifier screen and approves only a clear verdict.
ADR number: #1635 (Phase 3) kept 0087 and #1636 (Phase 5) became 0088, so this branch's ADR is renumbered 0089.
What changed
src/lib/import-scrub.ts(new), prepare step 5b:scrubEdfHeaderchanges is downloaded whole, checked against its key (size and sha256), patched in the identification fields only, proven withverifyScrub, annexed as SHA256E and uploaded through ADR 0060's upload leg. Its old key is retired in the git-annex branch with ADR 0085'sannexRegistry.import-scrubbedledger line is committed, in a commit that names only the scrub's own paths.[nemar-identifier-scrub] refused: <word>with counts. The words areheader-unreadable,upstream-size-mismatch,bound-exceeded,content-mismatch,unsupported-key-backend,already-imported-unscrubbed,old-key-still-named,retire-failed,scrub-unverified,upload-failedandscrub-failed.restrictManifestToTree). Before this, a re-import reset ontoorigin/mainbut took its manifest from upstream's whereis.src/lib/import-publication.ts(new): finalize requests publication and polls the screen state. The wait is at most 45 minutes, cut to what the finalize job's 90-minute timeout leaves. It approves onlyclear, re-runs astalescreen once, and otherwise returns one ofpublished,already-published,blocked,revieworunchecked.shared/identifier-scrub.ts:blankIdentifierJsonKeys, the history rewrite'sblank_jsonrule for one document, parity-tested against the Python, proven by a re-scan.shared/privacy-correction-text.ts: the provenance sentences, moved from the git plan (no behavior change there).import-scrubbed. The importer'sscanneris a build-time digest of the rule files (src/lib/scanner-rules-digest.ts, a Bun macro), because it runs from the package, not a checkout.identifier_scrub(afterupstream_inaccessible); the retry engine parks refusals a retry cannot clear (identifier_scrub_refused).nemar admin import-openneuro --screen-wait-minutes;--normalize-max-gbnow also covers the scrub's downloads.Defaults for the maintainer to confirm
Rollout (not part of this PR)
test/dataset-workflow-parity.test.tsrequires it to match the deployed copy byte for byte. Raising finalize'stimeout-minutesin both copies, together withFINALIZE_JOB_TIMEOUT_MS, lets the full 45-minute wait apply.identifier-scrublabel does not exist onnemarDatasets/.githubyet.run-identifier-screen.ymlmust be merged innemarDatasets/.githubfor the screen to run. Until then every import endsunchecked, and nothing is approved automatically.Tests
test/import-scrub.test.ts(35): real git-annex repositories in an OpenNeuro clone's shape, atype=directoryremote fornemar-s3, and an HTTP stand-in for the upstream bucket. It drivesprepareImportedTreeForCopy, the one callprepareImportmakes, and covers:--skip-dataand the backend override;test/import-finalize-screen.test.ts(21): the realfinalizeImportagainst an API stand-in. It covers every screen state, inert states that only sound clean, a timeout, an unreadable or refused status, a missing view, the history and no-record holds and the deny they write, a malformed record, a hold that cannot be written, stale re-run once, a re-run that cannot start, an exempt state, an open request, an approval in progress, and an already public dataset.test/identifier-scrub.test.ts(the JSON rule, with byte parity againstblank_json),backend/test/import-failure-cause.test.ts,backend/test/import-retry.test.ts,test/onboard-workflow.test.ts(the wait budget pinned to the workflow's timeout),test/adr-index.unit.test.ts.HEADbefore the next. 66 killed. One is equivalent:setTopLevelString'sdepth === 1against>= 1, since the walker skips each member's value whole and never reaches depth 2. The closing check is not mutation-tested because it is unreachable once web-URL sources are read; it stays as a backstop. Not guarded by a fast test: the wait budget's fallback infinalizeImport(screenWaitBudgetwhen no--screen-wait-minutesis given), which needs a run of minutes; the budget itself is pinned to the workflow's timeout.