Repository navigation
Description
Surfaced by review of #198.
Problem
POST /admin/publish/:id/approve fully awaits runPublicationApproval — a sixteen-step state machine (nemar-cli backend/src/services/publication-orchestrator.ts) that walks GitHub (tree read, blob read, workflow existence check, workflow deploy, run poll, visibility flip, repo spec, tag protection), verifies S3 state, and mints a Zenodo DOI. Several steps are wrapped in withRetry at three attempts with backoff. Only waitForPublicPropagation is deferred via c.executionCtx.waitUntil; everything else blocks the HTTP response.
So a single admin click on Approve holds one request open for the entire run. On a healthy backend, one retried GitHub step is enough to push that past any reasonable client deadline.
Why a longer timeout is not the fix
#198 raised the client deadline for approve to 120s, which stops the frontend aborting a healthy run. But that only moves the wall. The real problems remain:
- The Worker-side run is not tied to the client's
AbortController. If the client does give up, the orchestrator keeps going — the admin sees a failure for something that may well be succeeding. src/pages/admin/publication-requests.astrore-enables the button on error, inviting a second click while the first run may still be executing or may have partly completed. The retry sendsbody: "{}", not{resume: true}, so resume-skip-already-done is not guaranteed to engage. Individual steps look idempotent (DOI "already exists" handling, S3 lock 403 treated as idempotent) so corruption looks unlikely, but redoing finished GitHub calls compounds the latency that caused the timeout.- The admin gets no progress feedback during a run that can legitimately take a minute or more.
Ask
Make approve non-blocking: the endpoint accepts the request, starts the run, and returns immediately with a job handle. The admin page polls (or streams) progress. The orchestrator already writes per-step progress (startStep / updateProgress), so the state needed for a progress view largely exists.
Needs a nemar-cli change first; file the backend issue and link it here. Once it lands, ADMIN_TIMEOUTS_MS.approve in src/lib/admin-api.ts drops back to a normal deadline and its long comment goes away.
Activity
neuromechanist commentedon Oct 1, 2026
Finding: the web Approve cannot finish a real dataset
Approval is not a single request. After the irreversible
publish_doistep, S3 Object Lock (step 14) runs in batches of 100 objects and returnshasMorewith a continuation token that the caller must send back. The CLI loops (with retries andresume); the web page sends one{}and reloads. Any dataset over 100 files would stop inapprovingwith its repository public and DOI published, but no S3 lock, no catalog sync and no owner email, and anapprovingrow has no buttons to continue from. Until this lands, the web Approve button is withheld (PR #407,WEB_PUBLISH_APPROVE_ENABLED) and the page shows the CLI command.The loop lives in the caller on purpose: running it inside the Worker would cost too much.
Decision
The backend route is the contract, and executors are pluggable. For now the web button is executed by a GitHub Action in
nemarDatasets/.github. The CLI path is unchanged. Not nemaring, and not the Worker.POST /admin/publish/:id/approve-dispatchclaims the request atomically, records the clicking admin, and sends onerepository_dispatch(approve-publication). The list route gainsapproval_in_flightso clients need no timing constant. Migration addsapproval_requested_byandapproval_dispatched_at.nemarDatasets/.github):approve-publication.ymlrunsnemar admin publish approve <id> [--resume]with one concurrency group per dataset. The environment (production or dev) selects both the API URL and the secret from a fixed map; nothing from the payload is trusted.Deploy order
dev, verify on api-test..githubmain before the backend dispatches in production (a dispatch with no workflow does nothing, so the page would say "queued" forever).main, then the website promoted.Also fixed on the way: when approve fails, the page shows the backend's real sentence instead of "Approve failed: Bad Gateway" (the backend sends it as
error, whichreadErrorfiles undercode).neuromechanist commentedon Oct 1, 2026
Shipped to staging and dev
Approval no longer runs inside the page's request. Merged 2026-10-01:
971200a) with Fix publication queue listing nothing; drop All tab #407 before it: the Approve button asks the backend to start the run, and the page watchesstatus,current_stepandapproval_in_flight. ADR 0022.176874f,dev):POST /admin/publish/:id/approve-dispatch, migration 0090, attribution that forks by origin. ADR 0080.1452d11):approve-publication.yml, which runs the CLI's loop on a runner.ADMIN_TIMEOUTS_MS.approveis gone; dispatch has a 15 s deadline.Not yet promoted to production, and not yet run end to end: it needs the
NEMAR_ADMIN_API_KEY_DEVsecret onnemarDatasets/.githuband a dev request to approve (an exemplar, since dev blocks non-sandbox DOI creation).Follow-ups, filed in nemar-cli
/approvetakes arequest_idpreconditionnemar admin publish approveexits 0 when an approval failsapprove-dispatchvalidates the dataset id before claimingLeaving this open until the change is on production.