Skip to content

Automated publication pre-screen (claude -p) on publish request #666

Closed

Description

@neuromechanist

Goal

When a user requests publication, automatically pre-screen the dataset (publisher minimum, not peer review) before it reaches an admin. Block + notify on hard gaps so the requester can self-correct.

Screen (Recommended gate)

BLOCK if any:

  • No real data (annex/S3 targets missing or implausibly small for the subject count)
  • README empty / missing / citations-only (must say what the data is and how to use it)
  • dataset_description.json missing Name or Authors

Non-blocking note: missing data paper / primary citation -> recommend adding.

Architecture (mirrors run-enrichment)

  1. POST /datasets/:id/publish/request (after BIDS readiness passes): dispatch repository_dispatch[run-prescreen] to nemarDatasets/.github with an HMAC callback token; set prescreen_status='pending'. Non-blocking (dispatch failure logs, does not 500).
  2. run-prescreen.yml (nemarDatasets/.github): mint per-repo App token, checkout dataset metadata, compute declared-data size from annex pointers, run claude -p --model haiku (auth via CLAUDE_CODE_OAUTH_TOKEN) -> structured verdict JSON. On block: open/refresh a GitHub issue on the dataset repo (NEMAR_ADMIN_TOKEN). POST verdict to callback.
  3. POST /webhooks/prescreen-result: verify HMAC (one-shot, gated on prescreen_status='pending'). Independently verify S3 presence server-side (getDatasetS3Stats, Worker has creds). If claude says block OR S3 check fails -> status='blocked', block_reason='prescreen_failed', store prescreen_issue_url, email requester (sendPublicationBlockedEmail). Else prescreen_status='passed'.

Work items

  • migration 0028_prescreen.sql (+prescreen_status, prescreen_issue_url, prescreen_at on publication_requests)
  • email.ts: sendPublicationBlockedEmail
  • github.ts: sign/verify prescreen callback token + triggerPrescreenRun
  • webhooks.ts: /webhooks/prescreen-result + pure decidePrescreenOutcome
  • datasets.ts: prescreen_failed block message + dispatch in publish-request
  • nemarDatasets/.github: run-prescreen.yml
  • tests (token roundtrip, dispatch payload, decision fn, block message)
  • secrets to add on nemarDatasets/.github: CLAUDE_CODE_OAUTH_TOKEN, NEMAR_ADMIN_TOKEN

Context

Motivated by a 99-dataset bulk import (EEGDash) where 8 had missing READMEs / metadata / data. Backfill review done manually 2026-06-01; this automates it going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions