Skip to content

Add publication workflow (request/approve pipeline) - #70

Merged
neuromechanist merged 4 commits into
devfrom
feature/publish-workflow
Jan 24, 2026
Merged

neuromechanist merged 4 commits into
devfrom
feature/publish-workflow

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

  • Adds full publication workflow with request/approve/deny pipeline (closes Publication workflow: request/approve pipeline with resumable orchestration #68)
  • D1 migration for publication_requests table with status tracking
  • User CLI commands: dataset publish request/status/resend
  • Admin CLI commands: admin publish list/deny/approve with step-by-step orchestrator
  • S3 Object Lock service (governance mode, 100-year retention)
  • Email notifications via Resend (request, deny, approve)
  • Orchestrator tracks progress in D1; supports --resume for failed steps

Changes

Backend

  • backend/src/db/migrations/0005_publication_requests.sql - new D1 table
  • backend/src/routes/datasets.ts - user publish endpoints (request/status/resend)
  • backend/src/routes/admin.ts - admin publish endpoints (list/deny/approve + orchestrator + s3-lock)
  • backend/src/services/s3.ts - S3 Object Lock functions (listObjectKeys, applyObjectLock)
  • backend/src/services/email.ts - publication email templates

CLI

  • src/commands/dataset.ts - dataset publish subgroup (request/status/resend)
  • src/commands/admin.ts - admin publish subgroup (list/deny/approve)
  • src/lib/api.ts - API client functions for publish endpoints

Tests

  • test/publish-workflow.test.ts - 18 integration tests covering help, auth, user ops, admin ops

Orchestrator Steps (approve)

  1. Check CI (deploy if missing, verify passing)
  2. Make repository public
  3. Create concept DOI (if needed)
  4. Apply S3 Object Lock
  5. Notify user

Test plan

  • All 154 tests pass
  • Biome lint clean
  • TypeScript typecheck clean
  • Deploy backend and run migration
  • Test full workflow end-to-end

- D1 migration for publication_requests table
- User commands: dataset publish request/status/resend
- Admin commands: admin publish list/deny/approve
- Orchestrator with step tracking and resume support
- S3 Object Lock service (governance mode, 100yr retention)
- Email notifications via Resend
- API client functions for all publish endpoints
- Integration tests for publish workflow
- Fix S3 Object Lock: encode path segments individually, add Content-MD5
- Fix HTML injection: escape user-controlled strings in email templates
- Fix CI check: verify run status for all workflows, not just pre-existing
- Add deny reason max length (2000 chars)
- Add resend rate limiting (30 min cooldown)
@github-actions

github-actions Bot commented Jan 24, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR70

Version: 0.3.7-PR70.3ba5d12
Commit: 3ba5d12


🤖 Updated on each push.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

PR Review Findings

Critical Issues (Fixed)

  1. HTML Injection in emails - User-controlled strings (username, reason, datasetId) were interpolated directly into HTML email templates without escaping. Added escapeHtml() helper.

  2. S3 Object Lock URL encoding - encodeURIComponent(key) double-encoded path separators (/ -> %2F), causing S3 to not find objects. Fixed to encode segments individually.

  3. S3 Content-MD5 header - PutObjectRetention requires Content-MD5 for integrity. Added MD5 computation via crypto.subtle.digest.

Important Issues (Fixed)

  1. CI check logic gap - Newly deployed workflows skipped run status verification. Fixed to always check runs (freshly deployed with zero runs is acceptable).

  2. Deny reason unbounded - No max length on denial reason. Added .max(2000) validation.

  3. Resend no rate limiting - Resend endpoint allowed unlimited email spam. Added 30-minute cooldown.

Accepted/Deferred

  1. Race condition on publication_requests - No DB uniqueness constraint for active requests per dataset. Application-level check is sufficient; D1 doesn't support partial unique indexes.

This branch was previously deployed

1 inactive deployment
npm — 3ba5d121 Deployed Jan 24, 2026 by neuromechanist
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