Repository navigation
Phase 2: Version-DOI publish that can't time out (#751) - #758
neuromechanist merged 2 commits into
Conversation
Restructure /webhooks/publish-version-doi (EZID) into a fast 202 + async residual (waitUntil) + poll-for-completion, gated on MANIFEST_VIA_CENTRAL_WORKFLOW so prod keeps the legacy synchronous path until the flip. Kills the deterministic 60s curl timeout for high-file-count datasets (file-count-bound, not bytes). - Cheapen metadata read to O(1) Contents API (readRepoMetadata useContentsApi), replacing the recursive getTreeAtRef whole-tree fetch. - Reuse manifest_jobs as the publish state machine: accepted -> dispatched -> ready|failed; manifest-ready stays the single owner of the dataset_versions insert. Migration 0042 adds request_source + widens the status enum. - New GET /webhooks/version-doi-status for the CI poller. - Converge the admin orchestrator version_doi step onto the same mint+dispatch (no inline generateManifest / dataset_versions insert under central flow). - Move Zenodo backup off the request path; skip for OpenNeuro (on-prefix). - Tests (no mocks): migration + lifecycle SQL, status SELECT, idempotency + poll-decision pure functions.
From the 4-agent /review-pr pass: - Promote UPDATE now checks meta.changes; throw on 0 rows so a vanished/already- promoted accepted row is recorded as failed instead of dispatching a workflow whose callback can never complete (CRITICAL). - waitUntil last-resort .catch() now attempts a terminal failed-mark (status != 'ready' guard) so a residual whose own failed-UPDATE threw can't leave the row stuck non-terminal (the poller would wait to its CI timeout). - GET /version-doi-status wraps the D1 read; logs + returns 503 so a DB outage is distinguishable from 'no row yet'; unknown response now carries outcome:'wait'. - dispatchCentralManifestJob args -> discriminated union (promoteNonce XOR requestSource); ManifestJobStatus literal union for the pure decision fns. - Tests: version v-prefix normalization + admin request_source='admin' dispatched insert.
/review-pr summary (4 Sonnet agents: code-reviewer, silent-failure-hunter, pr-test-analyzer, type-design-analyzer)Addressed in commit f433577: CRITICAL — promote UPDATE didn't check HIGH — HIGH — Tests — added version Types — added a Intentionally not changed (with rationale)
|
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR758Version: 🤖 Updated on each push. |
d9b3072
into
feature/issue-749-epic-import-robustness
Summary
Restructures the EZID version-DOI publish so it can no longer hit the deterministic 60s curl timeout that blocked high-file-count OpenNeuro imports (on005385 3265 files, on005752 11000 files; the wall is file count, not bytes).
/webhooks/publish-version-doinow (under the central manifest flow) validates cheaply, creates anacceptedmanifest_jobsrow, returns 202, and runs the heavy residual (cheap metadata read + idempotent EZID mint + central manifest dispatch + Zenodo) off the request path viawaitUntil. The CI workflow pollsGET /webhooks/version-doi-statusuntilready/failedinstead of holding a 60s synchronous curl.Gated on
MANIFEST_VIA_CENTRAL_WORKFLOW: dev (true) exercises the new async path now; prod (false) keeps today's exact legacy synchronous path until a separate, gated flip (held per the epic's rollout plan).Changes
readRepoMetadatauseContentsApi), replacing the recursivegetTreeAtRefwhole-tree fetch. Opt-in, so other callers are byte-identical.manifest_jobsas the publish state machine:accepted -> dispatched -> ready|failed./webhooks/manifest-readystays the single owner of thedataset_versionsinsert (its contract is unchanged). Migration 0042 addsrequest_source+ widens the status enum (no DDL on the plain-TEXTstatuscolumn).GET /webhooks/version-doi-statusfor the CI poller (same token auth).version_doistep onto the same mint + dispatch (no inlinegenerateManifest/dataset_versionsinsert under central flow) so there is one idempotent owner.on-prefix), which is O(bytes) and handled by Phase 3's archive policy.Companion (cross-repo)
run-version-doi.yml"Publish version DOI" step rewritten to enqueue (202 central / 200 legacy) then poll. Merge after the Worker is live on prod (the poll endpoint must exist first).Not in this PR (gated)
MANIFEST_VIA_CENTRAL_WORKFLOW="true"and re-drive on005385/on005752 — held for explicit go (would change publish behavior for all prod datasets; requiresMANIFEST_CALLBACK_SECRETverified on prod).Closes #751
Part of epic #749
Test plan
bun test(backend): 235 pass + 13 new (migration/lifecycle SQL, status SELECT, idempotency + poll-decision pure functions). No mocks.tsc --noEmitclean;biome checkclean on changed files.ready,dataset_versionsrow appears, dev data plane manifest 200s.