Repository navigation
Phase 4a: upstream staleness route - #1932
Merged
neuromechanist merged 7 commits intoOct 24, 2026
Merged
neuromechanist merged 7 commits into
neuromechanist merged 7 commits into
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR1932Version: 🤖 Updated on each push. |
Pure classifyMirror and diffStaleMirrors in shared/upstream-staleness.ts: eleven states, eight anomaly kinds, verdict by upstream creation order (not tag number), plus isSourceTag. Recorded OpenNeuro fixtures included. Tested with the recorded responses.
Batched GraphQL reader for the staleness report: 50 datasets per request, ids only as variables, per-alias deleted/absent, any failure an error read (never a verdict). Exports OPENNEURO_GRAPHQL_URL and adds an override binding. Tested against a stand-in serving the recorded response.
Read-only, keyset-paged report of OpenNeuro mirrors behind upstream: batched snapshot read, GitHub mirror probe with a HEAD control read (rawContentUrl gains an org parameter), pinned in the route inventory. Tested on real SQLite, a recorded-response OpenNeuro stand-in, and Miniflare D1.
Dated amendment: population, state precedence, creation order over tag number, the control-read proof of mirror lag, no cron. Points the design note's staleness predicate at it. Docs only, not tested.
Reader: a partial response, a null latest beside a non-empty list and a foreign 'does not exist' are error reads. Classifier: a latest older than a list entry is an anomaly; unknown rows name the OpenNeuro failure. Service: 502 only when rows needing a verdict ended unchecked, excluded unmanaged on rows counted, probe 200 needs a JSON object body, no claimed probes when the token cannot be minted. Route: strict limit, dataset with after is 400, D1 failures labeled apart from defects. Tested with mutations on real SQLite, recorded responses and Miniflare D1.
Amendment now states the status codes, per-page counts, unmanaged rows, the latest-versus-list anomaly, the same-tag re-creation limit, the CDN 404 cache, the HEAD control read, and what the next part will do. The token caveat moves to Not yet verified. Fixes the design note predicate and the raw-read comments. Docs only, not tested.
An unparsable (not null) latest date skipped the list check and let a recorded==latest row read current beside a later snapshot. The list entry's date is tried next; if neither reads the row is upstream_dates_unreadable. ADR wording for upstream_older and the unknown-row note, probe doc block moved back. Tested with mutations.
neuromechanist
force-pushed
the
feature/issue-1910-phase4a-upstream-status
branch
from
October 24, 2026 12:49
429a416 to
cd6ab47
Compare
neuromechanist
merged commit Oct 24, 2026
80cb119
into
feature/issue-1046-epic-upstream-freshness
14 checks passed
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
Adds
GET /admin/upstream-status, a read-only, keyset-paged admin route that reports which NEMAR mirrors of OpenNeuro datasets are behind OpenNeuro's latest snapshot (ADR 0111). It reads the recorded upstream tag fromdataset_versions.source_version, asks OpenNeuro for the dataset's snapshots in batches of 50, probes the GitHub mirror at the latest tag, and classifies each dataset: current, stale_ready, mirror_lag, stale_unverified, anomaly, unknown, not_examined, unpublished, in_progress, parked or unchecked. A failed or partial read is never reported as current or as a definite claim about upstream. The report itself writes nothing to D1 and files nothing; authentication still stampstokens.last_used_at.countsis per page, so aggregation is the caller's (4b).Phase 4a of epic #1046 (4b adds the CLI, the weekly-report section and the mirror flag; 4c adds
--measure).What is in it
shared/upstream-staleness.ts: the purediffStaleMirrorsclassifier and the wire types;isSourceTaginshared/source-snapshot.ts. Tag order is OpenNeuro's creation order, not numeric order (ds000001 has00006before1.0.0).backend/src/services/openneuro-snapshots.ts: batched GraphQL reader (50 aliases, sequential, 20 s timeout, ids never in the query text; partial responses and foreign error messages areerrorreads).backend/src/services/upstream-status.tsandbackend/src/routes/admin/upstream-status.ts: the page, the GitHub mirror probe (raw read at the tag plus a control read at HEAD, both requiring a JSON object body), the probe budget,excluded_unmanaged; route inventory pin 155 to 156.Review
Round 1 (four Sonnet reviewers) and the delta round are done; every finding is fixed or answered in the commits.
Test plan
bun run typecheck, Biome clean; datasets column budget still 84OpenNeuroDatasetsraw files is not testable locally; if refused, every probe readsstale_unverifiedwith the reason (recorded in the amendment under "Not yet verified")Part of epic #1046.