Skip to content

Read datasets held on an authenticated data host - #1978

Merged
neuromechanist merged 18 commits into
devfrom
feature/authenticated-data-host
Oct 27, 2026
Merged

neuromechanist merged 18 commits into
devfrom
feature/authenticated-data-host

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Closes #1977.

Some datasets are held on an authenticated NEMAR data host: the host serves their git repository behind the NEMAR API key and their annexed objects one by one. This lets nemar read them without ever sending the key anywhere but that host (ADR 0114, proposed).

  • src/lib/data-hosts.ts: the allow-list of data host origins: https://private.nemar.org in a production build, https://private-test.nemar.org in a dev build, plus NEMAR_DATA_HOSTS from the environment (loopback http only through it, for tests); NEMAR_DATA_HOSTS_ONLY=1 narrows the list to exactly that. Nothing a repository holds can widen it.
  • git-annex-remote-nemar, a second bin: a read-only git-annex external special remote. PREPARE refuses a host not on the list before any request; TRANSFER RETRIEVE sends the key only to the configured origin and follows at most three redirects by hand, dropping Authorization on any other origin; CHECKPRESENT is a HEAD; store and remove are refused; no output carries the key or a redirect address.
  • nemar auth git-credential (hidden): a git credential helper that answers only for allow-listed origins, so a clone keeps the helper and never the key; it prints nothing else on stdout.
  • nemar dataset clone: an id the API does not know, or --host <origin>, is looked up on the allow-listed hosts and cloned from <origin>/git/<id>.git with the helper; nemar dataset get in such a clone skips the S3 credential fetch and gets through the special remote.
  • Packaging: the build emits both bundles; the dev publish step rewrites the API address in both.

Why not the generic web remote with annex.http-headers-command: it sends the header to every URL a repository registers, so any writer could collect readers' keys, and it forwards the header on redirects.

Test plan

  • bun run lint, bun run typecheck, bun run build
  • New suites (128 tests): the special remote over its real protocol as a child process against a local data host and a second origin that refuses Authorization; credential helper; host lookup and clone; packaging; allow-list parsing
  • End to end with real git and git-annex 10.20261006: clone through a stand-in host, nemar dataset get, git annex fsck; the redirect origin never sees Authorization, a foreign URL a writer registered never receives a credential, the clone's config holds no key
  • Unit-pure tier locally: one pre-existing failure (account-copy-parity "website parity"), unrelated
  • After merge: clone and get a fixture dataset from the dev data host with a dev build

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1978

Version: 0.10.26-PR1978.808c7a5
Commit: 808c7a5


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 132685e into dev Oct 27, 2026
20 checks passed
@neuromechanist
neuromechanist deleted the feature/authenticated-data-host branch October 27, 2026 08:11
neuromechanist added a commit that referenced this pull request Oct 27, 2026
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).
neuromechanist added a commit 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 branch was previously deployed

1 inactive deployment
npm — 808c7a5c Deployed Oct 27, 2026 by neuromechanist via publish #4044
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant