Repository navigation
Phase: a pending publication request is a state, not an error - #1678
Merged
neuromechanist merged 37 commits intoOct 8, 2026
Merged
neuromechanist merged 37 commits into
neuromechanist merged 37 commits into
Conversation
Right after an upload, 'nemar dataset publish request' is refused with
block_reason bids_validation_pending ('BIDS validation has not run yet') or
bids_validation_in_progress. The request IS recorded as blocked and a daily
sweep clears it once CI is green, but the CLI exited 1 with only
're-request publication', so scripted uploads (the iEEG campaign lanes)
wrapped the command in their own retry loops.
- Without --wait: a CI-pending refusal says the request is recorded and
re-checked automatically, and names '--wait' and 'nemar dataset ci <id>'.
- --wait [minutes] (default 30, max 24 h) re-requests every minute while,
and only while, CI has not concluded; a validation failure or any other
refusal is reported at once. Re-requesting updates the one blocked row
server-side; admins are notified only when the request is accepted.
The CLI no longer re-requests on a timer. A depositor follows CI with 'nemar dataset ci <id>' and requests again, or leaves the recorded request to the server's sweep. Keeps the CI-pending predicate and hint; drops the interval, clock and sleep plumbing and the tests that existed only for it.
publicationRequestNotice gains one sentence: 'You will be emailed if a check needs your attention, and when an administrator decides.' It promises only mail the requester gets: the identifier screen's blocked mail, and the approval and denial mails. A clean screen mails the admins, so nothing says the requester hears when the checks complete. The tests that pin the notice are changed deliberately, not loosened: test/identifier-screen-report.test.ts (wording, varying part, one-place-only phrases), backend/test/identifier-screen-flow.test.ts (request_notice) and test/identifier-screen-cli.test.ts (printed lines, now five). ADR 0090 gets an amendment.
A publication request made before BIDS validation has concluded is recorded and continues on its own once validation passes, so the CLI reports it in the info style and exits 0 instead of printing a failure and exiting 1 (issue #1646). The headline tells 'has not started yet' from 'is still running'; the lines after it promise no time and name 'nemar dataset ci <id>'. An anonymous depositor is handed --anonymous back in the command to run again, because a re-request restates the flag, and an anonymous request the server did not echo as anonymous is warned about. Every other refusal (validation failed, minimums, 409, 403, identifier findings, a 5xx) keeps its text and exits 1. The help text says validation must complete first. Tests spawn the real CLI against a local stand-in server. ADR 0086 gets an amendment.
printUploadSuccess now says BIDS validation runs on GitHub after the upload, how to follow it ('nemar dataset ci <id>') and that publication is requested once it has completed ('nemar dataset publish request <id>'). A sandbox (xx) dataset is not told to request publication, since the backend refuses it. Issue #1646.
The pending-state CLI test invented a docs.nemar.org page, which test/docs-links.unit.test.ts rightly could not resolve. It now imports SUBMISSION_POLICY_URL from the backend.
Backend. A request made while BIDS validation is pending or running skipped the ADR 0026 submission minimums and the ADR 0065 anonymity blind check, and the blocked-request sweep released it without evaluating either. A request right after an upload is nearly always pending, so the sweep was the default path and a named depositor could be released under the blind label, which cannot be undone. The check moves into one function, checkSubmissionGate, that the request route and the sweep both call. The route now runs it when CI is the only block (a missing minimum is answered at once as min_requirements_failed with its reasons, and a re-request re-records the verdict instead of erasing it); not when CI failed, the owner has no name, or the readiness check itself could not run. The sweep runs it before releasing a request: a failing one is re-blocked as min_requirements_failed, an anonymous blind that could not be read waits for the next run. OpenNeuro imports and exemplars keep their exemption except for an anonymous request. backend/test/anonymity-publication-paths.test.ts pinned the gate's source text in the route; the two source pins now follow it to submission-gate.ts. The behavior is driven through the real route and the real sweep in backend/test/publish-request-ci-pending.test.ts. ADR 0086's amendment now says what the sweep checks.
Backend. The readiness check mapped any exception (token, workflow deploy, GitHub outage, expired PAT) to bids_validation_pending, byte-identical to 'no run yet', so a depositor was told the request was recorded and would continue when the sweep, which makes the same GitHub calls, may never move it. The row is still written, but the route now answers 503 with error ci_check_unavailable and a message, no block_reason and no status, so nothing reads it as pending. The shared block-reason vocabulary is unchanged; a distinct block reason with a website sync is left as a follow-up. ADR 0086 amendment updated.
Backend. The bids_validation_pending and bids_validation_in_progress messages still told the depositor to 're-request publication', which contradicts a request that is recorded and continues on its own. They now say so. 'BIDS validation is currently running' stays in the in-progress message verbatim because src/lib/exemplar-clone.ts and src/lib/import-openneuro.ts decide to keep waiting by matching that substring; a test pins it, and pins its absence from the pending message. The failed, minimums and other messages are unchanged.
Backend tests. publish-request-ci-pending.test.ts gains the exact key sets of the pending, minimums, owner-name, already-open (409) and not-owner (403) bodies from the real route, so the CLI test's stand-in server cannot drift from them. requester-mail-recipients.test.ts checks the recipients the new request notice promises: a denial goes to requested_by, an approval to the dataset owner, with the two being different people so a swap of columns fails.
CLI. The hint now opens with 'Your request is recorded.' (the headline is on stderr and the hint on stdout, so a caller that drops stderr still reads that a request exists), says to check validation with 'nemar dataset ci <id>', that a repeat request may answer 'already exists' and need nothing more, and that a failed validation leaves the request blocked with no mail. The CI link the refusal carries is printed. isCiPendingBlock also requires the body to say status: blocked. The client leads with the message of a ci_check_unavailable 503, not the bare code. An anonymous request whose server echo is not exactly true now prints the warning and exits 1 on both the pending path and the accepted path (the accepted-path warning predates this change and exited 0). The command to run again takes its --anonymous from what was typed, never from the echo. The detailed help says what a request made before validation has completed does. Tests: the stand-in bodies carry the key sets the real route sends and the 409 and 403 bodies are the real ones; the identifier-finding case, which the route never returns, is gone. The harness moves to test/helpers/pending-cli.ts and the child gets a dead proxy with loopback exempt.
CLI. publish status printed a request waiting on BIDS validation as a red 'Blocked:' followed by the server's 'then re-request publication', and a dim 'run publish request <id> to retry now' without --anonymous, which for an anonymous request converts a blind request into a named one (the backend resets the flag on every request). A request blocked only on validation is now shown the way publish request shows it: an info line that tells not started from running, the same hint (the command to run again carries --anonymous for an anonymous request) and the CI link. It prints no identifier-screen block, because the screen starts only when the request is released and the backend would word its absence as 'NOT RUN for this request' in red. Every other blocked reason stays a red block, and the retry command it prints now keeps --anonymous too.
CLI. deployCiStep returned nothing, so the success output said BIDS validation runs after the upload and sent the user to 'nemar dataset ci' even when the upload could not set CI up (an owner is refused by the admin-only route, and the only code that deploys CI for an owner is the publication request itself). deployCiStep now returns configured, not-configured or unknown (a resumed upload whose CI step an earlier run completed), and printUploadSuccess says 'CI is set up when you request publication' when it was not configured. A sandbox (xx) dataset keeps only the lines that do not name a publication request. 'Follow' becomes 'Check' and 'completed' becomes 'passed', since a completed run can have failed.
Backend test. The bodies the CLI tests answer with (test/helpers/pending-cli.ts) are compared field for field with what the real route sends for a pending, in-progress, failed, owner-name and ci_check_unavailable refusal, and by key set for the minimums, accepted and status bodies. A drift in either side now fails here instead of leaving the CLI tests green against a body the Worker no longer sends.
Backend test. identifier-screen-flow.test.ts asserted that a publication request with no GitHub credential is answered 422, because the readiness check that cannot run was reported as pending. It is answered 503 ci_check_unavailable now (the request is still recorded and blocked), so the case asserts that.
test/publish-anonymous-cli.test.ts predates the exit-1 rule for an anonymous release the server did not confirm: its body test answered without the confirmation and expected exit 0, and the two warning cases did not look at the exit code. The body test now gets the confirmation a real backend sends and the warning cases assert exit 1.
A request blocked for a reason other than pending validation still shows its identifier screen in publish status; only a request waiting on validation leaves it out. Closes a surviving mutant that hid the block for every blocked request.
ADR 0086 amendment: the sweep cadence is stated with its caps and kept out of the decision, the identifier-finding claim is corrected (the request route never returns it; a finding blocks later), the reason a CLI loop is rejected is given, and history phrasing is gone. ADR 0090 amendment: the notice has five lines. The README index lines for both mention their amendments.
Comments only. Five code references and two test names cited 'ADR 0090, amendment 2026-10-07', but ADR 0090 now has three amendments dated 2026-10-07; they cite the one by its title. The publicationRequestNotice docblock no longer claims that nothing else in the repository spells the sentences (tests and ADR 0090 quote them); it says that no other source file does and that a test enforces it. A backend test comment states what the message must not say instead of what it used to say.
The blocked-request sweep runs from the 03:00 UTC scheduled cleanup in production (backend/wrangler-sccn.toml).
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1678Version: 🤖 Updated on each push. |
The two block reasons that only say validation has not concluded were spelled three times: a Set in the CLI, an inline pair in the request route and a list in the sweep. They are now CI_PENDING_BLOCK_REASONS, CiPendingReason and isCiPendingReason in shared/contract/publication.ts, which the CLI re-exports, the route calls and the sweep spreads into its candidate list. The block-reason vocabulary itself is unchanged. No behavior change.
Backend, comments and one condition. CI_CHECK_UNAVAILABLE_MESSAGE and its doc block sat between the BLOCK_MESSAGES doc block and BLOCK_MESSAGES; the message moves above both. The 503 branch tests ciCheckFailed alone, since it is only ever set together with blocked. The comment above the minimums call keeps the route-specific rule (when it runs) and points at checkSubmissionGate for the rest instead of restating it. No behavior change.
Backend. The dataset_description.json read and the README loop shared one try, so a README that could not be read took the whole gate with it: a 0-byte README.md (GitHub answers base64 with empty content, which getFileContent threw on) made a native request fail open, so Name, Authors and ethics were never checked and the sweep released it, and an anonymous request stayed unverified forever, a permanent daily error in the sweep. The README is now read only when EthicsApprovals lists no approval (the one rule it can change) and a README that cannot be read counts as one with no statement, so it never takes the Authors rule with it. getFileContent returns the empty string for a zero-byte base64 file. A description that cannot be read is 'unverified' for everyone; the route keeps its policy (an anonymous release is blocked, a native submission goes on to the admin review) and the sweep defers the row, so a native request whose description cannot be read is no longer released by the sweep.
Backend. The sweep's submission-gate reads used the default GitHub policy: below 50 remaining requests a read sleeps up to 60 s before it goes out, and a 5xx or 429 retries with Retry-After up to 60 s, so one row measured 3 s with a bucket that resets in 3 s and a batch of rows could stall a scheduled invocation. Gate-blocked and unverified rows do not count toward the 10-unblock cap, so 50 rows with no README made about 300 requests. getFileContent takes a retry policy and the sweep passes LOOKUP_ONCE (interactive kind, one attempt, the policy branchExists already uses for the same reason). Any read that fails in the sweep, native or anonymous, defers the row to the next run and counts it as an error: a daily batch loses a day by waiting, and a verdict from a partial look is worse. The gate's reads share a budget across the sweep (MAX_GATE_READS_PER_SWEEP, 100, a parameter for tests); once it is spent the rows not yet evaluated are left untouched and counted in the tally as deferred, with the number of reads made as gateReads, and the cron log line says deferred. The route keeps its policy.
Backend. The sweep checked the budget before calling the gate, and the gate checks it before every read, so the first check was redundant for a row that needs reads and wrong for one that needs none: an exempt dataset was held back by a spent budget though the gate would have cleared it without reading. The sweep no longer checks; a test releases an exempt row with the budget at zero.
Backend. The sweep reads its candidate rows, spends GitHub calls on each, and writes afterwards, with only status = 'blocked' to guard the write. A request made again in between (a native pending row re-requested with --anonymous while the file still names the depositor) is still blocked, so the sweep released it on a verdict reached for the native row and ended with anonymous = 1, no block reason and stale reasons: a named depositor under the blind label, which ADR 0065 says cannot be undone. All three writes (release, minimums re-block, failing-validation relabel) are now conditional on the row being as it was read: status, anonymous, block_reason and updated_at, with IS so a NULL compares. A write that finds the row changed is left undone and counted as skipped, not released and not an error. The release also clears min_requirements_reasons, as the route does. The tests make the real route request mid-run from inside the GitHub stand-in, and change each of the three columns alone for each of the three writes.
Backend test. A denial leaves block_reason and anonymous as they were and, within the same second, updated_at, so only the status term of the sweep's write condition can see it; the per-column race cases did not include it, and removing the term left them green. The three writes now have a case that changes status alone.
Backend. The sweep takes candidates oldest updated_at first, 50 at a time, and a row it looked at and left as it was (CI still running, a file that could not be read, a CI lookup that failed, a dataset with no repository, a request already labelled as failing) kept its old updated_at, so 50 of them filled every run and nothing behind them was ever reached. Those rows are now moved to the back of the queue by stamping updated_at, under the same condition as the other writes. Rows it did not look at (over the unblock cap, or deferred by the read budget) are left where they are so the next run starts with them.
Backend test. Moving a looked-at row to the back of the sweep's queue writes updated_at under the same condition as the sweep's other writes; a row that a concurrent request changed in between is left alone. Removing the condition left the suite green.
Comment and ADR 0086. The route comment and the ADR said the sweep 'makes the same calls' and would fail the same way. It does not: it reads the run list with the same credential and recovers when GitHub does, but it does not deploy the workflow, so a request recorded after a failed deploy waits for a run nothing starts. They now say that, and that the row keeps the pending reason so publish status still shows it as waiting on validation; telling the two apart would take a stored marker and stays a follow-up.
The pending hint told the depositor that a failed validation leaves the request blocked with nothing emailed, but not that a submission minimum failing when the sweep goes to release it does the same: the sweep re-blocks the request as min_requirements_failed and mails nobody. The hint and ADR 0086 say so, and ADR 0026's Consequences, which said the gate runs only on publication requests, point at the amendment that has the sweep run it too.
CLI, no behavior change. The status handler tested isCiPendingReason twice, once only to narrow the type, and built the retry command outside the only branch that uses it. The pending reason is computed once, narrowed, and used for both the screen suppression and the info branch; the retry command moves into the red branch.
The two pending-output CLI test files repeated the same stand-in setup, reset hooks and spawn helpers, and the stand-in repeated its own defaults again. usePendingCliHarness() owns the stand-in, its reset (now a method on it), the per-test config directory and the default timeout for a file, so the 33 per-test timeout arguments go (the two tests that run twice keep an explicit one). pendingStdout() is the repeated expectation of what a pending request prints. spawnBun() is split out of spawnCli so the upload test's subprocess reuses the config directory, the environment scrub, the dead proxy and the signal check instead of repeating them. Behavior of the tests is unchanged and every earlier mutation stays killed.
Rename describe_ to descriptionJson (it took a new ethics parameter in the same change), loop over cases.entries() instead of recomputing an index, and cut the 503 tests to what the field-for-field body pin does not already say: the status, the error code and the recorded row. The test that the body has no block reason is the pin's toEqual.
ADR 0086 amendment. The README is read only when no approval is listed and never takes the other rules with it; the route and the sweep differ on a description they cannot read (the route's policy, the sweep defers); the sweep's reads never sleep, share a budget and give no verdict from a partial look; every write is conditional on the row as read; rows looked at and left move to the back.
Contributor
Author
Review recordTwo passes of the PR review toolkit (Sonnet agents): code review, test analysis, silent-failure hunt, comment analysis and a propose-only simplifier on the CLI redesign; then a second focused review of the backend code that the first round added, and a second simplifier on the whole PR. Every finding below was fixed unless it is listed under "Not done". Tip at the time of writing: Critical
Important
Suggestions and nice-to-have (all applied)
Verification
Not done (tracked follow-ups)
|
The services/github export-surface pin deliberately excludes symbols that exist for cross-module wiring; LOOKUP_ONCE is only used by the submission gate, so it is imported from its module, as branchExists already is. unit-pure failed on the extra runtime export; the pin is unchanged.
neuromechanist
merged commit Oct 8, 2026
f87b1fa
into
feature/issue-1671-epic-bru-upload-fixes
18 checks passed
This was referenced Oct 8, 2026
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.
Summary
Right after an upload,
nemar dataset publish request <id>is refused with block reasonbids_validation_pendingorbids_validation_in_progressbecause the BIDS validation run has not started or finished.The backend records the request as blocked and a sweep continues it once CI passes, but the CLI printed "re-request publication" and exited 1, so a depositor concluded the request had been rejected and scripted uploads wrapped the command in their own retry loops (issue #1646).
A CI-pending refusal is now reported as a pending state with exit 0, and the user checks CI with the command that already exists,
nemar dataset ci <id>.The first commit is the contributor's original change (PR #1652, bruAristimunha), preserved with authorship.
A client-side
--waitloop was rejected in review: the server already records the request and owns the transition, and every re-request repeats the GitHub readiness check and rewrites the row once a minute for up to 24 hours per waiting client.What is kept from the contributor's work: recognizing the two CI-pending block reasons (
isCiPendingBlock), the hint helper and their tests, insrc/lib/publish-pending.ts(renamed frompublish-wait.ts).The commits on top fall in three groups.
CLI
--wait, the retry loop and the polling plumbing are removednemar dataset ci <id>), that a re-run after the request moved on answers "a request already exists, nothing more is needed", and that a failed validation or a missing submission minimum leaves the request blocked with nothing emailed; the CI link from the response is printedbids_validation_failed,min_requirements_failed, 409, 403, an owner name missing, an unknown reason) is unchanged and still exits 1publish statusshows a waiting request in the same info style (it printed a red "Blocked: ... then re-request publication"), with a hint that keeps--anonymousfor an anonymous request--anonymousrequest whose response does not confirm anonymity now exits 1 on both the pending and the accepted path (the accepted-path warning predates this PR and exited 0); the hint's--anonymouscomes from the flag that was typed, never from the server's echo, because a re-request resetsanonymousto what the flag says and "run it again" would otherwise turn a blind request into a named onexxdatasets get no publish line;deployCiStepnow returns its outcomepublish request --help-allgained two lines on the same flowBackend (separate commits, droppable)
--anonymous, the blind check now apply to a request that is only blocked on CI, through one shared function (checkSubmissionGate) used by both the request route and the sweep: before this change a CI-pending request skipped them in the route and the sweep released it without them, and a request right after an upload is nearly always pending; a missing minimum is answered at once asmin_requirements_failedwith its reasons; the sweep re-blocks a request that fails the gate, and an anonymous blind that cannot be read is never releasedupdated_at): without that, a concurrentrequest --anonymouscould be overtaken and the row released withanonymous=1while Authors still named the depositor (ADR 0065: irreversible); a lost race counts asskipped; a real race is testedci_check_unavailableinstead of a 422 identical to "no run yet", so the CLI reports an error rather than "recorded, will continue"; the block-reason vocabulary is unchangedexemplar-clone.tsandimport-openneuro.tsmatch)shared/contract/publication.ts(CI_PENDING_BLOCK_REASONS,isCiPendingReason); two additive exports, the vocabulary schema is unchangedDocs
Part of epic #1671. Supersedes #1652 (contributor PR retargeted to the epic branch). Issue: #1646.
For the owner to review
publicationRequestNoticeis printed by the CLI and returned by the backend route asrequest_notice; ADR 0090 names it as the one place those sentences are spelled, so its amendment was updated and the pinning tests were changed deliberately. The requester is mailed when a screen finds something (torequested_by), on denial (torequested_by) and on approval (todataset.owner_email, which differs only when an admin requests on an owner's behalf). A requester mail on a clean screen would be a small backend change and a product decision; it is not made here.Behavior to know about
cancelledandtimed_outruns stay blocked (sweep behavior, unchanged).publish statusstill shows the row as waiting; telling an outage from a wait needs a stored marker or a new block reason (follow-up).bids_validation_pendingis still what the backend writes for an outage row, but the response to the request is the 503.Test plan
bun run typecheck(root and backend),biome checkon the 26 changed.tsfilespublish-request-ci-pending77,requester-mail-recipients2,anonymity-publication-paths48,identifier-screen-flow53,cron-sweep-wiring129,cron-dev-safety43 and the adjacent publication, approval and anonymous-release suites; CLI:publish-pending11,publish-pending-cli25,publish-status-pending-cli8,upload-success-next-steps11, the notice-pinning tests, ADR index 8: all pass, 0 failtestRequest|TEST_API_URL|runCli\() finds nothing in any new or edited file excepttest/identifier-screen-cli.test.tsandtest/publish-anonymous-cli.test.ts, which already matched before this changebids_validation_failedtreated as pending, the typed-flag hint, the anonymity warning and exit code on both paths, headline stream, 503 handling, the status view, the gate in the route and in the sweep, anonymous unreadable fails closed, each of the sweep's conditional-write terms, the read budget, the requeue, the mail recipientsFollow-ups (not in this PR)
ci_check_unavailableblock reason (with a website vocabulary sync) sopublish statuscan tell an outage from a waitcancelledandtimed_outruns, and mailing on a failing-validation relabel or a minimum re-block--jsonresulttest/identifier-screen-cli.test.tsandtest/publish-anonymous-cli.test.tsout of the live tier