Skip to content

Phase 4c: upstream-status --measure - #1937

Merged
neuromechanist merged 13 commits into
feature/issue-1046-epic-upstream-freshnessfrom
feature/issue-1910-phase4c-measure
Oct 24, 2026
Merged

neuromechanist merged 13 commits into
feature/issue-1046-epic-upstream-freshnessfrom
feature/issue-1910-phase4c-measure

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Adds nemar admin upstream-status --measure (ADR 0111): for the stale mirrors the 4a route reports, it reads OpenNeuro's file listing at the recorded tag and at the latest tag and summarizes the delta (files added, changed, removed, annexed versus git, bytes to copy, metadata-only or data-changing), then estimates how many version DOIs a catch-up would mint at the 30-day pace (one to two per re-pull, the second only when NEMAR corrections replay as N.0.1) and how many days the open cap needs. An unread listing never counts as zero: the total bytes become null with the known sum beside it, the delta is reported as unknown, and the run exits 2; a deliberate --measure-limit leaves mirrors not_measured and does not. A pass that failed part-way is not measured (exit 1, measurement: null). The conflict and unexplained counts that the design's second gate lists come from Phase 5's nemar admin repull plan, not from this measurement, so that gate cannot close in this phase.

Phase 4c of epic #1046; closes the Phase 4 work in #1910 (the issue is closed by hand once this merges).

What is in it

  • shared/upstream-staleness.ts: summarizeSnapshotDelta and estimateRepullDoiVolume, pure and unit-tested over recorded real OpenNeuro listings (test/fixtures/openneuro-snapshot-files/, with provenance).
  • src/lib/openneuro.ts fetchSnapshotFilePair (typed result, no throw), src/lib/upstream-measure.ts (orchestration, totals, rendering), src/commands/admin-upstream-status.ts (--measure, --measure-limit, NEMAR_OPENNEURO_GRAPHQL_URL override).
  • ADR 0111 amendment dated 2026-10-24 for this part.

Test plan

  • Typecheck and biome clean; 79 targeted tests pass after the rebase; the full suite ran before the rebase with only the stale-sibling website parity failure and three load-induced timeouts that pass when rerun alone.
  • About 30 single-line mutants applied; each failed a test (two survivors found by the first pass were killed by added tests), one equivalent mutant left.
  • Not verified here: a live measurement against production and timeouts on very large listings (the 120 s default and --measure-limit bound the run).

Pure summarizeSnapshotDelta over two OpenNeuro file listings: added, changed (by id), deleted, annexed counts, new keys and bytes to copy (null when a size is unknown). Tested on two recorded listings.
estimateRepullDoiVolume over the upstream snapshot lists: catch-up, per snapshot, at most one per 30 days, busiest day, a doubled upper bound for N.0.1 patches. Unreadable dates are counted, not dropped. Tested on the recorded lists.
fetchSnapshotFilePair reads two OpenNeuro snapshots' recursive file listings in one request, on the administrator's machine. Any failure is an error result, never an empty listing. Tested against a stand-in serving two recorded listings.
Reads OpenNeuro file listings from the administrator's machine for each stale mirror, totals the deltas and the DOI volume, and exits 2 when a delta could not be read. Unknown is null with an at-least sum, never zero. Tested through the spawned CLI against a stand-in serving two recorded listings.
Amendment for the measurement: what it measures, the DOI volume estimate, its two limits, and that the conflict and unexplained counts belong to the Phase 5 plan. Docs only.
Read key sizes with the strict field parser, count future-dated snapshots, and name the import by date, keeping every snapshot of a dataset with an unreadable date. Tested, including mutations.
An empty listing, one without a root dataset_description.json, data beside errors, a bad size or a repeated filename now fails the pair instead of becoming a delta. One malformed-entry case per field. Tested, including mutations.
Totals carry the pass scope, a not_comparable breakdown and a complete flag; the DOI block lists what it left out; reading stops after five consecutive failures with a progress line every ten; sizes near a unit boundary are promoted. Tested.
A pass that threw, was refused, hit --max-pages, changed population or had unchecked rows is not measured: measurement is null with the reason. Help text and header comments corrected. Tested through the spawned CLI.
Records the listing refusals, the complete-pass rule, the not-comparable counts and scope, the stop after repeated failures, and the date handling. Docs only.
Help text for NEMAR_OPENNEURO_GRAPHQL_URL on upstream-status. Tested by running --help-all.
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR1937

Version: 0.10.24-PR1937.1c72192
Commit: 1c72192


🤖 Updated on each push.

Not-comparable states, completeness with an unsized key, and the transport-only stop. Docs only.
not_comparable lists in_progress, parked and unpublished; only transport failures count toward the stop after five; no progress line after the stop; complete implies a known byte total. Tested, including mutations.
@neuromechanist
neuromechanist merged commit 403da20 into feature/issue-1046-epic-upstream-freshness Oct 24, 2026
14 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-1910-phase4c-measure branch October 24, 2026 17:14

This branch was previously deployed

1 inactive deployment
npm — 1c721926 Deployed Oct 24, 2026 by neuromechanist via publish #3901
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.

1 participant