Skip to content

fix: round 1 review fixes for the upstream freshness epic - #1984

Merged
neuromechanist merged 67 commits into
feature/issue-1046-epic-upstream-freshnessfrom
feature/issue-1046-review-fixes
Oct 27, 2026
Merged

neuromechanist merged 67 commits into
feature/issue-1046-epic-upstream-freshnessfrom
feature/issue-1046-review-fixes

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

This PR carries the fixes for the round 1 review of #1983, which merges the upstream freshness epic (#1046) into dev. It targets the epic branch, because the epic branch bars direct commits.

Each finding has one outcome: fixed in this PR, rejected with the reason, verified with the evidence, or an owner action.

Findings and outcomes

Finding Outcome
Mirrors whose version rows carry a v prefix read as unpublished, so staleness was understated Fixed: mirroredTagOf reads vN.N.N rows, the backfill examines them too, and the cursor carries the spelling
The administrator's BIDS override could not be reached, because resume only recorded gates on clean Fixed: resume records gates on a head whose only failing check is BIDS validation; the merge refuses the override when another check fails; ADR 0111 records the live GitHub check
The G4 gate could wait forever on a missing dataset with no reason in the weekly report Fixed: the weekly report gives the reason while the automatic switch is on
The OpenNeuro endpoint override was honored in production Fixed: production honors only a loopback http override (the tests use one); a test matrix pins the rule
Live-tier merge-gate tests could skip silently when a required tool was missing Fixed: the tool check throws when CI is set; the CI jobs install or check their tools
Nine merge-gate CLI suites reached the live tier because a header comment named the variable Fixed: the suites are hermetic, and the comment no longer names the variable
Canned success stubs bypassed real code paths in three tests Fixed: each uses a loopback stand-in the code really calls; the policy note is restored
The merge-path guards had no tests for non-gates_clear rows, patch rows and credential order Fixed: tests reach each refusal through the real function, and assert that no claim row is written
Locale and UTC-day tests passed vacuously without their environment Fixed: the German test installs its locale in CI; the UTC-day test waits out the last two seconds before midnight UTC
Timing data covered 25 of 109 pure test files Fixed: regenerated through the process in test.yml
The IAM collaborator tests failed with 403 when the dev fixture lost its row Fixed: they fail with "Missing precondition" and name the row. The durable fix is an owner action (see below)
Four older ADRs said the work was not built Fixed: dated annotations, append-only
AGENTS.md stated the switch and merge rules too broadly Fixed
Version patterns were duplicated, and one constant was unused Fixed: one definition for each pattern; the unused constant removed
Trailers were hand-written at three sites Fixed: every commit writes its trailers through one builder
The plan read trusted bucket, region, dataset id, tag, version and commit ids Fixed: each is refused with the field named
approve --merge exited 1 on a held merge claim, while repull merge exits 3 Fixed: both exit 3
A patch record without counts gave no way out in its message Fixed: the message names nemar admin repull abandon
The plan text said plan writes nothing Fixed: qualified for --automatic-dispatch
The git shim in the mirror-major test could reach GitHub on a regression Fixed: the shim refuses clone, fetch, pull, push and ls-remote
The publication dedupe branches were not all pinned by tests Verified: all three branches are pinned by existing tests
Migrations 0104 to 0106 sort below dev's 0107 to 0111 Verified: wrangler selects migrations by name (wrangler 4.85.0, wrangler-dist/cli.js)
Deferred dispatches are counted neither toward the open bound nor the daily cap Rejected: intentional; ADR 0111 documents it
The "* -> failed" transition has no code Rejected: an owner open item named in ADR 0111
The workflow header says "held" in the org copy and the authoring copy Owner action: the org copy changes first, then the authoring copy follows in a separate PR

Owner actions

  • Re-seed the dev fixture: restore test-user's collaborator row for nm099999 in dev D1 (the seed statement is in scripts/seed-dev-db.sql, around line 85). Every API route that writes the row first adds the GitHub collaborator, so the API cannot restore it without a GitHub side effect. Until this runs, integration-dev stays red, and the release to main is blocked, because integration-dev is required there.
  • Before the release: the production S3 identity must allow s3:GetObjectRetention, because publication lock retries depend on it.
  • Approve the comment-only change to the org copy of run-upstream-repull.yml on nemarDatasets/.github main. Its header says "held," which is false. The authoring copy follows once the org copy merges, because a test pins the two byte for byte.

Not in this PR

  • The two docs pages that say a re-created tag is compared by tree: nemarOrg/docs#93.
  • The question whether nemarDatasets/.github PR 144 was approved on 2026-10-24, although its body said not to merge yet.

Verification

Gates on the head: bun run typecheck exit 0; bun run lint exit 0; Biome exit 0 on the 84 changed code files.

Changed pure test files, each run on its own: all 34 ran their tests, 916 in total, which matches the union run below. test/scrub/require-tools.test.ts belongs to the scrub tier by design (bunfig.toml keeps test/scrub out of a bare run), and it passes under the flags of bun run test:scrub (8 pass, 0 fail).

The union of the changed pure test files in one run: 900 pass, 16 skip, 0 fail, exit 0 (34 files ran; the per-file run above accounts for each one).

CI on this PR is reported in the PR conversation once the run completes.

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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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).
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.
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.
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.
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.
"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.
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.
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.
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.
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.
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.
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.
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).
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).
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.
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.
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.
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.
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.
The state word shown when GitHub's mergeable state cannot be printed
reads "unrecognized".

Tested: Biome and typecheck in the hook.
…sonnet' into feature/issue-1046-review-fixes
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.
…sonnet' into feature/issue-1046-review-fixes
@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@PR1984

Version: 0.10.26-PR1984.d802a5c
Commit: d802a5c


🤖 Updated on each push.

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.
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).
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.
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.
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.
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).
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).
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.
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.
…sonnet' into feature/issue-1046-review-fixes
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).
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.
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.
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.
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.
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.
@neuromechanist
neuromechanist merged commit 577ffce into feature/issue-1046-epic-upstream-freshness Oct 27, 2026
24 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-1046-review-fixes branch October 27, 2026 21:05

This branch was previously deployed

1 inactive deployment
npm — d802a5ce Deployed Oct 27, 2026 by neuromechanist via publish #4075
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