Repository navigation
Epic: integrate upload and integrity fixes (#1671) - #1702
Conversation
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.
chore: sync latest dev into issue 1671 epic
chore: sync latest dev into epic #1671
* docs: clarify 1455 benchmark acceptance * docs: fix 1455 test wording
Review of #1702 with the pr-review-toolkit rolesHead 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
Before merging to
|
| 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
release --version(dataset release --version <X.Y.Z> is swallowed by the root --version flag #1493) was run against the real CLI: values reach the handler, a missing value fails with a clear error, and the shadowing cases behave as the code says. All six spawned-CLI tests fail when the pre-pass is removed.shared/openapi.jsonregenerates byte-identical to the committed file.- The chunked delivery fails closed at every uncertain S3 answer, counts bytes per chunk, and signals a mid-stream failure.
- The git annex init publishes the depositor's username, host and local path #1399 privacy guard is tested against real bare remotes and asserts on their contents. The Upload: git init -b fails on git older than 2.28 #1645 fallback is tested under English, German and empty git output, and the Upload: "Uploaded 0 data files" after a copy that sent everything, and the post-copy check skips files #1642 and Data plane and manifest.json build plain annex object URLs, so chunked datasets 404 #1565 mutations were all caught.
- The availability, branch-exists, sweep-release and PR-review claim tests each failed when the guarded line was removed.
- The recorded-check stamp, the fsck retry design and the signal handling were checked against a real git-annex. The numeric claims in ADRs 0031, 0086, 0090, 0094 and 0095 were recomputed and hold.
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
dataFilesand correct the estimate and ADR 0094 (item 3). - Return
unverifiedfor a README read failure inpublish-request(item 4). - Type
blockReasonasPublicationBlockReason | null(item 5). - Fix the ADR 0064, 0031, 0097 and 0095 statements and remove
buildAnnexPublicUrl(item 6). - Before production: settle
Content-Lengthwith a live check, align the audit with serving limits, fenceS3_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
Direct push to the epic branch:
|
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1702Version: 🤖 Updated on each push. |
Summary
Integrates all nine phases of epic #1671 from
feature/issue-1671-epic-bru-upload-fixesintodev. The epic branch includesdevthrough6271fa79; PR #1701 adds the final #1455 acceptance-evidence correction.Included phases
main(Phase: availability report never creates main #1672).--versionreaches the release command (Phase: release --version reaches the command #1673).git init -bcompatibility fallback (Phase: git init falls back when -b is unsupported #1676).-J4/--annex-jobs, and S3 worker validation (Phase: batch-feed local annex add paths #1688, Warn on idle annex tracking #1689, Upload: warn when final save has no output #1690, Upload: set bounded local git-annex workers #1692, fix: validate upload S3 worker count #1694).Verification
41188e96: 330 passed, 13 skipped, 0 failed; 1,315 expectations across 16 files. The later PR docs: correct #1455 benchmark evidence #1701 changes only test-requirement documentation.bun run typecheckandbun run lintpassed on final epic headb549bb6a.Acceptance still open
sandboxCommandacceptance.git add -A, and real-data warning persistence.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
devfor 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 targetsstagingand can follow the CLIdevintegration; 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.