Repository navigation
Add admin repo unpublish; move lifecycle commands under admin repo - #2199
Merged
Merged
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2199Version: 🤖 Updated on each push. |
6 tasks
9 of 10 tasks
2 tasks
This was referenced Nov 18, 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.
Fixes #2198
What and why
A bare visibility flip on a published dataset (nm000289, 2026-10-29) left it private everywhere and published in the record:
publish statusstill saidpublished, DOIs stayed public, and there was no way to describe the dataset truthfully. This PR adds the operation authors actually need and removes the tools that make half states.unpublish versus withdraw
nemar admin repo unpublishnemar admin repo withdrawrestorewithdrawandrestorebehave exactly as before, they only moved.Changes (commits in order)
refactor: move withdraw and restore under admin repo:nemar admin repo withdraw|restore; the old top-leveladmin withdrawandadmin restoreare hidden stubs that do nothing and exit 1 with "moved to ...".refactor: move admin publish under admin repo: the whole group (list,show,start,next,approve,deny,screen) is nownemar admin repo publish ..., options unchanged; oldadmin publishis a hidden stub. Every reference (help strings, README, ADRs, mail text, tests) updated.nemar dataset publishis untouched.refactor: remove repo public/private, refuse PATCH: both commands removed.PATCH /admin/datasets/:id/visibilityis kept and refuses both directions with 409 and a pointer (publish approve, unpublish), rather than being removed, because the scrub runbook and any external script still name it, and a 409 with a sentence is a better answer to them than a bare 404. The one-handler route is pinned in the route inventory. The visibility service tests that used the route now call the service directly.feat: add unpublish service and admin route: migration0144(publication_requests.unpublished_at),services/unpublish.ts,POST /admin/datasets/:id/unpublish(dry run by default, reason required to execute),publish statusreads a stamped request asnone.feat: add nemar admin repo unpublish: the command (dry run by default,--execute --reason, confirmation,--json), help text that says when to use it versus withdraw.docs: add ADR 0125 on unpublish.The
repogroup description is now "Dataset publication lifecycle: publish, unpublish, withdraw, restore".Behavior of unpublish
applyDatasetVisibility(private)(GitHub, S3, D1, repo spec, collaborator reconcile, revert on failure), then stampsunpublished_aton every request stillpublished(status is not rewritten), then writes adataset_unpublishedaudit row with the reason.first_published_at(anonymity stays unavailable, ADR 0065),concept_doi,ezid_status,dataset_versions, tag ruleset and S3 lock, collaborators and access requests alone.restore), and a private dataset with nothing to reset.Not changed, noted
nemar admin make-publicstill makes a dataset public without a request; same class as the removed flip..context/scrub-runbook.mdusedrepo publicto return a scrubbed dataset to public. That step is now marked held for an owner decision;repo privatethere becamerepo unpublish.admin publishtoadmin repo publishrename (commit 2). Commits 3 to 6 are the substantive review.Tests
Targeted, all green (184 + the CLI group runs):
backend/test/unpublish.test.ts(20): reproduces the half state, then proves the repair and the ordinary pull-back with a real D1 and stand-ins for GitHub and S3. EZID is unreachable in the file, so a call to it fails the test. Mutating theunpublished_atupdate turns four tests red.backend/test/fleet-visibility-route.test.ts,visibility.test.ts,review-auto-require-paths.test.ts,withdraw*.test.ts,publish-withdraw.test.ts.test/admin-unpublish-cli.test.ts(real command against the in-process backend),test/admin-restructure.test.ts,test/admin-publish-*-cli.test.ts,test/admin-route-inventory.unit.test.ts,test/api-export-surface.unit.test.ts,test/adr-index.unit.test.ts.bun run typecheck,bun run lint,bun run migrations:d1-check.Not run: the full
bun test(epic to dev gate);test/recover-datasets-packaging.test.ts(needs the built dist and a backend, only its command path string changed); the live-API suites (no test keys).Production repair (owner runs)
After this is deployed (the migration
0144applies with the Worker deploy):The dataset is already private, so step 2 reports
already private, but a publication record still says published (a repair): it re-applies private on GitHub and S3 (idempotent), stamps the published request (id 836), and writes the audit row. No EZID call, no D1 statement needed. Verify:If the owner reports the dataset is still not found after this, check that the CLI is pointed at production (
nemar auth status; unset any test API URL in the shell): the routes admit the owner, administrators and collaborators to a private dataset.Drafted with AI assistance.
Follow-up: verify re-publishing an unpublished dataset end to end on nm099999 (#2202).