Skip to content

Phase: verify every annexed file reached S3 - #1677

Merged
neuromechanist merged 59 commits into
feature/issue-1671-epic-bru-upload-fixesfrom
feature/issue-1642-copy-verify
Oct 9, 2026
Merged

neuromechanist merged 59 commits into
feature/issue-1671-epic-bru-upload-fixesfrom
feature/issue-1642-copy-verify

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On nm000358 (165 data files, 1.6 TB) a resumed upload printed "Uploaded 0 data files to S3" although git-annex had recorded all 165 keys at nemar-s3, and then spent hours in "Saving dataset changes": git annex add stages unlocked files with zero stat data, so the following git add -A streams every annexed file through git-annex filter-process (about 1.6 TB re-read) (issue #1642, part of #1455).
The S3 step now copies exactly the annexed paths the location log says are not yet at nemar-s3, requires every annexed file to be recorded there afterwards, and the save step skips the content re-read for large uploads.

The first commit is the contributor's original fix (PR #1647, bruAristimunha), preserved with authorship.
The commits on top are review refinements:

  • git annex copy runs with --json --json-error-messages and success records are counted; the step logic is extracted into copyAnnexedToRemote (plan, refuse, copy, verify every annexed file is recorded at the remote) and is driven by tests against real git-annex and a real directory special remote named nemar-s3; wording says "recorded at the remote" because it is the location log, not a bucket HEAD
  • the save-step skip (assume-unchanged around git add -A, status and commit) only applies when the recorded annexed bytes reach SAVE_SKIP_MIN_BYTES (1 GiB, a conservative start and not a measured crossover), so a small tree takes exactly the baseline path with no listing, no stat pass and no index rewrite; the S3 step's annexed set is forwarded to the save instead of being listed again
  • the skip is guarded: a stat check against the progress record fails the save for any annexed file that changed since it was tracked ("Re-run the upload command to re-track them", first 3 paths named) and runs again after the commit; stale assume-unchanged flags on annexed paths (a killed process between mark and unmark) are cleared at every saveDataset entry, including deleted and locked files, leaving a user's own flag on a non-annexed file alone; unmarking is in a finally; a marking failure warns and proceeds without the skip
  • the blocked branch (a large data file that git-annex did not annex) now recovers: it unstages the staged blobs with unstageTrackedPaths (moved to git-annex/init.ts) and clears the tracking stamp so a re-run actually re-tracks, names both .gitattributes annex.largefiles and .gitignore as causes, and prints the exact manual unstage command if unstaging fails; STS credentials are now cleared on every outcome (they leaked on the blocked path)
  • the annex size threshold is 100,000 bytes, written as an exact count: git-annex reads largerthan=100kb as SI (a 100,001 byte file is annexed), while the CLI's constant was 100 x 1024, so files of 100,001 to 102,400 bytes were annexed by git-annex but called small by shouldAnnex; no dataset's tracking changes, only the CLI's classification and the text derived from the constant; isCurrentLargefilesExpression makes the fleet scan accept the 100kb spelling that about 204 datasets are configured with, which would otherwise have read as drift; boundary tests run both spellings against real git-annex
  • case variants of data globs (X_MOTION.tsv, whose exclude=*.tsv matches while include=*_motion.tsv does not) are tracked with --force-large through trackDataFiles; every other data file is added normally, so an inherited .gitattributes override still leaves an ordinary data file in git and the not-annexed check stays meaningful; a re-run is idempotent
  • git annex copy failures are reported with their reason: when git-annex declines a remote before trying, the error-messages list is empty and the reason is only in note, so the old parse printed "file: failed"; messages are de-duplicated; tests use real failing output captured live from a read-only and a missing store rather than hand-written JSON
  • an amendment to ADR 0031 records the threshold unit, the case-variant rule, and a measured known gap

Part of epic #1671. Supersedes #1647 (contributor PR retargeted to the epic branch). Issue: #1642.

For the owner to review

  • Resume freshness now includes the S3 destination. The fingerprint covers the remote name plus the effective arguments passed to configureS3Remote (bucket, normalized prefix, region, multipart size, public URL, protocol and fixed options); credentials are excluded. A real git-annex directory-remote test reconfigures the same remote name to a second store and proves the new destination is populated. Removing target identity from the fingerprint made that regression fail; restoring it made the test pass. A no-pending resume still skips opening the remote under ADR 0092, so an externally changed destination on that no-op path remains outside this check.

  • Remaining test boundary. The sandbox tests exercise saveAndPush with a real repository and bare origin. Full sandboxCommand orchestration reaches the shared backend, GitHub org and S3; its entrypoint coverage gap and required isolated staging conditions are recorded in test_requirements.md.

  • ADR 0031 amendment (binding text, three sections): the threshold is 100,000 bytes; the CLI's selection is authoritative for case variants of data globs; and a known gap, below.

  • Known gap, measured and not fixed here: git annex init writes * filter=annex to .git/info/attributes, so the save's git add -A does annex by annex.largefiles (ADR 0031's earlier claim that it does not is false). An uppercase METADATA file over the threshold (for example a 200 KB BIG.JSON) is annexed at save time, after the S3 step, so its content never reaches S3 and the commit carries an unresolvable pointer. It needs an uppercase metadata extension that BIDS validation should reject. A post-save git annex find --not --in nemar-s3 would catch it (0.2 s at 600 annexed files, 3.7 s at 10,000), but a re-run does not copy a file no add target names, so the check could not be cleared by re-running. To be filed as a follow-up.

  • Ceph numbers cannot be reproduced here. Please re-measure on the nm000359 host; 1 GiB is a conservative gate (the Ceph tree is 72 MB of annexed data, nm000358 is 1.6 TB).

  • The docs.nemar.org validated-workflows page still says largerthan=100kb; both spellings are correct and it can move to the byte count when next edited.

