Skip to content

Phase 4b: upstream-status CLI, weekly section, mirror flag - #1935

Merged
neuromechanist merged 12 commits into
feature/issue-1046-epic-upstream-freshnessfrom
feature/issue-1910-phase4b-upstream-cli
Oct 24, 2026
Merged

neuromechanist merged 12 commits into
feature/issue-1046-epic-upstream-freshnessfrom
feature/issue-1910-phase4b-upstream-cli

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Adds the operator and reporting surfaces for the upstream staleness report (ADR 0111): nemar admin upstream-status, a counts-only ## Upstream freshness section in the weekly import report, and a three-valued per-version mirror flag. The CLI walks the 4a route's pages, recounts from deduped rows (a row on two pages counts once) and exits 0 for stale rows alone, 2 when anything is unchecked, a page returned 502, errors[] came back on a 200, --max-pages was reached or the population changed, and 1 when a request failed. The weekly section names no dataset, caps the pass at 20 pages and 25 probes, and treats a missing or null upstream as "could not be determined", never as zero. mirrorFlagOf returns true, false or null from source_version and the N.0.0 version, derived at read time; it is on /datasets/:id/versions and the public landing, and the landing carries only that flag. metadata.json is unchanged.

Phase 4b of epic #1046 (4a is merged; 4c adds --measure). Part of #1910, which stays open until 4c.

What is in it

  • src/commands/admin-upstream-status.ts, src/lib/upstream-status-report.ts, src/lib/api/admin.ts: the command, the recount and the exit-code rules.
  • backend/src/services/import-weekly-summary-sweep.ts, import-weekly-summary.ts, shared/contract/weekly-attention.ts, src/commands/import-weekly: the weekly section, the attention rule and the upstream: line.
  • shared/source-snapshot.ts (mirrorFlagOf), backend/src/routes/datasets/manifests.ts, backend/src/services/data-router.ts: the mirror flag on the versions route and the landing.
  • The raw-mirror stand-in moved to backend/test/helpers/raw-mirror-standin.ts, shared by the route and sweep tests.
  • ADR 0111 amendment dated 2026-10-24 for this part.

Test plan

  • 16 targeted files: 645 pass, 0 fail; full bun test: 19138 pass, 242 skip, 1 fail (test/account-copy-parity.test.ts website parity, which compares against a stale sibling website checkout and failed the same way before this PR).
  • bun run typecheck and bun run lint clean; the Miniflare D1 test covers the fleet summary and PUBLIC_DATASET_VERSIONS_SQL.
  • About 90 single-line mutants applied; the three survivors are equivalent.
  • The website chip (separate issue in nemarOrg/website) and the GitHub raw read with the installation token against another org are not verifiable here.

Walks GET /admin/upstream-status page by page and recounts from the
rows. Exit 0 with stale mirrors; exit 2 for an unchecked row, a refused
page, errors[] on a 200, --max-pages or a changed population; exit 1
for a failed request. Tested through the real CLI against a local
server, with mutations.
Counts only (no dataset named), unknown never as zero: the section,
upstream_stale and upstream_unchecked in the log line, the headline rule
for a missing pass, and a gather that lists unchecked rows, batch
problems and a pass that stopped early as part failures. Stale itself is
not attention. import-weekly prints an upstream line. Tested on real
SQLite against stand-ins for OpenNeuro and its GitHub mirror.
mirror is true for an N.0.0 of an on###### mirror with a known tag,
false for anything else that is not a mirror, and null when the tag is
unknown or never examined (unknown is not no). Derived at read time on
GET /datasets/:id/versions and on the public landing, which exposes the
flag only. Truth table, real-route test and Miniflare D1 check, with
mutations.
Dated amendment: the command and its exit codes, the weekly section
(counts only, stale is not attention, blindness is), the three-valued
mirror flag and what each surface exposes. Docs only, not tested.
Mint the GitHub token once per pass and remember a failed mint. State
the 2,000-mirror page ceiling and the recomputed subrequest worst case
(about 151). Drop the dead row dedupe. Tests: the 25-probe budget across
pages, a withdrawn-plus-created mirror mid-pass, exactly at the cap,
past the cap, the token asked once. Mutation-checked.
The line now reads Examined N of M and gives the number actually
compared with upstream. Rewords a sentence that would rot once the
scheduler ships, notes the stale split depends on the 25-probe budget,
and narrows the attention type. Drops a test that could not fail.
Exit 0 is not a clean fleet; import-weekly exits 2 when the pass threw
and 1 when the backend predates the field; the subrequest arithmetic
and the 2,000-mirror ceiling; the website shows a chip, not a tag.
Docs only, not tested.
@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@PR1935

Version: 0.10.24-PR1935.35219e1
Commit: 35219e1


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 83686ca into feature/issue-1046-epic-upstream-freshness Oct 24, 2026
14 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-1910-phase4b-upstream-cli branch October 24, 2026 15:07

This branch was previously deployed

1 inactive deployment
npm — 35219e15 Deployed Oct 24, 2026 by neuromechanist via publish #3890
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