Repository navigation
Phase 3: uploader-side identifier preflight - #1635
Merged
neuromechanist merged 21 commits intoOct 7, 2026
Merged
neuromechanist merged 21 commits into
neuromechanist merged 21 commits into
Conversation
Split the report parser's scan body from its identity check, name each state's verdict once with the count lines in one helper, move the format and failure folds into the contract module (re-exported by the CI lib), and export the local-read byte limits from the fleet lib. No behavior change. Tested: identifier report, CI screen, fleet and scan suites (332 pass).
UploaderPreflight is the scan an uploader's CLI made before sending anything, parsed at the door like the publication report: closed kinds, counts and fixed words, no dataset identity, every field required, a status no cleaner than its counts, and an acknowledgment (prompt or flag, never text) present exactly when the gate needs one. describePreflight says each verdict in the screen's own words. Tested: preflight contract (19) and report (26) suites.
Screens a dataset directory on the uploader's machine with the fleet scan's clone-source scan (every EDF/BDF header, 256 bytes; side files at the publication screen's limits), counting unlistable directories, broken links and special files as unread. Direct identifiers refuse; lesser verdicts need a prompt or a flag naming the verdict; --dry-run previews. Tested: 25 step tests on real trees (links, FIFO, sparse 8 GiB file, 24,001 files in about a second).
createOrResumeDataset sends identifier_preflight beside the attestation on create, and on a resume from the local config (which never reached the create route, so its attestation was dropped) records both through PUT /datasets/:id/attestation. A record the backend did not store is always a warning, never a refusal. Tested on the wire against a Bun stand-in (8); api export pin updated (recordDepositAttestation).
nemar dataset upload (and nemar upload) runs the preflight after the account checks and before the tool checks, validation, the ORCID step and the create call, so a refusal sends nothing. New option --acknowledge-identifier-preflight <verdict>, limited to the gate's acknowledge set; help text says what is read and what is printed. Tested: 7 subprocess runs that end at the preflight (no request beyond GETs, no .git created, no name or path in the output, offline too).
POST /datasets and the new PUT /datasets/:id/attestation (owner or admin, private and never published) store identifier_preflight inside the attestation JSON after the report contract parses it. A refused record is not stored, never fails the request, and is named by a fixed word; the detail route serves none of it. readRecordedPreflight reads it back as recorded, absent or unreadable. Tested: 13 route tests on real D1; route inventory pin updated (62 entries).
Local screen before anything is sent, the publication screen's scan and words, no override for direct identifiers, a verdict-bound acknowledgment with no free text, recorded inside the attestation and never trusted. Tested: adr-index (passes).
For MNE-BIDS and MOABB, counts only, naming no dataset or source, with what the maintainer must check before anything is filed. Nothing was filed. Not tested (prose).
Serialize the attestation (with its preflight) once per create, so the resume UPDATE and the claim INSERT cannot differ, and keep the PUT route's publication guard in its UPDATE alone, where the 409 tests can see it. Adds a preflightRecording unit test. Tested: preflight route (14), attestation endpoint and detail contract suites.
The subprocess tests stop at the preflight by design, so a source pin covers the one hop they cannot: the action passes the step's record to createOrResumeDataset, after the step runs first. Tested: passes; fails when the argument is dropped.
bun:test does not run a cleanup returned from beforeEach, so every case left two directories behind. Tested: the three preflight suites (41 pass) leave nothing in TMPDIR.
formatCoverage takes a format name from the file name, so a file like sourcedata/Smith.John reads as .john. The preflight now keeps only names on KNOWN_FORMATS (the scanner's own lists plus BIDS extensions), folds the rest into .other, and its parser refuses any other name. The publication report is unchanged. Tested: contract (22).
A non-ReportError from the parser is still refused as preflight-shape, and is now logged by error class (never the message). Adds a fresh create test that reads the claim INSERT's attestation. Tested: route suite (15).
One warning call after create for both answers, so neither branch can drop it; separate words for a failed request, a refusal, a server that could not store it, and one that predates the field; a resume with a preflight and no attestation now says so. The wire test names its stand-in in the config file, so it runs in the pure CI tier. Tested: wire suite (10).
From the PR review: walk a directory named .gitattributes (find still lists its files) and any directory the listing does not type; bind an acknowledgment to every condition found (the verdict plus unchecked and not-screened when review hides them), repeatable or comma-separated and exact; screen again right before the create call and send that scan; refuse a dataset path that is not a directory; exit 130 on Ctrl+C at the prompt; deliberate refusals skip the bug-report nudge. CLI tests run in the pure tier, past the preflight with no tools on PATH, and at a real pseudo-terminal. Tested: step (39), CLI (13).
Records the condition-bound acknowledgment, the second screen before create, the closed format list and what a dry run still does. The converter draft leaves its counts as placeholders until the fleet re-run. Tested: adr-index (passes).
Pins that a symlink to a directory is listed and not walked, and that a dataset path that is a file is refused even with the acknowledgment an unlistable tree would need. Tested: step suite (40).
Covers the case the record contract cannot catch on its own: an acknowledged scan that gains a condition still parses, so only the recheck's comparison stops it. Tested: step suite (41); reverting the comparison now fails it.
A live-tier file earlier in the same process sets the test-tier API override and keeps it, which the client prefers to the config file. The wire test sets such overrides aside for its run and restores them, and still fails closed if the client would go anywhere but its stand-in. Tested: alone (10) and after identifier-screen-callback-token (19).
Contributor
Author
Review recordTwo independent reviews ran on the branch before the review-fix commits: Sonnet code-reviewer and Sonnet silent-failure-hunter. Both were briefed that this check decides whether a person's name leaves a machine, and to weigh silent failures and vacuous tests heavily. Neither found a critical issue: no path where a direct identifier or an incomplete scan lets the upload proceed without the stated acknowledgment, and none where content is sent before the verdict. Every finding is listed below with what was done about it. Fixed
Not changed, with the reason
Process note
|
readdir order is the filesystem's: CI's ext4 listed .eeg before .vhdr where APFS did not, so the printed counts came out in a different order and unit-pure failed. Children are sorted and subdirectories walked in that order, so a tree gives the same record and words everywhere. Tested: step (42) and CLI (13) suites; a walk-order test.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1635Version: 🤖 Updated on each push. |
13 tasks done
Contributor
Author
CI and full-suite record
|
This was referenced Oct 7, 2026
…er-screening' into feature/issue-1613-phase3-upload-preflight
neuromechanist
merged commit Oct 7, 2026
8c6a477
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.
Phase 3 of epic #1610 (issue #1613): the identifier preflight that runs on the uploader's machine.
The decision is recorded in ADR 0087.
Design note: #1613 (comment)
Part of #1613. This does not close the issue: the converter request is a draft for the maintainer to send.
What it does
nemar dataset upload(andnemar upload) screens the dataset after the account checks, and before the tool checks, BIDS validation, the co-author ORCID step and the create call. A refusal therefore sends nothing. The preflight reads local files only and makes no network request.scanDatasetFromManifestwith theclonesource, which is what the publication screen uses, through a local reader:LOCAL_SCAN_LIMITS, one definition now shared with the CI screen.tree-truncated;.gitattributesis walked, because the plan'sfindlists its files.direct-identifiers: the upload is refused, also under--dry-run. There is no override.uncheckedwhen the scan is incomplete, plusnot-screenedwhen some recordings are in formats the scanner cannot read.--acknowledge-identifier-preflight. The flag is repeatable or comma-separated, and its list must match the conditions exactly.--yesnever acknowledges, and--dry-runnever prompts.describePreflight), and no value or path. Format names come only from a closed list (KNOWN_FORMATS); anything else is printed and stored as.other.identifier_preflightinside thedatasets.attestationJSON, so no new column is needed.parseUploaderPreflightis the door: closed kinds, counts and fixed words, no dataset identity, and every field required. It refuses a status cleaner than its counts. It requires an acknowledgment (promptorflag, never free text) exactly when the gate needs one.PUT /datasets/:id/attestation(owner or admin, private and never published). Before this, that path dropped the attestation.readRecordedPreflightreads it back as recorded, absent or unreadable..context/draft-converter-subject-info-request.md. Its counts are placeholders until the fleet re-run, it names no dataset or source, and it carries a checklist for the maintainer. Nothing was filed.Tests
test/identifier-preflight-contract.test.ts(22): the preflight record contract, including the closed format list.test/upload-identifier-preflight.test.ts(42): the step, on real trees, walked in name order so output is the same on every filesystem:reviewhides, and the recheck;test/upload-identifier-preflight-cli.test.ts(13): real subprocess runs.--yes,--no, and offline.y, and Ctrl+C..gitcreated, and no name or path in the output.test/upload-preflight-recording.test.ts(10): the wire, on create and on local resume, and each warning cause.backend/test/identifier-preflight-route.test.ts(15) on real D1, including the fresh create's claimINSERT.TEST_variable from the child process.git statusclean after each.bun run typecheckand biome on every changed source file.backend/test/neurobagel-writer.test.ts). They time out at 5 s under concurrent load, and pass when run alone. Second run: 10,914 pass and 7 fail, all in untouched files (see the CI comment).Review
Two Sonnet reviews ran: code-reviewer and silent-failure-hunter. Findings and their disposition are in the comment below.
For the maintainer
These were defaulted to the stricter reading:
--dry-run;uncheckedcan be acknowledged, as at the admin gate;Not covered (ADR 0087, Consequences):
review.