Behavior to know about

  • The skip defers the re-read, it does not remove it: entries stay zero-stat, so the first git status after a skipped save re-hashes everything (339 ms at 600 files, 4.5 s at 15,000, against 12 ms and 45 ms after a plain save). At 1.6 TB the next git status or nemar dataset update pays for it once.
  • Below the gate the save is the baseline path plus one cheap extra walk (the early not-annexed check). Local timings, directory remote: a 600 x 120 KB annexed .edf plus 600 JSON tree saves in about 1.0 to 1.1 s below the gate and 0.8 s with the gate open, against 1.2 s at baseline; a 15,000-file tree takes 10 to 12 s below the gate and 5.6 to 6.2 s with it open, against 9.7 s at baseline.
  • Production copy chunks at 500 paths, which costs about 6 s per 10,000 paths on a fresh upload where everything is pending.
  • Large uppercase-extension data files such as X.EDF were never committed to git: the production expression ORs the size clause, so they annex by size. An earlier hypothesis that they would be refused by the new blocking check was wrong; only the uppercase _MOTION.tsv case needed the force step.

Test plan

  • bun test test/copy-json-real.unit.test.ts test/run-command-redaction.unit.test.ts test/upload-data-steps.unit.test.ts test/upload-recorded-check.unit.test.ts test/upload-s3-copy-step.unit.test.ts test/upload-save-failures.unit.test.ts test/upload-transfer-recovery.unit.test.ts — 133 pass, 0 fail across seven files, using real Git, git-annex and directory remotes.
  • bun run typecheck (root and backend), bun run lint, Biome check on 12 changed TypeScript files, and git diff --check.
  • The CI-tier grep (testRequest|TEST_API_URL|runCli\() finds no matches in these seven test files.
  • Target-identity mutation proof: removing the identity from the fingerprint makes the destination-reconfiguration regression fail; the restored implementation passes.
  • Full local suite and owner/live checks not run: real S3, Ceph, live tier and full sandboxCommand integration. Remaining real-test requirements are in test_requirements.md.

Follow-ups (not in this PR)

  • nemar dataset push/update and the sandbox (copyToAnnexRemote) keep the weaker flow
  • the post-save "annexed at save time" check with a re-enterable S3 step, and the case-variant metadata gap above
  • pre-pay or document the skip's deferred re-read at 1.6 TB
  • a single whole-tree copy for a fresh upload where everything is pending
  • a bucket-level HEAD check

bruAristimunha and others added 30 commits October 7, 2026 17:47
- git annex copy is driven with --json --json-error-messages; filesCopied
  counts success records instead of scraping 'copy ... ok' lines (nm000358
  logged 'Uploaded 0 data files' while all 165 keys were recorded at
  nemar-s3 during that copy).
- The copy set is taken from the location log (annexed paths not yet at
  nemar-s3), and the post-copy check now requires EVERY annexed file to be
  recorded at the remote, not only this run's targets.
- A data file larger than the annex size threshold that git-annex did not
  annex (policy overridden, e.g. an inherited .gitattributes) now fails the
  upload instead of being committed to git silently.
- saveDataset takes skipContentCheckPaths; the upload's save step marks the
  annexed paths assume-unchanged around git add -A/status/commit so git does
  not stream every freshly annexed unlocked file through git-annex
  filter-process (zero-stat index entries after git annex add). Refs #1455.
- The success line states sent / already-present / verified totals.
…ad-fixes' into feature/issue-1642-copy-verify
@neuromechanist

Copy link
Copy Markdown
Contributor Author

Review findings and resolutions

The requested project:pr-review-toolkit pass ran inline because project-preflight reported native_agent_status=unknown and no native-agent surface. Three independent read-only reviews were also incorporated: contract had no actionable findings, maintainability had no findings, and verification reported the items below.

Findings

  • Moderate, accepted residual — test/sandbox-save-push.unit.test.ts:13. The tests drive saveAndPush with real Git repositories and a bare origin, but do not exercise the sandbox command through finalization and cleanup. test_requirements.md now records the missing entrypoint coverage and why a safe local real-service environment is unavailable. The owner chose to keep this gap documented; add the end-to-end test only with an isolated staging fixture. No stub API or live service was used.
  • Rejected as outside the changed behavior — test/git-init-branch-fallback.unit.test.ts. The reported Git stand-in assertions are unchanged from the epic base; this PR only updates adjacent explanatory comments.
  • Rejected as outside this PR — test/helpers/pending-cli.ts, test/release-version-flag.test.ts, and test/upload-success-next-steps.test.ts. These files are not changed in the PR diff from the current epic base.
  • No production correctness findings. The target fingerprint uses the effective S3 arguments passed to configuration, excludes credentials, and disables stamp reuse when target identity is unavailable. The real directory-remote regression covers reconfiguring the same remote name to another destination.

Validation

  • Local real-Git/git-annex suite: 133 passed, 0 failed across seven files.
  • Root and backend typecheck, lint, Biome on 12 changed TypeScript files, and git diff --check passed.
  • Mutation proof: removing destination identity from the fingerprint made the destination-reconfiguration regression fail; restoring it made the test pass.
  • Fresh checks passed on head fdcb1ca336a35f2089b5e15647222480221a7ef6: unit-pure (18m24s), integration-dev (8m57s), e2e-sandbox, api-test, lint, zenodo-sandbox-test, and publish. The e2e-upload, passwordless-auth, and scrub-tools jobs were skipped by the workflow.

Residual risk

The full local suite, real S3, Ceph measurements, and live-tier checks were not run. A completed-step resume with no pending data still skips opening the remote, as ADR 0092 specifies; changing the external target on that no-op path is outside this fingerprint check. The sandbox entrypoint gap remains documented in test_requirements.md.

This branch was previously deployed

1 inactive deployment
npm — fdcb1ca3 Deployed Oct 9, 2026 by neuromechanist via publish #3257
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.

2 participants