Skip to content

Integrity: count chunked annex objects as present - #1651

Closed
bruAristimunha wants to merge 1 commit into
nemarOrg:feature/issue-1671-epic-bru-upload-fixesfrom
bruAristimunha:fix/issue-1565-chunked-key-availability
Closed

bruAristimunha wants to merge 1 commit into
nemarOrg:feature/issue-1671-epic-bru-upload-fixesfrom
bruAristimunha:fix/issue-1565-chunked-key-availability

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Datasets uploaded through a chunked special remote (nm000276, chunk=1GiB) hold only <key>-S<chunksize>-C<n> objects in S3, never the plain key. isKeyPresentAtDeclaredSize (backend import-integrity.ts and its CLI twin in s3-server-copy.ts) looked up the plain key only, so verifyDatasetVersionS3 called every such file missing, data_complete stayed 0 and nemar dataset status printed "incomplete" although every byte is in the bucket. The CLI fleet/recovery checks inherited the same false "missing".

Change

  • A key is also present when every chunk C1..Cn exists at the size chunking gives it: chunk size for 1..n−1, the remainder for the last, one chunk for an empty file. A missing or short chunk still counts as absent.
  • -m<mtime> keys are handled.
  • The chunk index is built once per listing.
  • Backend and CLI copies are kept identical.

Not in this PR: serving chunked objects through the data plane / manifest.json URLs (data-router.ts), the 404 half of #1565. That needs a decision (stream-concatenate the chunks, or re-upload unchunked), so #1565 stays open. After merge, nm000276's data_complete updates on the next integrity sweep.

Part of #1565

Testing

  • test/chunked-key-availability.unit.test.ts and backend/test/import-integrity-chunked.test.ts (new, 15 tests across both copies): a key stored only as complete chunks is present; a missing or short chunk makes it absent; an empty file as one empty chunk; a truncated plain object rescued by a complete chunk set (not the reverse); the chunk index following a listing that grows; keysWithoutObjects and compareManifestToListing on a fully chunked dataset and one missing a chunk.

  • Files that import the changed modules, on current dev: CLI 13 files, 236 pass, 4 skip, 0 fail; backend 7 files, 135 pass, 0 fail.

  • bun run typecheck, biome check on the changed files.

  • CI api-test and integration-dev fail on this PR because it comes from a fork: both call the dev API with the TEST_*_API_KEY secrets, which GitHub does not pass to fork pull requests, so the authenticated cases fail and the unauthenticated ones pass. lint, unit-pure and e2e-sandbox run normally.

Datasets uploaded through a chunked special remote (nm000276, chunk=1GiB)
hold only '<key>-S<chunksize>-C<n>' objects in S3, never the plain key.
isKeyPresentAtDeclaredSize (backend import-integrity.ts and its CLI twin in
s3-server-copy.ts) looked up the plain key only, so verifyDatasetVersionS3
reported every such file missing, data_complete stayed 0 and 'nemar dataset
status' printed 'incomplete' although every byte was in the bucket; the CLI
fleet/recovery tools inherited the same false 'missing'.

A key is now also present when every chunk C1..Cn exists at the size
chunking gives it (chunk size for 1..n-1, the remainder for the last). A
missing or short chunk still counts as absent. The chunk index is built
once per listing. Serving chunked objects through the data plane (the 404
part of nemarOrg#1565) is not addressed here.
@neuromechanist
neuromechanist changed the base branch from dev to feature/issue-1671-epic-bru-upload-fixes October 7, 2026 22:06
@neuromechanist

Copy link
Copy Markdown
Contributor

Thank you for this fix and for tracing the chunk key format so carefully. It is merged into the integration branch for epic #1671 as PR #1674, with your commit kept (595b384 on that branch, authored by you). The review added commits on top, so this PR is closed in favor of that one.

What the review added: the key logic now lives once in shared/annex-key.ts for both the Worker and the CLI; keys with an -m field work in the chunk path; a truncated plain object is no longer rescued by a complete chunk set; the chunk lookup is bounded by each key's own C1 objects so an uploader cannot inflate its cost; the test gaps (empty file, chunk geometry, mixed chunk sizes) are covered; and an amendment to ADR 0064 records that "present" now means recoverable, not servable.

The epic merges into dev as a unit once 0.10.15 has shipped. Issue #1565 stays open for the data-plane half. The full review record is on #1674.

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