Repository navigation
Phase: availability report never creates main - #1672
Merged
neuromechanist merged 14 commits intoOct 8, 2026
Merged
neuromechanist merged 14 commits into
neuromechanist merged 14 commits into
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.
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1672Version: 🤖 Updated on each push. |
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.
Contributor
Author
Review recordOne pass of the PR review toolkit (Sonnet agents): code review, test analysis, silent-failure hunt, comment analysis, then a propose-only simplifier. No critical findings. Every finding below was fixed unless it is listed under "Not done". Tip at the time of writing: Important
Suggestions and nice-to-have (all applied)
Verification
Not done (tracked follow-ups)
|
neuromechanist
merged commit Oct 8, 2026
7e4017a
into
feature/issue-1671-epic-bru-upload-fixes
14 checks passed
This was referenced Oct 8, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The availability-report sweep commits
.nemar/availability-report.jsontomainthrough the GitHub Contents API.On a repository that was created but never pushed, that PUT created
mainas an unrelated root commit and broke every laternemar dataset upload(nm000358).The report now refuses when
maindoes not exist, the check runs before any S3 work, and the sweep only selects datasets that have a version (issue #1643).The first commit is the contributor's original fix (PR #1655, bruAristimunha), preserved with authorship.
The commits on top are review refinements:
mainis absent; 404 means the repository is not visible to NEMAR and is reported as a distinct fault, not as a depositor-side 409); a 409 counts as "empty repository" only when its body says so; a 2xx must carryobject.sha; every other status throws and leaves the row unstampedmainabsent there are zero PUTs and zero S3 requests, withmainpresent exactly one PUT whose committed body is decoded and checked, and one ordered event log pins GitHub first, S3 second, PUT lastverifyDatasetVersionS3and the report's manifest read acceptS3_ENDPOINT_URLthroughtestS3EndpointOverride(env), which returns it only outside production; a config-guard test asserts no wrangler[vars]block declares it#,?and%in a name cannot change the URL (GitHub acceptsrelease/1.0andrelease%2F1.0alike, so this is hardening, not a fix for slash branches)branchExistsandgetMainBranchShashare one ref fetch and one response validator;getMainBranchShakeeps its retry-on-404datasetHasVersionSql("d" | "datasets")and used by the archive retry sweep and the availability candidacy, with a test that pins bothstatusmarker (409 refused, 500 fault, 400 and 404 the dataset's own state),AvailabilityReportErrorkeeps itscause, and 5xx are logged on the single-dataset routePart of epic #1671. Supersedes #1655 (contributor PR retargeted to the epic branch). Issue: #1643.
Behavior to know about
no_source,identifier_scrub_refused) no longer get a report carryingblocklist_reason; the reason stays in D1. This follows from restricting the sweep to versioned datasets.main), then S3.Test plan
bun run typecheck(root and backend),biome checkon the 16 changed filesobject.shacheck fails 5; any 409 treated as empty fails 4; repository probe not distinct fails 4; seam fence removed fails 1 at each of the two sites;S3_ENDPOINT_URLadded to a wrangler vars block fails 1; lookup fault reported as 409 fails 18; version predicate dropped fails 1api-test,integration-dev): backend changes reach the dev worker only when the epic merges todevnemarDatasetsrepository has not been exercised (only public empty repositories and stand-ins)Follow-ups (not in this PR)
createOrUpdateFile, or move writers tocommitFilesAsTree, which cannot create a branchcommitEnrichmentWithBidsignore,routes/admin/doi.ts:1171,enrich-dataset.ts:1090)excluded_unversionedcount in the sweep responsemaincommits on dataset repositorieserrorsfaileddata-integrity-sweep-routeandimports-verify-routeto theS3_ENDPOINT_URLseam