Skip to content

Add admin repo unpublish; move lifecycle commands under admin repo - #2199

Merged
neuromechanist merged 15 commits into
devfrom
fix/unpublish-published-dataset
Nov 18, 2026
Merged

neuromechanist merged 15 commits into
devfrom
fix/unpublish-published-dataset

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

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 status still said published, 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 unpublish nemar admin repo withdraw
Use when the authors pull a dataset back the dataset is broken or removed
Repository private everywhere private everywhere
DOIs untouched, EZID is never called tombstoned (concept and every version)
Afterwards an ordinary unpublished private dataset, can be published again withdrawn; undone with restore

withdraw and restore behave exactly as before, they only moved.

Changes (commits in order)

  1. refactor: move withdraw and restore under admin repo: nemar admin repo withdraw|restore; the old top-level admin withdraw and admin restore are hidden stubs that do nothing and exit 1 with "moved to ...".
  2. refactor: move admin publish under admin repo: the whole group (list, show, start, next, approve, deny, screen) is now nemar admin repo publish ..., options unchanged; old admin publish is a hidden stub. Every reference (help strings, README, ADRs, mail text, tests) updated. nemar dataset publish is untouched.
  3. refactor: remove repo public/private, refuse PATCH: both commands removed. PATCH /admin/datasets/:id/visibility is 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.
  4. feat: add unpublish service and admin route: migration 0144 (publication_requests.unpublished_at), services/unpublish.ts, POST /admin/datasets/:id/unpublish (dry run by default, reason required to execute), publish status reads a stamped request as none.
  5. 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.
  6. docs: add ADR 0125 on unpublish.

The repo group description is now "Dataset publication lifecycle: publish, unpublish, withdraw, restore".

Behavior of unpublish

  • Runs applyDatasetVisibility(private) (GitHub, S3, D1, repo spec, collaborator reconcile, revert on failure), then stamps unpublished_at on every request still published (status is not rewritten), then writes a dataset_unpublished audit row with the reason.
  • Repairs the nm000289 half state (already private, live published request), and on a public dataset that was never published it just makes it private.
  • Leaves first_published_at (anonymity stays unavailable, ADR 0065), concept_doi, ezid_status, dataset_versions, tag ruleset and S3 lock, collaborators and access requests alone.
  • Refuses the live datasets nm000103 to nm000107, exemplars, withdrawn datasets (points at restore), and a private dataset with nothing to reset.

Not changed, noted

  • nemar admin make-public still makes a dataset public without a request; same class as the removed flip.
  • .context/scrub-runbook.md used repo public to return a scrubbed dataset to public. That step is now marked held for an owner decision; repo private there became repo unpublish.
  • Republishing reuses the existing concept and version DOIs. The orchestrator already handles an existing concept DOI and EZID's "already exists"; a second publish of the same version number was not exercised against EZID.
  • This PR touches about 100 files, almost all of them the mechanical admin publish to admin repo publish rename (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 the unpublished_at update 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 0144 applies with the Worker deploy):

# 1. Plan (dry run, changes nothing)
nemar admin repo unpublish nm000289

# 2. Apply
nemar admin repo unpublish nm000289 --execute --reason "authors asked to return it to unpublished; repair of the 2026-10-29 bare private flip"

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:

nemar dataset publish status nm000289      # as the owner: no request, "unpublished by an administrator"
nemar dataset status nm000289               # as owner or admin: found, DOIs still listed
nemar dataset access list nm000289          # the pending request from psong is there; approve with: nemar dataset access approve psong nm000289

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).

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2199

Version: 0.10.34-PR2199.447f0b8
Commit: 447f0b8


🤖 Updated on each push.

This branch was previously deployed

1 inactive deployment
npm — 447f0b84 Deployed Nov 18, 2026 by neuromechanist via publish #4517
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