Repository navigation
Add the upstream re-pull workflow - #148
Merged
Merged
Conversation
Whole-file copy of .github/dataset-workflows/run-upstream-repull.yml from nemarOrg/nemar-cli, branch feature/issue-1046-epic-upstream-freshness at 1abf92868e8216b4d1596d6802dea0c7ab2f7e8c (file last changed in 138386fb650568c56d7abf6dbed34ecf88f917fe; sha256 7335f4cd99b1e1cf6718ab044efe23c0a6856df8968df85804ef176ede81f74b, 336 lines). Verified with cmp. YAML parsed and actionlint clean; the workflow was not executed.
9 of 10 tasks
neuromechanist
added a commit
to nemarOrg/nemar-cli
that referenced
this pull request
Oct 27, 2026
The validation step now checks the token and repull_id in the jq gate, on the event file, where a token with a trailing newline and an empty repull_id can no longer pass as they did through a shell variable. The mask step splits the token at carriage returns as well as line feeds. Comment fixes: the second step reads the token, canceled, and the script, not the runner header, never echoes a value. Checked with a hostile-event harness (each guard mutated and caught), actionlint, and test/repull-workflow.test.ts: 34 pass, 3 skip. The org copy follows in nemarDatasets/.github#148.
Whole-file copy of the hardened .github/dataset-workflows/run-upstream-repull.yml from nemarOrg/nemar-cli#1980, commit db1b932040f08bfbc045768b3de87897519291ac (sha256 ea9052fe68bc2be207425740515711aa5b3d6df4cbee308c9c0d14f05fc479ea, 343 lines). Verified with cmp. The token and repull_id are checked in the jq gate on the event file, and the mask step splits at carriage returns too. actionlint clean; the workflow was not executed.
neuromechanist
added a commit
to nemarOrg/nemar-cli
that referenced
this pull request
Oct 27, 2026
The validation gate now refuses a control character in any payload field, read from the event file. An environment variable ends at a NUL, so the checks on the variables saw only what preceded it and step 2 passed a payload the CLI refused later. The test also covers the final newline that a regex dollar lets through, so the separate final-newline guard on the token and repull_id is gone. Checked with the review harness on jq 1.8.2, Apple jq 1.7.1 and Ubuntu 24.04's jq 1.7.1 (identical results), actionlint clean, and the existing tests: 34 pass, 3 skip. The org copy follows in nemarDatasets/.github#148.
Whole-file copy of .github/dataset-workflows/run-upstream-repull.yml from nemarOrg/nemar-cli#1980, commit a3dc47cea58d6d1b7dd2f7a4924355737eaa216a (sha256 ccb8a657ac61bd43dbc3105efede0c5101bc34e484b76471e91d75cd8a66c259, 345 lines). The validation gate refuses a control character in any payload field, which closes the gap where a NUL ended an environment variable and step 2 passed a payload the CLI refused later. Verified with cmp. actionlint and shellcheck clean; the workflow was not executed.
neuromechanist
marked this pull request as ready for review
October 27, 2026 09:00
neuromechanist
added a commit
to nemarOrg/nemar-cli
that referenced
this pull request
Oct 27, 2026
* ci: check out the repull workflow in tests Adds run-upstream-repull.yml to the sparse checkout of the deployed dataset workflows and updates the comment's count to four. Nothing reads the file yet; the next commit names it for the parity test. YAML parsed; not run in CI. * ci: set the repull workflow live flag in tests Names the checked-out copy in NEMAR_REPULL_WORKFLOW_LIVE so test/repull-workflow.test.ts compares it byte for byte; a declared path that is missing fails. The unit-pure job stays red until the twin pull request lands in nemarDatasets/.github, so this is held with it. YAML parsed; not run in CI. * test: say repull header names the deployed copy Comment only. The header said the unit-pure-shard job will, once the deploy lands, name the deployed copy. It now says the job does so, stays red until the deploy pull request is merged, and fails on any drift after. bun test test/repull-workflow.test.ts: 34 pass, 3 skip, 0 fail with the variable unset. * ci: harden the repull token and mask checks The validation step now checks the token and repull_id in the jq gate, on the event file, where a token with a trailing newline and an empty repull_id can no longer pass as they did through a shell variable. The mask step splits the token at carriage returns as well as line feeds. Comment fixes: the second step reads the token, canceled, and the script, not the runner header, never echoes a value. Checked with a hostile-event harness (each guard mutated and caught), actionlint, and test/repull-workflow.test.ts: 34 pass, 3 skip. The org copy follows in nemarDatasets/.github#148. * ci: refuse control characters in the payload The validation gate now refuses a control character in any payload field, read from the event file. An environment variable ends at a NUL, so the checks on the variables saw only what preceded it and step 2 passed a payload the CLI refused later. The test also covers the final newline that a regex dollar lets through, so the separate final-newline guard on the token and repull_id is gone. Checked with the review harness on jq 1.8.2, Apple jq 1.7.1 and Ubuntu 24.04's jq 1.7.1 (identical results), actionlint clean, and the existing tests: 34 pass, 3 skip. The org copy follows in nemarDatasets/.github#148. * test: pin the repull hardening and control check Adds cases to the mask test and the refusal test, each caught by its own mutant: a carriage return in the token is masked per line; a token with a final newline, an empty repull_id and a repull_id of 1 plus a newline are refused; a NUL in any field is refused, with the job environment cut at the NUL as a C string is. The refusal cases are collected, so a weakened check shows every case it lets through. 34 pass, 3 skip (37 pass against the org copy).
neuromechanist
added a commit
to nemarOrg/nemar-cli
that referenced
this pull request
Oct 27, 2026
* docs: fix the s3_lock 403 comments A 403 on PutObjectRetention counts as locked only when the retention read-back shows the lock this route sets. Comment text only; tested: not applicable. * docs: say a secret turns the switches on The auto re-pull switches are read from the Worker environment, so a secret of the same name enables them too. Comment text only; tested: not applicable. * feat: ask when the scheduler waits on gate G4 With the open switch on and the scheduler's last tick concluded waiting-for-manual-run, the weekly report now asks for attention: a switch turned on early otherwise changes nothing and says nothing. Quiet with the switch off. Tested: import-weekly-repull-section (81 pass); both the removal and the unconditional form of the check fail the new tests. * fix: ignore the OpenNeuro URL override in prod snapshotGraphqlUrl returns OpenNeuro's own endpoint in production and in an unknown environment (fail-closed), and honors OPENNEURO_GRAPHQL_URL elsewhere. A loopback http address is honored everywhere, as githubApiBase does in the CLI, so the suites that run the production-only scheduler against a local stand-in stay hermetic. Tested: openneuro-snapshots (34 pass) with a routed fetch that never reaches a network; four mutations each fail the new tests; 337 pass across the nine dependent files. * fix: mirroredTagOf reads vN.N.N rows too D1 stores a version as 1.0.0 or v1.0.0, and mirroredTagOf matched only the bare spelling, so a mirror whose rows carry the v read as unpublished and was never compared or dispatched. It now accepts one leading v, orders by number across both spellings, reads the rows of one version together (a disagreement is unknown, never one picked) and returns the version bare. The staleness report dates a version by its earliest row in either spelling, and the plan's from-tag no longer strips the v itself. Tested: source-snapshot and upstream-staleness unit tests, every consumer's suite (12 files, 462 pass) and the plan, supersede and upstream-status CLI suites (86 pass); the v-only test fails with the old regex. * refactor: drop the unused SOURCE_VERSION_BASES Nothing in src, shared, backend or the tests read it or its type (git grep finds only the definition); migration 0104's CHECK is the list of the three words, and the parser's types name them directly. Tested: source-snapshot unit tests (48 pass); typecheck in the hook. * ci: install and name the test tools unit-pure-shard, deploy-backend's test-gate and the nightly run set up Python 3.12 and uv, as scrub-tools-shard does: without uv the EDF reader cases in identifier-scrub and identifier-dates skipped in unit-pure (3 skips in shard 4 of run 40537526547) and reported green. Each of those jobs, and integration-dev, gets a "Tool versions" step that names git, git-annex, uv (where needed) and the aws CLI, which the runner image provides and no step installs, so a missing tool fails that step by name. Tested: ci-tier-routing, workflow-yaml and the other suites that read these workflows pass; the three files parse. * test: fail on a missing tool when CI is set toolOrFail threw only under NEMAR_REQUIRE_SCRUB_TOOLS=1, which only the scrub-tools job sets, so in unit-pure, integration-dev, the deploy gate and the nightly run a missing aws, uv or git-annex skipped about 45 describe blocks across 18 files and reported green. It now also throws wherever CI is set, read by gitAnnexGate's rule (exported as ciIsSet), and the error says which of the two made the tool required. Tested: test/scrub/require-tools.test.ts passes (8 tests) with new cases for CI=true and for CI set to false, 0 or empty; with the CI clause removed the CI=true case fails. * docs: say why the two version patterns differ NEMAR_VERSION_RE (repull-state) and the stored-row pattern in source-snapshot now accept different spellings, so they stay two constants. Each says why: a re-pull record and its requests carry a bare N.N.N, which the record's statements prefix with the v themselves to find a row in either spelling, while dataset_versions rows may carry the v. Comments only. Tested: Biome; typecheck in the hook. * docs: qualify plan as read-only plan --automatic-dispatch reports started (and refused or failed) to the Worker, which stores it. Help text, the plan command description, the CHANGELOG bullet and an ADR 0111 annotation say so. Tested: repull-command-text (13 pass). * refactor: write the trailers from one builder The re-pull commit (synthesize), N.0.0's pull request body, N.0.1's body and its commit message now take their trailer lines from repullTrailerLines and the new repullPatchTrailerLine in shared/repull-squash.ts instead of their own templates (#1972). Bytes are unchanged. Tests pin each writer's lines to the builder's output; mutating any one writer fails them. Tested: repull-trailers.unit (13), command-text, patch, patch-cli, resynthesize, admin-pr-reviews-repull, worker-merge (160 pass), execute-prepare and execute-cli (74 pass). * fix: approve --merge exits 3 on a held claim A claim to merge that is held (a lost answer, GitHub did not merge) now exits with the waiting code, as repull merge does, instead of 1. A refusal with no claim held still exits 1. Tested: admin-pr-reviews-repull (14 pass); removing the branch fails the two exit-3 tests and exiting 3 always fails the exit-1 control. * test: run the merge-gate CLI suites in unit-pure Nine suites reached integration-dev only because a header comment named the API address variable that scripts/ci/unit-pure-files.sh greps for: repull-merge, -gates, -patch, -patch-resolutions, -release, -abandon, -supersede, -merge-bids-override and admin-pr-reviews-repull. Only the header comment changes: it no longer names the variable, and its CI TIER claim says unit-pure, which test/ci-tier-routing.unit.test.ts holds against the classifier. Tested: the nine suites pass with no TEST_API_URL in the environment, no --timeout and no retry (147 pass, 0 fail, 278 s), with every proxy variable pointed at a local egress spy that logged no request; the same spy logged bun fetch, the aws CLI and git reaching outside hosts. ci-tier-routing passes (73 tests); the classifier lists 760 files. * fix: name abandon for a record without counts A record that does not say how many corrections and conflicts its plan has stays released and blocks the dataset's next re-pull; resume's message and help now name nemar admin repull abandon as the way out. Tested: repull-patch-cli (21 pass); the old message fails the new test, which also runs abandon and sees patch_declined. * test: bound workerd hooks and spawn loops Four Miniflare suites booted workerd and applied every migration in a beforeAll under the default five seconds: their beforeAll now has 60 s and their afterAll 30 s, the bounds site-binding-identity, private-site-rpc-entry and email-send-binding give the same hooks. dataset-release-mirror-major runs the CLI from source up to four times a test, each run bounded at 30 s by its own timeout; the file now has 60 s, git-credential's bound for the same spawn. repull-workflow's seven tests that run step scripts in a loop (up to 31 bash runs) get 20 s, the bound publication-review-workflow gives its loops. Tested: the four Miniflare suites (10 pass) and the two test/ suites (40 pass, 3 skips: the deployed copy, accepted) pass. * test: end the held copy on release, not a timer "killed while a copy hangs" held the killed run's CopyObject for a fixed 8 s. The CLI's aws child outlives the SIGKILL and keeps its connection open, so the hold never saw its client go and always ran out its timer; the test then sat out the rest of it (4.6 s locally). The S3 stand-in's hold now also ends on releaseHolds(), and the test holds with a 120 s backstop, ends the hold after the next run has completed (in a finally, so a failure cannot leave it held), and polls for its observable end with the existing 15 s deadline. Tested: the test passes in 15.0 s of run time against 19.2 to 20.0 s before; with releaseHolds() made a no-op it fails at the settle check. * docs: mark the re-pull ADR amendments as built ADRs 0006, 0060, 0089 and 0091 each carried an amendment saying the re-pull was designed in ADR 0111 and not yet built. Each gets a dated annotation saying epic #1046 built it, and which ADR 0111 amendment records how. Append-only; no decision text changed. Tested: test/adr-index.unit.test.ts. * docs: annotate stale ADR 0111 statements Seven earlier statements of ADR 0111 still said the workflow pair was held or not deployed, a route was owner-or-admin only, or an item was open that the Phase 2 amendment closed. Each gets a dated annotation under it, as the record's own rule requires. Append-only; the end of the file is untouched. Tested: test/adr-index.unit.test.ts. * test: run mirror-major against the real routes The spawned cases of dataset-release-mirror-major ran the CLI against a Bun.serve() that answered GET /datasets/:id and /versions with rows written in the test, so the source and version the refusal reads were a copy of the Worker's answer, not the answer. They now run against the real datasets router over bun:sqlite with every migration applied, behind its real auth (makeRepullApp, as repull-plan-cli does), with the rows seeded in SQLite and GitHub, which the versions route reads the description from, as the github-standin. /notices is answered as the re-pull suites answer it. Tested: 6 pass. With the detail route's `source` removed from its answer (a scratch mutation) the two xx cases fail, which the canned answer could not show. Under an egress spy that logs any request to an outside host, nothing reached one. * test: refuse remote git calls in a CLI shim dataset-release-mirror-major's git shim refused only `clone`, and the update case's working tree has `https://github.com/nemarDatasets/<id>` as its origin. A mutation that let the CLI past the mirror refusal made the test create a branch, commit and run a real `git push` to GitHub with the machine's credential helper; it failed only because nemarDatasets/xx090123 does not exist today. The shim now refuses clone, fetch, pull, push and ls-remote, and still records each call. Tested: 6 pass; under the same mutation the push is refused by the shim ("Failed to push branch") and nothing reaches GitHub. * test: run prepareImport against the real routes import-prepare-pin's backend was a Bun.serve() that answered the import create with a hand-written 409 and the version list with a hand-written array, so the release state the upstream-moved guard reads never came from the Worker. It is now the real admin and datasets routers over bun:sqlite with every migration applied, behind their real auth (makeRepullFullApp): the import create answers 409 because the database holds on999990, and each case sets its release state with a version row. GitHub, which the version list reads the description from, is the github-standin. Tested: 5 pass. Scratch mutations of the real routes are caught: a version list that drops its rows fails the released case, and an import create that does not refuse an existing dataset fails all four prepare cases. No request reached an outside host under an egress spy. * docs: correct the re-pull merge rules AGENTS.md said an administrator merges by three paths only; it is NEMAR's tools that do, and the GitHub merge button is not bound. AGENTS.md and ADR 0093 (dated annotations) said the Worker merges while AUTO_REPULL_MERGE_ENABLED is on; it merges only in production with AUTO_REPULL_ENABLED and AUTO_REPULL_MERGE_ENABLED both exactly 1 (autoRepullMergeEnabled). Tested: test/adr-index.unit.test.ts. * docs: say the re-pull workflow copy is merged The header of repull-workflow.test.ts still said the org copy was held until the epic ships. It merged as nemarDatasets/.github#148. Comment text only; the authoring copy is not changed. Tested: repull-workflow (34 pass, 3 skip). * test: restore the exemplar test's no-mocks note This epic replaced exemplar-endpoint's header sentence that tied the happy path to the no-mocks policy. The GitHub stand-in it added is a loopback server the route's own GitHub client calls (createRepository is the happy path's only GitHub request), in the style of repull-github-standin, so it stays; the header says so again and names the policy. Tested: backend/test/exemplar-endpoint.test.ts passes (20 tests). * test: pin the Worker merge's status and order Nothing ran workerMergeRepull on an automatic record that is not at gates_clear (patch_* included), reconcileWorkerClaim on a claim held on such a record, or the credential read that comes before the claim. New tests, in the worker-merge suite's harness (bun:sqlite with every migration behind realD1, the repull GitHub stand-in): - every status but gates_clear, a machine-clean world otherwise: workerMergeRepull skips, reads nothing from GitHub, and writes no claim and no row (16 tests); - the same statuses holding a claim: reconcileWorkerClaim skips and reads nothing (16 tests; pr_open is the case only the status term refuses, the others also lack a merge commit); - the credential goes away after the facts' reads and comes back for the claim's own read: held pr-unreadable, no claim, no audit row, nothing sent. Tested: the suite passes (114 tests). Scratch mutations, one at a time: the status term dropped from workerMergeRepull fails 16 tests, from reconcileWorkerClaim 8; the credential read moved after the claim fails the order test, and so does a catch that carries on. * refactor: name the dataset checks in shared The BIDS validation and version-check names, and the four legacy inline repositories, move to shared/dataset-checks.ts so the CLI's re-pull gates can read the check the ruleset requires; deriveContexts reads them there and branch-protection re-exports the legacy set. Outputs are unchanged. Tested: branch-ruleset and the other GitHub module suites (part of the 28-file hermetic run, 1259 pass); typecheck in the hook. * refactor: share the BIDS override rule shared/repull-bids-override.ts holds the rule an administrator's merge over a failed BIDS validation rests on: checkFactOf reads the App's latest run of a check (moved from the Worker's reader of the two checks), bidsOverrideFault decides the facts (an administrator's record, unstable and not blocked, BIDS failed, version-check passed), and othersNotPassing and bidsOnlyFault add that no other check run or commit status fails. The Worker's claim now asks bidsOverrideFault, with its refusal codes and words unchanged. Tested: new unit test of the rule (13 pass); the Worker's override, facts, merge-claim and scan suites (part of the 28-file hermetic run, 1259 pass); typecheck in the hook. * fix: resume gates a head failing BIDS alone A failed BIDS validation that no rule requires makes GitHub report unstable, and resume recorded the gates only on clean, so merge --bids-failure-reason, taken only from gates_clear, could not be reached. On a record an administrator opened, resume now also records the gates when GitHub reports unstable and BIDS validation is the one check that fails (bidsOnlyFault over every check run and commit status of the head, read with the administrator's token); the result and the ready line say to merge with the reason. The merge gate refuses an override where another check or status does not pass, before anything is written; the Worker's claim still reads the BIDS and version-check facts itself. An automatic record, a merge without the reason and pr-reviews still require clean. The GitHub stand-in answers a commit's combined status. Tested: BIDS override CLI suite (28 pass, 10 new: BIDS-only unstable reaches gates_clear and merges with the reason; another check, a status, a running check, a failed version-check or a passed BIDS run are not gated; clean is unchanged; an automatic record is not gated; the merge without the reason and the merge over another failing check refuse); machine-clean unit test (58 pass); 13 other CLI suites (512 pass). The BIDS-only test fails with the resume change reverted. * docs: amend ADR 0111 for the #1983 review A dated amendment at the end of the record, nothing above it changed: the BIDS override is reached through resume (what was wrong, the rule in shared/repull-bids-override.ts, the merge gate's half, what still requires clean, what only GitHub can show), and the mirrored tag reads both spellings of a version (the rows of one version read together, a disagreement unknown; the backfill's bare-only rows left open). Tested: documentation only. * style: American spelling in a BIDS-only message The state word shown when GitHub's mergeable state cannot be printed reads "unrecognized". Tested: Biome and typecheck in the hook. * ci: install the German locale for the git cases Two pure suites run git in German to show that an outcome is read from a status and not from git's message. The runner has no de_DE.UTF-8 locale, so git spoke English there and those cases asserted nothing. unit-pure-shard, deploy-backend's test-gate and the nightly run now install language-pack-de-base after git-annex, and "Tool versions" fails by name when de_DE.utf8 is not listed. Tested in an ubuntu:24.04 container with git 2.56.0 from the git-core PPA (the runner's git): before the pack git answered an unknown command in English under LC_ALL=de_DE.UTF-8; after it (8 s to install) in German. The archive's git 2.43 ships no catalog of its own and speaks German only with the pack. * test: fail German cases where git is English The German cases in import-annex-uuid-preflight and import-upstream-moved-guard set LC_ALL=de_DE.UTF-8 and asserted on the outcome, which passes on English where the locale or git's German catalog is missing. Their two copies of inGerman become one helper (test/helpers/in-german.ts) that first asks git something whose answer differs from the C locale's: where git is not German it throws with CI set, and elsewhere runs the case in English after a warning, as a missing tool skips. Tested: both suites pass (34 pass, 1 skip: the root-only case); git speaks German here. With the locale replaced by one that does not exist (a scratch mutation) the two German cases fail with CI=true and pass with a warning without it. * fix: check the shapes a re-pull reads and trusts The bucket and region remote.log names, and the dataset ids, tags and versions a plan states, become a host, a ref, a branch name and the write guard's one destination. Each is now checked where it is read (new src/lib/repull/shapes.ts): the planner refuses a malformed bucket or region, execute and the release refuse it as nemar-s3-invalid, the annex-uuid read and the bucket listing build no host from one, and planFacts refuses a malformed scalar as plan-schema. The words name the field and the shape, never the value. Tested: repull-shapes.unit (18), the planner and release entry points, 13 mutations each fail a test; the whole re-pull family, 676 pass in 36 files. * test: pin the production override fence Production ignores a non-loopback OPENNEURO_GRAPHQL_URL of any protocol and honors only an http loopback one. A matrix of six protocols against loopback and other hosts pins snapshotGraphqlUrl, https on a loopback host is refused, and the reader posts to openneuro.org (routed fetch, nothing sent) for https, ws and ftp on the stand-in's port and for http on a host that is not loopback. Tested: openneuro-snapshots (37 pass); removing the protocol check, allowing https and dropping the host check each fail the new tests. * fix: backfill examines vN.N.N rows The backfill took only rows spelled N.N.N, so a v-spelled row from before migration 0104 stayed never examined, and the staleness report, which now reads both spellings, sent it to a pass that could not reach it. A candidate is now read as mirroredTagOf reads it: one lowercase v stripped (bareNemarVersion, and the same in SQL), then N.N.N. The ref is the canonical tag, the rows of one version in both spellings are read once and each recorded from that read, the write stays on the row's own spelling, and the cursor carries it (CURSOR_RE takes the v). vv1.0.0, V1.0.0 and other shapes are still never candidates. Tested: new Miniflare D1 test (4 pass: a v-only row examined and its source_version written; both spellings read once; the v cursor pages to the end; odd spellings skipped); route test (35 pass, the v test replaced by its new rule); backfill, status and snapshot suites (13 files, 395 pass, 6 skipped by design, 0 fail). * fix: shape-check the commit ids of a plan planFacts now refuses an upstream, main or git-annex commit in a plan that is not a full 40-digit lowercase hex id (plan-schema, naming the field and never the value). A commit id ends up as an argument of git fetch, checkout, commit-tree and ls-remote. New isCommitId in shapes.ts uses the Worker's SHA_RE. Tested: repull-shapes.unit (22 pass); six mutations each fail a test; 182 pass across the 12 re-pull unit files. * docs: ADR 0111 notes the backfill reads v rows The review amendment at the end of the record said the backfill still took only N.N.N rows and left that open; the backfill now examines both spellings, so the bullet says so, and that the Phase 2 amendment's "Only a version of the form N.N.N is a candidate" no longer holds. Only the amendment's own last bullets change. Tested: documentation only. * test: keep the day-cap suites in one UTC day The merge cap and the open cap count a fixed UTC day with date('now') inside their statements, and no function that claims takes a clock: workerMergeRepull(env, row), claimOpenDispatch(env, candidate) and the claim route read D1's own. So a test that makes several claims and expects one day (merge-claim's "the day is the UTC day", dispatch's "yesterday's dispatches do not count", worker-merge's "a cap of 1 and two clean rows") fails when it runs across 00:00 UTC. With no clock to fix, each of the three suites' beforeEach now awaits insideOneUtcDay(db): when less than 2 s is left of the UTC day on the database's clock, it polls until the day turns, with a deadline of a second past the turn. Every test in them takes well under a second. Tested: the three suites pass (222 tests); the guard returns at once away from midnight, and SQLite's now agreed with Date.now() to the ms. * test: pin the nemar-s3-invalid guards advance.ts: a working clone whose remote.log names the bucket as a path is refused by the real executeRepull before the copy, with nothing uploaded, pushed or opened and the record prepared with [copy:nemar-s3-invalid]. run.ts: a plan forged onto a git-annex commit with such a remote.log, digested again with its handoff, is refused at prepare by the automatic execute (record planned, [prepare:nemar-s3-invalid], dispatch prepare-failed, no S3 or GitHub write). Tested: removing either guard fails its test; both pass with the guards in place. * test: name the IAM collaborator precondition Three iam-removal cases need test-user to be a collaborator of nm099999 (its dataset_collaborators row and its user_s3_permissions row, seeded by scripts/seed-dev-db.sql). The reset of nm099999 deletes both and restores neither, so after any reset the cases failed with the route's 403, which reads as an authorization bug. The only routes that write the row, invite and access-request approve, go through grantCollaborator, which first adds test-user's GitHub login as a collaborator on GitHub, so no test may call them. Each of the three cases now reads GET /datasets/nm099999/collaborators as test-admin first and fails with "Missing precondition: test-user is not a collaborator of nm099999 ..." and how to re-seed it; an answer that is not 200 fails as unread and is asked again by the next case. Tested against the dev backend, whose nm099999 has no collaborator row: the three cases fail with that message; with the check removed they fail as before, 403 where 200 was expected. * docs: list the review fixes in the CHANGELOG Four bullets under Production behavior changes, each on its own lines: the G4 attention reason in the Monday report, production ignoring OPENNEURO_GRAPHQL_URL unless it is a loopback http URL, approve --merge exiting 3 on a held claim, and the shape refusals for a bucket, region, dataset id, tag, version and commit id. Docs only. * docs: record the live GitHub check in ADR 0111 The review amendment's stand-in bullet becomes what was read on 2026-10-27, read-only, on nemarDatasets/on004362 pull request #1 at c06fa1cf: main has no branch protection (404) and only the tag ruleset; the pull request reads unstable with "NEMAR PR Review", not required, as its one failing check; the check names and the fields of the check-runs and combined-status answers are the ones the rule reads, and the rule run on those answers names the review as what fails. Still unverified: a live failed BIDS run on an unprotected repository reading unstable. Tested: documentation only; the rule was run on the saved live answers. * ci: refresh the unit-pure shard timings Regenerated as test.yml's note above unit-pure-shard says: the unit-pure-shard-* artifacts of the two green runs at b78f11c (push 40537526547 and pull_request 40537849610), merged per run with the documented jq, then averaged per file across the two runs, as the note asks. The committed file timed 644 of the 751 pure files; this one times all 751 (1,495 s of test time in all). The nine merge-gate suites that now route to unit-pure ran in integration-dev in those runs, so they are not timed yet and bun puts most of them on the last shard. A dry run of bun's partition (--shard i/6 -t '^never$') with each file's measured time, the nine at their integration-dev times, projects the slowest shard at 472 s with this file and 737 s with the old one. The next refresh, from the first green run of the fix pull request, times the nine. Tested: the file parses as version 1 with 751 numeric entries, and bun partitions the 760 listed files with it. * test: name the git calls the shim refuses * fix: re-read other checks before the claim The gate read that nothing but BIDS validation fails once, before the review was read again, the confirmation and the claim, and the merge's last look re-checks only that GitHub still says unstable, so a check that started failing in between was merged over. sendUnderLock now reads it again, under the lock and before the claim, through the same helper step 7 uses, and a refusal claims nothing. The ordinary merge reads no check, as before. Tested: BIDS override CLI suite (a check that starts failing after the gate's read is refused with nothing claimed; the ordinary merge of a clean head reads no check); the test fails with the re-check removed. * fix: approve --merge marks its exit 3 reported approve --merge exits 3 while a claim to merge is held and when GitHub merged the pull request and the record does not hold it yet, without markReportedExit, so the exit hook asked for a debug log under a correct answer. Both paths mark the exit reported, as repull merge does; a refusal that exits 1 is unchanged. Tested: pr-reviews re-pull CLI suite (the three exit-3 cases print no request for a debug log). * fix: resume at the gates names the BIDS override A second resume on a record gated over a failed BIDS validation returned a plain ready, so it printed the ordinary merge command, which the gate refuses while GitHub reports unstable. At gates_clear, on a record an administrator opened, resume now reads GitHub's state and, while it is unstable for BIDS validation alone (the rule its gates were recorded by), its ready line names --bids-failure-reason. resume --json carries the flag as bids_failure, true or false. Tested: BIDS override CLI suite (the second resume's line and JSON name the override while the validation fails, and the ordinary merge once GitHub reports clean); the gates CLI suite. * docs: annotate the v-row candidate sentence ADR 0111's Phase 2 amendment still said only a version of the form N.N.N is a candidate. A dated annotation under it says a row spelled vN.N.N is a candidate too. The #1983 review amendment said earlier text is unchanged; it now says the decision text is unchanged and earlier text is annotated where the amendment corrects it. Append only, bar that one sentence. Tested: test/adr-index.unit.test.ts. * docs: make the AGENTS.md merge rules agree The paragraph on ADR 0093 said NEMAR's tools merge by three paths only, then said the Worker merges a machine-clean automatic re-pull. It now says an administrator merges through NEMAR's tools by three paths only, the Worker makes the one other merge, and the GitHub merge button is bound by none of it. Docs only. * docs: say plan may report its dispatch The header comment of admin-repull.ts said plan writes nothing to D1 or the API, and its help said a dry run, always. Both now carry the exception the help already named further down: plan --automatic-dispatch reports its dispatch to the Worker. Comment and help text only. Tested: repull-command-text (13 pass). * docs: fix the BIDS override help sentence The merge help said no check but BIDS validation fails or is still running, and that resume records the gates of such a head. resume and the Worker's claim need BIDS validation to have completed with failure and every other check to pass, and resume waits while a check runs. The sentence now says so. Comment text in the help only; no code changed. Tested: repull-command-text (13 pass). * docs: note staleness reads v-spelled rows A CHANGELOG bullet under the Unreleased production behavior changes: the staleness report and the backfill now read version rows spelled vN.N.N, which the report used to ignore, so upstream-backfill --execute writes more rows. On its own lines. Docs only. * ci: require test tools by variable, not CI toolOrFail and inGerman threw wherever CI was set. nightly-tests.yml and bump-validator.yml run dev's tests with their files on main, which install neither uv nor the German locale, so the nightly would have gone red and filed an issue once this reached dev. Both now fail only under NEMAR_REQUIRE_SCRUB_TOOLS=1, set at job level where every tool is installed or named: test.yml's unit-pure-shard (git-annex, the German locale, Python and uv, the runner's aws), integration-dev (git-annex and aws; its suites need nothing else) and scrub-tools-shard (moved from its test step), and deploy-backend's test-gate (as unit-pure-shard). nightly and bump-validator do not set it. gitAnnexGate is back to its own CI rule, unexported. Tested: require-tools.test.ts passes (8), now pinning that CI=true alone is a clean skip; with CI keyed back in, those two cases fail. With the locale replaced by one that does not exist, the German cases fail under the variable and pass with a warning under CI=true alone. * ci: give the validator bump git-annex bump-validator.yml's bump path runs a bare `bun test` over the whole tree with neither git-annex nor the backend's dependencies. Since #1978 the data-host suites refuse to skip a missing git-annex on a CI runner, so the path has been red; and without backend/node_modules no backend suite can import hono. It now installs git-annex (with the 10-minute limit test.yml's jobs use) and the backend's dependencies from their lockfile, both behind the skip guard every later step has. The variable that requires uv and the German locale is not set here: this job runs from the copy of the file on main. Tested: bump-validator-workflow.test.ts and workflow-yaml.test.ts pass (34). With git-annex off PATH and CI=true, data-host-cli and data-host-e2e fail ("refusing to skip"); with it, they pass (27). * test: shim refuses every remote git call dataset-release-mirror-major's git shim matched the command in $1 only, so `git -c k=v push`, `git -C dir push`, `git --git-dir=x fetch`, `git annex sync` and `git remote update` reached the real git, and cli() handed the CLI the test process's GH_TOKEN and GITHUB_TOKEN. The shim (gitShim) now finds the command past git's own options, the ones that take a value skipping it too, and refuses with exit 128, before the real git runs: clone, fetch, pull, push, ls-remote, archive, request-pull, send-pack, fetch-pack, http-fetch, http-push, svn, p4 and every submodule command; remote update, prune, show and set-head; every annex command but annex version. cli() drops GH_TOKEN and GITHUB_TOKEN. The header says exactly that, and a test holds it to the two lists. New tests, with a recorder in place of the real git: 18 such calls are refused and never reach it; the six calls the CLI makes here are still handed on; a token in the test process does not reach the CLI. Tested: 27 pass. With the old $1 matching back, 13 of the 18 reach the recorder and fail; with the two tokens no longer dropped, the token test fails. * test: refuse the override on a failed check read Nothing failed the two reads the BIDS-only override rests on (src/lib/repull/bids-only.ts: every check run of the head, and its combined status), the merge gate's unreadable branch, or fetchDatasetRepoJson itself. The GitHub stand-in gains readFaults, an error-path fixture that answers one check-runs or status read with an HTTP status. Through the real CLI against the re-pull world, each read answering 500 now refuses `merge --bids-failure-reason` with the github stop and the read's own words, before anything is written, and keeps resume from recording the gates of a BIDS-only head (4 tests). fetchDatasetRepoJson is pinned on an HTTP error with and without a message, a 200 that is not JSON, and no answer at all (5 tests). Tested: the three suites pass (126). Scratch mutations, one at a time: a failed check-runs read taken as no runs fails its 2 tests; a failed status read taken as all success merges and gates, and fails its 2; the merge gate taking unreadable as BIDS-only merges, and fails 2; fetchDatasetRepoJson keeping an error's body fails 2. * test: keep the open-cap suites in one UTC day upstream-repull-advance (usedToday, the resume dispatches that count against the open cap) and upstream-repull-scheduler ("a second tick the same day is cap-reached") count the same UTC day on the database's clock as the three suites already guarded. The advance tick takes a `now`, but it decides the tick's windows; the cap's day is date('now') inside the statement. Both suites' beforeEach now await insideOneUtcDay(db), and the helper names its five users. Tested: both suites pass (175). With the guard made to throw, all 175 fail, so it runs before every test of both. * test: read the annex-uuid host through a spy repull-shapes' happy path replaced fetch and served a canned 200, so the read's success never met a real request. The read's URL is the real S3 host by design (no endpoint override), so the code cannot be pointed at a stand-in; a proxy is what it really calls instead. The happy path and the no-request cases now run the real fetch with the egress spy (test/helpers/egress-spy.ts) as the process's proxy: a valid pair sends one CONNECT to nemar.s3.us-east-2.amazonaws.com:443 and, refused, reads as an error; a bucket or region that could name another host sends nothing. The exact object URL is pinned on a 404 (absent) and a 403 (forbidden) answered by the remaining fetch fixture, error paths only. No test serves a canned success. Tested: 23 pass. Scratch mutations: without the bucket and region guard the no-request test fails; a path-style URL fails the host and URL tests; dropping the prefix fails the URL test. * test: name each missing IAM fixture row The precondition read only test-user's dataset_collaborators row, but the two upload routes also need its user_s3_permissions row for nm099999, which the reset deletes too. Each collaborator case now checks the rows its route needs and names the one that is missing: the collaborator row from the collaborator list, as test-admin, for all three; the permission row, which no route but the upload routes reads, from upload-urls as test-user, for the two upload cases. That route checks the rows in turn and writes nothing (it signs URLs locally), so a missing collaborator row says the permission row cannot be read yet. Nothing is written. Tested against dev, whose nm099999 has neither row: the three cases fail naming the collaborator row. Against a local server running the real datasets routes over bun:sqlite: with the permission row left out, the two upload cases name it; with both rows, the presigned URL case passes. With the permission check removed, the two upload cases fail with the route's bare 403 instead. * test: name the finish dispatch in the workflow header * docs: match the workflow header to nemarDatasets
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
Adds
.github/workflows/run-upstream-repull.yml, the central workflow of the automatic upstream re-pull (ADR 0111 in nemarOrg/nemar-cli, decision 6; epic nemarOrg/nemar-cli#1046, Phase 7), by whole-file copy of.github/dataset-workflows/run-upstream-repull.yml. The file is new and no existing workflow changes.What it does: the production Worker dispatches it (
repository_dispatch, typerun-upstream-repull, nine payload keys) to open or finish one dataset's re-pull of a changed OpenNeuro snapshot. It masks the dispatch token first, validates every field, mints an App token scoped to the one dataset repository, installs the exact nemar-cli release the dispatch names, and runsnemar admin repull planandexecute(open) orresume(finish) with--automatic-dispatch. The CLI reports tohttps://api.nemar.org/webhooks/repull-state, and a last step reports a run that did not report. It opens a pull request on the dataset repository and never merges. Its Actions log is public, so the CLI prints only counts and fixed words and nothing is uploaded as an artifact.No new secret is needed:
NEMAR_APP_ID,NEMAR_APP_PRIVATE_KEY,NEMAR_ADMIN_API_KEY,AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYare each already used by a workflow in this repository.Review fixes
The second commit,
ci: harden the repull token and mask checks, applies the accepted fixes from the review of this pull request. They were made first in the authoring copy (nemarOrg/nemar-cli#1980) and copied here byte for byte. The validation step now checksdispatch_tokenandrepull_idinside itsjq -egate, on the event file. A token of 64 hex characters followed by a newline used to pass, because$(jq -r)strips the newline before the shell sees it, and an emptyrepull_idpassed as if the key were absent; both are refused now. The mask step splits the token at carriage returns as well as line feeds before it masks each line, so a lone carriage return no longer keeps two parts of a value inside one::add-mask::line. Comments only: the second step is named as a token reader, "cancelled" is "canceled", and the validation script's comment says the script never echoes a value without claiming the runner's step header, which prints the job'senv:, is clean. Not applied: theDeploy to:path form on line 3, becausetest/repull-workflow.test.tspins the short form and changing it would churn the pin and both copies for a cosmetic difference. Checked with the review's hostile-event harness (the old file accepts the two holes and masks a lone carriage return inside one line; the new file refuses them and splits; no other case changed, and each guard, mutated alone, is caught),actionlint(no findings), andbun test test/repull-workflow.test.ts(34 pass, 3 skip with the variable unset; 37 pass against the twin's file; a one-byte drift still fails).The third commit,
ci: refuse control characters in the payload, is the last review fix, again made first in the authoring copy (nemarOrg/nemar-cli#1980) and copied here byte for byte. The validation gate gets one more condition,and (.client_payload | [.[] | test("[\u0000-\u001f\u007f]")] | any | not), which refuses a control character in any payload field. An environment variable ends at a NUL, so the checks on the variables saw only what preceded it and step 2 passed a payload that the CLI refused later; the gate reads the event file, which holds all of it. The same condition refuses a final newline, so the separate final-newline guard on the token andrepull_idis removed as redundant. The expression gives identical results on jq 1.8.2, Apple's jq 1.7.1 and Ubuntu 24.04's jq 1.7.1 (the runner's package) over the review's hostile-event harness, which still refuses every case it refused before.actionlintandshellcheckreport nothing on the run scripts. The tests that pin all of this are in nemarOrg/nemar-cli#1980, and each new case fails on its own mutant.Source and verification
The authoring copy is in nemarOrg/nemar-cli on
feature/issue-1913-phase7w-workflow-pair(nemarOrg/nemar-cli#1980) ata3dc47cea58d6d1b7dd2f7a4924355737eaa216a; until that pull request merges into the epic branch, the current copy lives there. It builds on the epic branch's copy at1abf92868e8216b4d1596d6802dea0c7ab2f7e8c, which was last changed in138386fb650568c56d7abf6dbed34ecf88f917fe(Phase 7d, nemar-cli#1963). Blob26cbb2b5340ae13f3004298ac5a96bb49ea9552f, sha256ccb8a657ac61bd43dbc3105efede0c5101bc34e484b76471e91d75cd8a66c259, 345 lines, 20,349 bytes.cmpof this file againstgit show a3dc47cea58d6d1b7dd2f7a4924355737eaa216a:.github/dataset-workflows/run-upstream-repull.ymlexits 0, the added blob id equals the authoring blob id, andcmpof the two files as GitHub serves them from the two pushed branches exits 0.yaml2.8.4 under Bun), andactionlint1.7.12 andshellcheck0.11.0 (on everyrun:script) report nothing.test/repull-workflow.test.ts, run against this branch's file throughNEMAR_REPULL_WORKFLOW_LIVE, passes 37 of 37, and its drift check fails on a one-byte change.No check runs on this pull request, because this repository's
pull_requestworkflows are filtered toscripts/**.Hold
Do not merge yet, and merge only after the owner's explicit confirmation. The file belongs to the shared central workflows that serve about 785 dataset repositories (ADR 0020), and
nemarDatasetsis shared between production and dev.mainrequires no review and no check (its only rule forbids deletion and force pushes), which is why this is opened as a draft.Before the switches are on the file does nothing. It runs only on a
repository_dispatchof typerun-upstream-repull. The only sender is the production Worker, and nowranglervars block setsAUTO_REPULL_ENABLEDor the caps, so the Worker sends none until the owner's reviewed change turns them on after the release.Order: first this pull request; then nemarOrg/nemar-cli#1980, whose Tests run compares this file with the authoring copy and fails while it is missing, so re-run its Tests and merge it into the epic branch; then the epic branch to
devand the release.Before merging, confirm the authoring copy has not moved since the commit above. The hardened copy is on the branch of nemarOrg/nemar-cli#1980 until that pull request merges into the epic branch, which happens after this one, so compare with that branch; once it has merged, the epic branch carries the same bytes. From a nemar-cli checkout, with this branch checked out at
<this checkout>:If
cmpreports a difference, refresh this branch from the new commit and update the hashes above.