Skip to content

Epic: integrate upload and integrity fixes (#1671) - #1702

Merged
neuromechanist merged 199 commits into
devfrom
feature/issue-1671-epic-bru-upload-fixes
Oct 10, 2026
Merged

neuromechanist merged 199 commits into
devfrom
feature/issue-1671-epic-bru-upload-fixes

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Integrates all nine phases of epic #1671 from feature/issue-1671-epic-bru-upload-fixes into dev. The epic branch includes dev through 6271fa79; PR #1701 adds the final #1455 acceptance-evidence correction.

Included phases

Verification

Acceptance still open

These issue-level acceptance gaps remain documented; local and CI checks do not establish them. The original Bruno PRs #1647, #1648, #1649, and #1654 are superseded by the epic replacements and have been closed with comments linking this PR. Original PRs #1650–#1653 and #1655 were already closed.

Release sequencing

This PR may land in dev for staging. Do not promote the stable manifest URL contract to production until eegdash/eegdash-viewer#3 is validated and merged; that PR currently has no check rollup. Website PR #437 targets staging and can follow the CLI dev integration; docs PR #66 targets the live docs branch and should follow the CLI production release.

The epic issue targets dev, not the default branch, so it will need manual closure after this PR merges. The child issues with outstanding acceptance gaps remain open.

bruAristimunha and others added 30 commits October 7, 2026 17:02
The availability-report sweep commits .nemar/availability-report.json to
main through the Contents API. On a dataset that was created but whose
upload had not pushed yet, that PUT created main as an unrelated ROOT
commit. nm000358 (created 2026-10-06 14:55Z, report commit 4ba0a7b at
03:00Z): every later 'nemar dataset upload' attempt failed at 'Pushing
metadata to GitHub' with '[rejected] adjusted/main(unlocked) -> main (fetch
first)', and the adjusted branch cannot be auto-rebased, so the upload Job
failed after 12 attempts and needed a manual merge.

- writeAvailabilityReport checks that main exists (new branchExists: 404 or
  GitHub's 409 'Git Repository is empty' mean no) and refuses with 409
  instead of creating it.
- The sweep's candidates now require a version (a version DOI or a
  dataset_versions row), like ARCHIVE_RETRY_SWEEP_QUERY: a never-versioned
  dataset has nothing to report, and a row the pass cannot complete must not
  hold one of its LIMIT slots forever.
- Test seeds that model reportable datasets now carry a version.
branchExists sent encodeURIComponent(branch) as one component, so release/1.0 became release%2F1.0 and read as absent. It and getMainBranchSha now share one ref request that encodes per segment; 404 retry stays a per-caller choice. Tested against a local GitHub stand-in.
verifyDatasetVersionS3 and the availability report's manifest read built their S3 origin from the literal AWS host, so neither could be driven by a local server. They now pass env.S3_ENDPOINT_URL like the data plane and admin routes do. Unset in every deployment, so no production behavior changes.
The branch check ran after verifyDatasetVersionS3 (a paginated LIST plus manifest walk, up to 30 times per sweep) for rows that were then refused. The GitHub target and the main check now come first on the write path. The 409 message also covers a repository that is invisible to NEMAR, which GitHub reports as the same 404. Route-level tests drive the single-dataset and sweep routes against local GitHub and S3 stand-ins and assert zero PUTs and zero S3 requests when main is absent or the repository is empty, and exactly one PUT when main exists.
The version DOI or dataset_versions row rule was hand-copied from ARCHIVE_RETRY_SWEEP_QUERY into the availability-report sweep. It is now exported once as datasetHasVersionSql from archive-retry.ts and both queries build from it. A test pins that they share it; the candidacy tests keep pinning the behavior.
branchExists slept inside a sweep row under rate-limit pressure (about 60 s per row), treated every 404 as 'no branch', trusted any 2xx, and treated any 409 as an empty repository. It now makes one interactive attempt (never sleeps), probes the repository on a 404 and throws when it is not visible, requires object.sha on a 2xx, and accepts a 409 only when the message says the repository is empty. getMainBranchSha shares the sha check and keeps its retry on 404. Tests cover each case against a local GitHub stand-in, including the retry behavior of getMainBranchSha.
S3_ENDPOINT_URL is now honored only in a recognized non-production environment (testS3EndpointOverride), at the integrity check and the report's manifest read, which now builds its options from getS3Config. A guard test asserts no wrangler vars block declares it. A failed or untrustworthy main lookup (auth, rate limit, 5xx, a repository not visible to NEMAR) is wrapped as a 500 with its cause, logged on the single-dataset route, and distinct from the 409 refusal; sweep error entries gain a status. One REPORT_BRANCH constant names the branch for the guard and the write, and datasetHasVersionSql takes only the two aliases in use.
Route-level tests for the availability report now share one ordered event log across the GitHub and S3 stand-ins. They cover: 403, 401, junk 2xx, 500, non-empty 409 and a repository not visible to NEMAR as 500s with a cause and zero PUTs and zero S3 requests; the 409 refusals with their status marker; the order lookup, S3 walk, PUT; the PUT body (dataset, version, completeness, message, no sha); the token on every GitHub call; the moved 400 and 500 checks; a version-less dataset as a non-candidate; the known LIMIT-slot starvation of a refused row; and that S3_ENDPOINT_URL is ignored in production.
The CLI help, the cron comment and three test headers described the sweep as covering every managed dataset, capped at 10, with sibling routes having no S3 seam. It covers every non-sandbox dataset with a version and no report, AVAILABILITY_REPORT_SWEEP_MAX is 30 (the cron passes no limit), and listObjectPages and verifyDatasetVersionS3 honor S3_ENDPOINT_URL outside production.
verifyDatasetVersionS3 and the availability report's manifest read built the same fenced S3 options in two places, one of them layered over getS3Config's unfenced endpoint. versionReadS3Options is now the one builder; behavior is unchanged.
The write-target block of writeAvailabilityReport (the 400 checks, auth, and the never-create-main guard with its 409) is now resolveReportTarget. Messages, statuses and the order (guard before any S3 work) are unchanged.
Check the 404 first, then any other failure, then release the body once, instead of an early return that cancelled the body separately. Behavior is unchanged.
The LIMIT-slot behavior of a refused row is documented on AVAILABILITY_REPORT_SWEEP_BASE_WHERE; the cron comment, the route doc, the remaining doc and the test point to it. The createOrUpdateFile docblock keeps the warning and the fact that only the availability report guards it, without naming callers, and the fetchBranchRef docblock no longer restates the call sites.
The refusal and fault cases share expectRouteRefusal and expectSweepRefusal; stand-in ref states derive from one answers record; the branch-exists stand-in drops its hit counter and special repository; the rejection helper is shared. New tests pin that the single-dataset route logs a 5xx and only a 5xx. All six faults still run as route, sweep and cause tests.
The root program's '-v, --version' is recognised anywhere on the command
line, so 'nemar dataset release <id> --version 2.0.0' -- the form the
release help documents -- printed the CLI version and exited 0, and a
scripted release (-y) silently did nothing. The '=' form already worked
because the root option is boolean.

Before parsing, bindShadowedOptionValues joins a value-taking option of the
addressed subcommand to its value when an ancestor command declares the
same flag ('--version 2.0.0' -> '--version=2.0.0'). Global flags keep
working anywhere (no enablePositionalOptions); a bare '--version', values
that look like flags, anything after '--', and boolean collisions (#1220)
are left alone.
nemar dataset release <id> --version (or --version -y) still let the
root -v, --version claim the bare flag, print the CLI version and
exit 0: the #1493 silent no-op for a scripted -y release.

When the leaf command declares a required-value option whose long flag
an ancestor also declares and it appears with no value (last token, or
followed by another flag), bindShadowedOptionValues now throws
MissingShadowedValueError. index.ts reports it through the declaring
command, so stderr and exit code are Commander's own:
error: option '--version <version>' argument missing, exit 1.

The "leaves everything else alone" test pinned the old pass-through
for the valueless forms; those cases moved into a new error test on
purpose. nemar --version and nemar -v are unchanged.
test.yml sorts a file into the live-API tier when its text matches
testRequest, TEST_API_URL or runCli(. The helper and the env var here
did, so the #1493 regression test ran only in the soft integration-dev
tier and never in unit-pure.

Rename the helper to spawnCli and point the CLI at a closed local port
through config.json in the isolated config dir, as the offline CLI
tests do. Strip TEST_* variables from the child env so an ambient
setting cannot override the config. The file no longer matches the
tier grep.
The comment said every ancestor option is a boolean; admin recover
declares --recover-file <path> on a command that also has subcommands.
Say what actually holds, and note why the join is harmless when the
ancestor's option takes a value too.
The test kept a hand-written copy of the command tree, which keeps
passing after a flag changes in src/commands. Build the tree from the
command groups src/index.ts registers, under a root declared the way
index.ts declares it, and restore the shared groups' parents after.

Add an invariant over every command in that tree: each value-taking
option whose long flag an ancestor also declares must be joined to its
value. It finds two today, dataset release --version and admin recover
status --recover-file; the second is shared with a value-taking group,
so a test pins that it still resolves through optsWithGlobals().

A drift test compares the test root with `nemar --help`, so a new root
option or top-level command in index.ts fails it until the tree is
updated. Optional-value shadowed options are rejected by a test, since
a bare flag cannot be delivered past the ancestor.
dataset validate declares -v, --verbose and the root declares
--verbose; both are booleans, so the token after the flag is a
positional. Joining them would make the path --verbose=./x and
validate the current directory instead.

Assert dataset validate --verbose ./x is unchanged, and that Commander
then hands ./x to validate as its path. Removing the value-taking
guard in bindShadowedOptionValues fails this test.
The valueless --version entry-point test passed even when index.ts
stopped reporting the error through Commander, because main()'s
generic catch prints the same message. The observable difference is
the bug-report nudge that only a non-Commander exit gets. Assert it is
absent, so the failure stays a usage error.
Only the throwaway root had exitOverride(), so a usage error raised by
a shared command (a missing <dataset-id>) called process.exit(1) and
ended the whole bun test run. Trap process.exit and stderr for the
length of the parse and surface the exit as a failure, with a test
that proves it.

Commander 12 never clears parsed option values, and the shared groups
outlive this file: clear what each parse stored, and give each case
values no other case uses.
Each spawn now has a kill timer and an explicit test timeout, and the
child env drops proxy variables: an unroutable proxy made a loopback
spawn hang for the whole kill window.

The CLI is pointed at a local stand-in backend instead of a closed
port, and the release test asserts the stand-in saw the notices call,
so a config apiUrl that stops being honored fails the test instead of
sending the call to the real API.

The spawn tests used the live dataset id nm000104; use nm099999.
A boolean ancestor option takes the flag and strands its value, which
is what the join repairs. An ancestor option that takes a value
(admin recover --recover-file) consumes the flag and its value
together and the leaf reads it through optsWithGlobals(), so the join
was unneeded there, and it made `admin recover status --recover-file
--json` newly fail.

Shadow only when the outermost ancestor option of that long flag is a
boolean. Only dataset release --version is rewritten now. The tree
invariant separates the two kinds of collision, keeps a non-vacuity
check for each, and pins the admin recover shapes as unchanged and
still resolving.
`dataset release nm1 --version "" --type patch -y` silently did a
patch bump, and without --type it opened a prompt that hangs on a
closed stdin: the release handler tested `options.version` for
truthiness, so an empty value read as no --version.

Fix both layers. The pre-pass treats an empty next token as a missing
value (Commander's "argument missing", exit 1). The handler tests
`!== undefined`, so the `--version=` spelling, which reaches it as "",
gets the existing "Invalid version" exit 1.

Entry-point tests run the real CLI against a stand-in backend whose
dataset names a repository that does not exist, so a regression fails
at the clone instead of touching a real dataset repository.
`release --help --version` and `release nm1 --version --help` now
fail with "argument missing" instead of showing the help that was
asked for, because the missing-value error fired first.

When --help or -h appears before `--`, drop the bare shadowed flag
instead of throwing. Left in the argv, the root would claim it and
print the CLI version, so it has to go. A flag that has a value is
still joined, and `--help` after `--` is an operand and does not count.
Commander reads a lone "-" as an option value (the usual spelling of
stdin), but the pre-pass counted it as a flag and rejected
`--version -` as a missing value.

A lone "-" now joins like any value. Any other dash-leading token is
still read as a flag, so a value that starts with "-" has to be spelled
--flag=value; a test and the code comment say so.
`dataset --version 2.0.0 release nm1 -y` and `dataset --version
release nm1 -y` printed the CLI version and exited 0: the leaf walk
stopped at the flag's value, and `dataset` does not declare the flag,
so the root claimed it. The `=` spelling cannot be rewritten into
place either; Commander has `dataset` reject it as an unknown option.

Remember a shadowed flag typed below the root and ahead of the command
that takes it, step over its value so the walk still finds that
command, and throw MisplacedShadowedOptionError. index.ts reports it
through the command like the missing-value error. At the root the flag
stays the root's own (`nemar --version dataset release ...` prints the
version), and a flag after the command's name is unaffected.

Pins `--` ahead of command names and the root-level shapes.
An unexpected throw from bindShadowedOptionValues escaped main() as a
bare message that read like a failure of the command the user typed.
Rethrow it as "argv pre-pass failed: <message>" with the original as
the cause, and leave the bug-report nudge on it, since that is a bug.

Explain at the catch that command.error() exits, and that going
through it runs the exitOverride whose markUsageExit() suppresses the
nudge for the mistyped-option errors. Checked by hand with an injected
throw: the pre-pass has no input that fails unexpectedly, so no
automated test can reach this branch.
Removing the alias lookup in the leaf walk failed nothing: the only
alias in the real tree, dataset status|view, has no shadowed option,
and no real option takes an optional value or collides on a short flag.

Run the join over every alias spelling of each real path, and add a
minimal tree of real Commander objects that has an aliased command,
a short-flag collision, an optional-value collision and a flag claimed
by both the root and a group. Each of those branches now fails a test
when it is mutated away.

Copy link
Copy Markdown
Contributor Author

Review of #1702 with the pr-review-toolkit roles

Head b549bb6a against dev (6271fa79). The diff is 192 files (+21,174 / -1,715), so the six toolkit roles (code-reviewer, silent-failure-hunter, pr-test-analyzer, comment-analyzer, type-design-analyzer, code-simplifier) were split into ten scoped reviews. Every reviewer ran as Sonnet 5.5 at high effort, read-only, on a checkout of the PR head. The two test reviewers also ran mutation checks in private copies, and several reviewers ran the real CLI or git-annex.

Items marked (confirmed) were re-checked directly in the code by the coordinating session. The rest are reviewer findings with evidence attached. CI is green on this head. The acceptance gaps already declared in the description (live S3 expiry, the 550 GB upload, chunk-byte acceptance, the #1399 back-catalogue) are not repeated here.

Summary

  • Upload pipeline. No reviewer found a way for a data file to be lost, or reported as uploaded or saved without a location-log record at the remote, on the main path. The save step and the S3 step both fail closed, and the retry accounting holds up.
  • Main gap: tests. Most tests are strong: they use real git, git-annex, bare remotes and spawned CLIs. Of the 28 single-line mutations the two test reviewers applied to production code, 20 were caught and 8 survived. The survivors cluster in two places: the new chunked annex GET (chunked-delivery.ts and the annex path in routes/data.ts have no direct test) and the Upload: S3 credentials expire after 2 h and the copy cannot renew them #1644 credential renewal and retry accounting (no test runs it). Details below.
  • Most likely to hurt users: the recorded-file check on resume can run one git annex copy process per file, about 11 to 13 times slower than the estimate the CLI and ADR 0094 print.
  • Scope. The diff also contains work that is not in the description's nine phases: hardening of the PR-review dispatch (ADR 0092, run-pr-review.yml), a new migration 0094_guard_retired_password_signup.sql, auth route edits, and the ADR renumbering (0094 to 0096, 0095 to 0097). Those were reviewed too and look sound, but listing them in the description would help whoever reads the release notes.

Before merging to dev (suggested)

  1. Add tests for the chunked annex delivery. No test references resolveAnnexDelivery, the x-nemar-chunk-get-budget protocol, listObjectSizesBounded or MAX_SERVABLE_CHUNKS, and this PR deletes the old route-level test "GET on an annexed file redirects with the manifest's headers" without replacing it (confirmed). I applied two mutations in a private copy, the end-of-body byte check (chunked-delivery.ts:397) and the plain-object size check (:87). The four closest data-route test files still passed (108 pass, 0 fail). The reviewer also found that removing the range check (:321) survives, across 26 files. Suggested backend/test/data-route-annex-delivery.test.ts, using a local S3 server like s3-manifest-standin.ts: a truncated chunk, an overrun, a wrong-size plain object, 416, an incomplete chunk set (502), the listing cap (503), If-Range, multi-chunk range slicing, a private dataset on the annex GET, and the chunk budget header. Assert on the bytes read from the body, not only the status.
  2. Test the credential renewal and retry accounting (Upload: S3 credentials expire after 2 h and the copy cannot renew them #1644). No test in test/ or backend/test/ references renewLease, leaseFromResponse, planCopyBatches, onCredentialsRenewed, isExpiredCredentialError or uploadCredentialsNeedRefresh (confirmed), and test: remove loopback S3 renewal test #1696 removed the only test that ran this path (test/upload-sts-refresh.integration.test.ts, 218 lines). Making uploadCredentialsNeedRefresh always return false, and disabling batch splitting in planCopyBatches, both left the suite green. The acceptance gap against real S3 is declared, but the decision logic does not need S3: copyAnnexedToRemote already takes lease, renewLease, onCredentialsRenewed, batchMaxFiles and batchMaxBytes, and a real directory special remote ignores the credential values. Suggested: an already-expired lease with a counting renewLease (renews before the copy and before each recorded-check chunk), a renewLease that always returns an expired lease (reaches the 48-renewal cap message), batchMaxFiles: 1 with onPlan.copyBatchCount, and pure tests of the planCopyBatches bounds. The comments on batchMaxFiles and batchMaxBytes (transfer.ts:1259, :1838) still cite the removed integration test.
  3. Size the recorded-file check from args.dataFiles. src/lib/upload/transfer.ts:1361 builds recordedCheckSizes from addTargets only, so on a resume every other recorded file has an unknown size and gets its own process (confirmed). Three reviewers measured this independently: 40 files took 1.9 s against 0.17 s, 150 files took 7.0 s against 0.54 s, and a third run took 7.7 s against 0.68 s. One tested the fix (const recordedCheckSizes = pendingSizes;) and got 7,660 ms down to 464 ms with identical results. Otherwise the printed estimate (recorded * 0.075 / jobs) and ADR 0094's "about 5 minutes for 15,000 files" stay understated by the same factor. planRecordedCheckBatches also reproduces planCopyBatches; the simplifier checked equivalence on 20,000 random inputs.
  4. README read failure in publish-request now blocks. submission-gate.ts:131-146: a failed README.md read for a native request sets readme = null and then the ethics rule returns a 422 telling the submitter to add a statement. On dev the same failure was logged "(non-fatal)" and the request went to admin review (confirmed). A code comment makes this deliberate, but its reason (an unreadable README must not open the Name and Authors rules) does not need this effect, because the description alone decides those. Returning unverified(err) for both callers matches what the sweep already does.
  5. Type the writer side of the block reason. publication.ts:294 is let blockReason: string | null (confirmed). A misspelled reason compiles, skips the CI-pending branch, and is stored with a value the sweep never selects. PublicationBlockReason | null is a one-line change and every current assignment fits.
  6. Fix the documentation the code contradicts. ADR 0064's new amendment says the data plane does not serve chunked keys, which ADR 0095 now contradicts. ADR 0031's amendment says the Decision "now reads" a sentence that the body (the diff is +74/-0) does not contain. ADR 0097 says migration 0094 clears hashes and then installs the trigger, while the SQL installs the trigger first. ADR 0095 cites .claude/issue-1565.local.md, which .gitignore excludes. transfer.ts:1230 says "step 4" where it means step 5. buildAnnexPublicUrl has no callers or tests, and its comment says "kept for internal callers".

Before the stable manifest URL contract goes to production

  1. Decide Content-Length on the streamed annex response (routes/data.ts near line 1487). It is set by hand on a ReadableStream body (confirmed), and .memory/bun-test-lenient-vs-workerd.md records that workerd drops it and that only a live test can show it. A mid-stream error should still surface as an aborted chunked body, so the loss is the advertised length. Use FixedLengthStream, or drop the header and say why, then check it live as test/git-broker-live.test.ts did for the git path.
  2. Align the integrity audit with what the data plane can serve. The listing prefix is <backend>-s<size>-S with no hash (confirmed), so chunked files of exactly the same byte size share one 512-object listing and hit a permanent 503 together. A file with more than 512 chunks gets a 502. Meanwhile verifyDatasetVersionS3 can report data_complete = 1, and a 503 invites clients to retry forever. Cap the audit at MAX_SERVABLE_CHUNKS, or return a non-retryable status with a distinct body, and say "more than 512" in ADR 0095.
  3. Fence S3_ENDPOINT_URL everywhere. Only import-integrity.ts uses testS3EndpointOverride. routes/data.ts:107, routes/admin/shared.ts:24 and neurobagel-writer.ts:315 read it raw (confirmed), and the data plane now makes its own authenticated S3 calls.
  4. Per the description, Proxy stable NEMAR manifest file URLs eegdash/eegdash-viewer#3 must be validated first.

Follow-ups (suggested as issues)

  • Annex-branch push failure is warn-only (clone-push.ts:1156, finalize.ts:306). pushMetadata stamps github_push and the run ends "Upload complete!". import-openneuro.ts:1424 treats the same warning as fatal. Pre-existing on dev, but this PR hardened the neighbouring cases (confirmed).
  • A .gitignore-hidden small data file is warned about once, marked uploaded, and the run ends "Upload complete!" (transfer.ts:1319 and :2029). It is deliberate and pinned by test/upload-s3-copy-step.unit.test.ts:618, so repeating the names in the final summary would close the gap (confirmed).
  • Availability report starvation. Refused rows (409) stay unstamped and ORDER BY dataset_id LIMIT 30 serves them first. The code comment declares it, but there is no bound. A last-attempt stamp or rotation would fix it.
  • dataset update (dataset.ts near 3510 to 3600) still warns on a failed S3 copy, then pushes and opens the PR. nemar sandbox returns exit code 0 on every failure branch. Both predate the PR.
  • Migration 0094. The trigger is permanent, though it is only needed for the window between 0093 and the deploy. Its test lacks negative controls: dropping NEW.password_hash IS NOT NULL from the WHEN clause survived. Add a NULL-hash insert, the ORCID web shape and email_verified = 1.
  • PR-review tests. The "unpublished anonymous deposit" test cannot detect removal of d.anonymous = 0 (it also sets first_published_at = NULL). dataset_not_reviewable is not in PR_REVIEW_LOGGED_SKIPS, so that skip leaves no log line (confirmed).
  • Tracking inactivity warning (Bound git-annex add concurrency during dataset upload #1455). Only the low-level timer is tested. Dropping the onInactivityWarning forwarding in gitAnnexAdd (init.ts:557) fails nothing. The final-save warning has an end-to-end test, but tracking has no equivalent because gitAnnexAdd and trackDataFiles expose no threshold option.
  • CLI details. --annex-jobs uses Number(), so 1e1 and 0x10 pass, with no upper bound (-J100000 is accepted), while --jobs uses /^\d+$/ (confirmed). The post-push failure hint says "refused" for every failure and names no retry command. A clone that git-annex auto-initialized can never push its annex branch, and the error offers no remedy. init.ts:566,580 print raw file names instead of displayName.
  • Test hygiene. Six CLI tests failed in a root sandbox (annex-add-batch twice, upload-s3-copy-step "lost objects cannot be sent again", annex-init-description three times), because they rely on chmod or os.userInfo(). upload-success-next-steps.test.ts:226 and anonymity-publication-paths.test.ts assert on source text. chunked-key-availability.unit.test.ts and import-integrity-chunked.test.ts claim more than they drive. run-command-inactivity.unit.test.ts has tight timing bounds. git-init-branch-fallback.unit.test.ts uses a fake git shell script: it is disclosed and its mutation checks pass, but it is the closest thing to a NO MOCK exception. Two release-version-flag.test.ts tests attempt a real GitHub clone when gh is present.
  • Types. CopyOutcome and RemoteHoldsOutcome are flat {success; error?} records, which forces as T in runRecordedCheckChunk and the ?? "Failed to ..." fallbacks. AnnexDelivery.streamed lets status and contentRange disagree. BoundedS3ObjectList lets a capped listing be read as a complete map.
  • Simplifications (optional): the credential-renewal state machine is written twice in transfer.ts, copyAnnexedToRemote and transferAnnexedData are each 230 to 250 lines, resolveAnnexDelivery is about 240, and NUL-separated listing and shell quoting are each duplicated three to five times.

Questions for owners

  • isKeyPresentAtDeclaredSize now treats a complete chunk set as present (confirmed). import-openneuro.ts:1589 (the publish gate), fleet-key-registration.ts and fleet-content-recovery.ts use it. If NEMAR's S3 remote has no chunk= setting, which I did not confirm, git annex get cannot fetch such a key. Is that intended?
  • scripts/scrub/s3/s3-lib.ts builds objectKey as <dataset>/objects/<annexKey> with no chunk awareness (confirmed). This predates the PR, but chunk-only datasets are now treated as served and complete. Does a privacy scrub (ADR 0085) of such a dataset fail loudly or skip its chunks? I did not trace this.
  • A git-tracked blob missing upstream now answers 502 instead of 404, and the Neurobagel gather's absent-table check depends on a 404. Is a manifest-listed but missing table now meant to refuse the gather?

Mutation checks by the test reviewers

Side Applied Caught Survived
Backend 13 8 chunk end-of-body byte check, plain-object size check, unsatisfiable-range check, migration 0094 WHEN loosened, d.anonymous = 0 removed
CLI 15 12 onInactivityWarning forwarding in gitAnnexAdd, uploadCredentialsNeedRefresh always false, batch splitting disabled in planCopyBatches

What held up

Action plan

  • Add the chunked annex delivery tests (item 1).
  • Add the renewal, retry-cap and batch-splitting tests (item 2).
  • Size the recorded-file check from dataFiles and correct the estimate and ADR 0094 (item 3).
  • Return unverified for a README read failure in publish-request (item 4).
  • Type blockReason as PublicationBlockReason | null (item 5).
  • Fix the ADR 0064, 0031, 0097 and 0095 statements and remove buildAnnexPublicUrl (item 6).
  • Before production: settle Content-Length with a live check, align the audit with serving limits, fence S3_ENDPOINT_URL, and validate eegdash-viewer#3 (items 7 to 10).
  • Open follow-up issues for the list above, and answer the three owner questions.
  • Re-run the affected reviews after the fixes.

Generated by Claude Code

copyAnnexedToRemote sized the recorded-file check from addTargets
only. On a resume that adds a few files, every other recorded file
had an unknown size and was checked in its own git-annex process.

Size it from the full data-file inventory, as the pending copy
already is. Only a path missing from the inventory is still checked
alone. Resume check on 80 recorded files plus one new file: 2.5 s
down to 0.5 s on a local directory remote, same result.

Claude-Session: https://claude.ai/code/session_01YXQWmd9X8QG9diuUNQ1PaF

Copy link
Copy Markdown
Contributor Author

Direct push to the epic branch: c17021d

Pushed straight to this branch at the requester's explicit instruction, which waived the .rules/git.md rule against committing src/ changes to an epic branch without a PR. It is one commit, and it follows from item 3 of the review above.

Change (2 files). src/lib/upload/transfer.ts now sizes the recorded-file check from the full data-file inventory (args.dataFiles) instead of addTargets, so a resume that adds a few files no longer starts one git-annex process per recorded file. A path missing from the inventory is still checked alone. ADR 0094 is reworded to match.

Checked.

  • bun run typecheck and Biome are clean.
  • upload-recorded-check, upload-s3-copy-step, upload-transfer-recovery, upload-data-steps and adr-index give the same result as on b549bb6: 112 pass, 1 fail. The failure ("lost objects cannot be sent again") also fails on the old head when run as root, because chmod 0555 does not block root.
  • A resume with 80 recorded files and one new file took about 2.6 s before and 0.5 s after, with the same ok result (local directory remote).

Deliberately not done. The new tests and other items from the review were skipped because they would not change production behavior. The chunked delivery and the credential renewal therefore have no automated guard beyond the live checks this PR already requires before the stable manifest URL contract reaches production.

Merging into dev once CI is green on this head.


Generated by Claude Code

@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1702

Version: 0.10.16-PR1702.c17021d
Commit: c17021d


🤖 Updated on each push.

This branch was previously deployed

1 inactive deployment
npm — c17021d3 Deployed Oct 10, 2026 by neuromechanist via publish #3333
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.

3 participants