Skip to content

Start web approval through a backend dispatch - #408

Merged
neuromechanist merged 11 commits into
stagingfrom
feature/web-approve-dispatch
Oct 1, 2026
Merged

neuromechanist merged 11 commits into
stagingfrom
feature/web-approve-dispatch

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed by an independent agent; its findings are fixed here (see the commits).

Stacked on #407 (base is that branch until #407 merges, then retarget to staging).

Problem

The web Approve button cannot finish a real dataset (see #407 and the finding on #200). Approval is not one request: after the irreversible DOI publish, S3 Object Lock runs in batches of 100 objects that the caller must keep requesting. The CLI loops; the page sent one request. The loop stays in the caller because running it in a Cloudflare Worker would cost too much.

Change

The page no longer drives approval. The backend route is the contract and executors are pluggable; for now a web click is executed by a GitHub Action in nemarDatasets/.github, and the CLI path is unchanged (ADR 0022).

  • Approve calls POST /admin/publish/:id/approve-dispatch, which answers 202. The page then only watches the request's own status and current_step.
  • Row states come from the backend's approval_in_flight, so the page holds no timing constant: Approve (ready), Queued or Running with the current step (no buttons, page refreshes every 20 s while a row runs), and Resume or Retry when a run stalls. The CLI command stays on a stalled row as a fallback.
  • A backend that does not send approval_in_flight cannot dispatch, so the page falls back to the CLI hint and drops the "keeps going if you close this page" promise. A site deployed ahead of its backend degrades instead of showing a button that answers 404.
  • The direct approvePublicationRequest and its two-minute deadline are removed (website#200: "drops back to a normal deadline"). Dispatch has a 15 s deadline.
  • What each row shows comes from one tested rowView (the review found the decision logic untested). Retrying a request that never started opens the same typed-PUBLISH dialog as the first approval, because nothing has run; the lighter Resume dialog is only for a request that already has steps done. A failed run shows its error and the CLI command instead of "it keeps going", even while the backend still holds its lease.
  • The auto-refresh waits for open dialogs, error messages and an admin's own Pause, and it no longer stops for good after a Cancel. A failed start offers a refresh link.
  • Anonymous releases are tagged and get their own confirmation wording (the data goes public, the repository stays private, no DOI is published).
  • Failures show the backend's sentence instead of "Approve failed: Bad Gateway". The backend sends it as { error }, which readError files under code. The deny response is typed as the backend sends it.
  • ADR 0022 records the decision. Who approved forks by origin: a CLI approval records the CLI user, a web click records the admin who clicked (backend half).

Deploy order

Do not promote the site before the first two.

  1. Backend: feat: dispatch web approvals to a workflow nemar-cli#1578 (route, migration 0090, attribution), into dev.
  2. Workflow: Add approve-publication workflow nemarDatasets/.github#124, merged to main before the backend dispatches in production. A dispatch with no workflow does nothing, so the page would say "queued" forever.
  3. This site. WEB_PUBLISH_APPROVE_ENABLED is the kill switch.

Testing

  • bun run typecheck (0 errors), bun run lint, bun run test (2762 passed), bun run build
  • New tests on real rows from a production response (test/fixtures/admin-publish-requests.json): phase for every status and for a backend without the dispatch fields, dispatch client, error text, deadlines
  • Rendered in dev and clicked through against a local stand-in for the dispatch route: Approve, type PUBLISH, confirm, the POST reaches approve-dispatch, and the row then reads "Approval queued" with no buttons. Running, stalled (Resume plus the CLI fallback) and ready rows all render. Against today's production response (no dispatch fields) there are no buttons and the CLI hints show.
  • Not yet run end to end against the real backend and Action: that needs the backend PR on dev and the workflow merged, then one approval of nm099999 on test.nemar.org.

Not changed

  • nemar admin publish approve exits 0 when an approval fails (found while reviewing the workflow), so nothing should rely on its exit code. The workflow reads the final status back instead.

The backend stores datetime('now'), UTC with no zone marker, which
new Date() reads as local time. Tested in UTC, Pacific, and Tokyo.
The page read a nested status object the backend list route never
sends, so rendering the first row threw and no request showed,
including nm000290. Read the flat row the route returns instead.

Tabs are now Pending (requested + approving), Published, Denied,
Blocked, each with a count and one row per dataset (latest request).
Old ?status=all and ?status=requested links land on Pending.

Tested: unit tests on a scrubbed production response, typecheck, lint,
build, and the page rendered against the full production list.
Approval is not one request: after the DOI is published, S3 Object
Lock runs in batches the caller must keep requesting. The CLI loops;
this page sent one request, so a dataset over 100 files would stop at
approving, public but unlocked and unannounced. Gate the button behind
WEB_PUBLISH_APPROVE_ENABLED (off) and show the CLI command, with
--resume for an approving request. Deny is unchanged.

Tested: unit test for the command, typecheck, lint, and the page
rendered in dev (no Approve button or dialog, Deny and hint present).
The page no longer drives approval. Approve asks the backend to start
it (POST /admin/publish/:id/approve-dispatch), which hands the run to
a GitHub Action, and the page watches status and current_step. Rows
show Approve, Queued or Running, and Resume or Retry when a run stalls,
from the backend's own approval_in_flight; a backend without it falls
back to the CLI hint. The page refreshes while a run is live.

Also shows the backend's real error sentence instead of the HTTP status
text, and types the deny response as the backend sends it.

Tested: unit tests on real-row variants, typecheck, lint, build, and
the page clicked through in dev against a local dispatch stand-in.
A site deployed ahead of its backend would tell admins approval keeps
going if they close the page, while the rows fall back to the CLI.
Detect dispatch support from the rows (approval_in_flight present) and
use it for the lede and the dialogs too.

Tested: unit tests, lint, typecheck, and the page rendered against the
current production response (no buttons, CLI hints, old lede).
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Retrying a request that never started now asks for the typed PUBLISH
confirmation like the first approval, since nothing has run. A failed
run shows its error and the CLI command instead of claiming progress.
Cancelling a dialog no longer stops the auto-refresh; the refresh can
be paused and waits for open dialogs and error messages. A failed start
offers a refresh link. Anonymous releases are tagged and get their own
confirmation. What each row shows now comes from a tested rowView.

Also: CLI command only for well-formed dataset ids, queued state for
a resume dispatch, time elements, username fallback, comment fixes.

Tested: unit tests (2762), typecheck, lint, and the page in a browser
against a local stand-in: states, dialogs, Cancel then refresh.
Open PR #396 already adds ADR 0021. Also correct two claims the
review found overstated: the page reads approval_in_flight, and its
copy names GitHub Actions.
Running and stalled rows link to the approval workflow's runs, since
the backend cannot see a failure inside the workflow. Friendly
messages for dispatch_unconfirmed, dispatch_unconfigured and
origin_not_allowed.

Tested: unit tests, typecheck, lint.
The backend now holds a failed run in flight for a short grace because
the CLI retries a failed step itself. The row no longer claims the run
has stopped during that window; the ADR matches.

Tested: unit tests, typecheck, lint.
Base automatically changed from fix/admin-publication-queue-shape to staging October 1, 2026 21:50
Staging squash-merged #407, whose original commits this branch still
carries. Take this branch's side of the overlapping files; it is a
superset of what the squash contains.
@neuromechanist
neuromechanist merged commit 971200a into staging Oct 1, 2026
5 checks passed
@neuromechanist
neuromechanist deleted the feature/web-approve-dispatch branch October 1, 2026 22:15
neuromechanist added a commit that referenced this pull request Oct 5, 2026
Cuts [Unreleased] into 0.2.28 (2026-10-05). Adds the missing entries
for #407 (queue lists nothing), #408 (web approval by dispatch) and #409
(50-row pages), and moves #422's Fixed entry, which had landed under
0.2.27, into 0.2.28.
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