Skip to content

B5: automatic deny (off, shadow, on) and ready-to-approve mail - #2387

Merged
neuromechanist merged 12 commits into
feature/issue-2182-epic-pq-decidefrom
feature/issue-2369-auto-deny
Nov 26, 2026
Merged

neuromechanist merged 12 commits into
feature/issue-2182-epic-pq-decidefrom
feature/issue-2369-auto-deny

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2369
Part of #2182

Card B5 of the publication-queue plan: a confirmed review fail denies a publication request as nemarAdmin (mode on), or records "would deny" (mode shadow), exactly under ADR 0139; the depositor gets a transparent mail; a pass with a clear gate mails the administrators "Ready to approve".

What changed

  • Migration 0153. publication_reviews gains confirm_of, auto_deny_state and auto_deny_at, and denial_mail_state (sent, failed, fenced) with denial_mail_attempts. The states: none; would_deny (shadow); denied; capped (past the daily cap, "recommended: deny"); not_eligible (the request changed: approval, withdrawal, re-screen, newer request, two earlier automatic denials); disagreed; confirm_failed (the confirming run errored, its dispatch failed or was declined, or the watchdog expired it); no_service_account (nemarAdmin missing, nothing denied); restored (an administrator restored it; that commit is never denied automatically again, and its cap place stays counted); its UNIQUE key becomes a partial unique index over first runs, with a second partial index for one confirming row per first run (rebuild, every row kept). publication_requests.auto_denied (0/1). publication_auto_deny_digests for the once-a-day digest claim. Replayed through local D1 (bun run migrations:d1-check, --local only), and both upserts on the partial indexes checked there.
  • One deny path. The body of POST /admin/publish/:id/deny moved verbatim to services/publication-deny.ts (denyPublicationRequest); the route calls it with no extras and keeps its single .run() write, so its answers and its race tests are unchanged. The automatic denial calls the same function with extra guard terms, auto_denied = 1, and the cap claim, the audit row and the claim's take-back in the same batch.
  • Eligibility (shared/publication-auto-deny.ts): one pure function, with the card's conditions; license_lineage_unconfirmed, every screen reason, every infrastructure outcome and source_license_conflict are never eligible.
  • The confirming run. Dispatched as its own row through the existing workflow and payload; the Worker's inputs route tells the job its model (confirm: { model: claude-sonnet-5-5, effort: max }, only for a confirming row), and the review script calls that model at max (streamed, 64k budget, 12-minute deadline). No change to nemarDatasets/.github. The Worker stores a confirming row's report only on that model and effort, and the confirmation needs the same input digest and prompt version. Confirming runs are left out of the depositor's tally and held by the platform cap.
  • Mode, cap, deny. PUBLICATION_AUTO_DENY_MODE (off/shadow/on, anything else off, re-read when acting) and PUBLICATION_AUTO_DENY_DAILY_CAP (default 25), both absent from wrangler-sccn.toml (new auto-deny-switch-flag.test.ts). The cap is one conditional statement, claimed before a deny or would-deny. A lost race (approval in flight, blocked, moved) takes the claim back and records not_eligible.
  • Mails. The depositor's denial mail goes to the requester and every account with owner rights on the dataset, de-duplicated. The backend's repository rights come from datasets.owner_user_id (maintain) and dataset_collaborators (write, no role column), so that is the requester plus the owner. It goes through the delivery fence, and what became of it is recorded on the review; the daily tick retries a failed mail once, and the digest lists "Denial mail not delivered" with dataset and request. The mail is built from the copy table, the closed codes and both review records (B4's reproducibilityLines), never from model text. The administrators' mail adds the state's line ("Automated review disagreed", "Recommended: deny", "Would deny"). A pass with gate clear is headed "Ready to approve" and lists the gate, the minimums, the lineage outcome, the four answers and the approve command; gate acknowledge says "Review passed; the identifier screen still needs an acknowledgment" and quotes the screen's status line. A daily digest of denied, would-deny, capped, disagreed, confirm-failed and service-account-missing rows, production-only, through getAdminEmailsForCategory, on the 03:00 tick. It counts first, lists at most 500 and says how many more wait (its window ends at the last row listed), and releases its day claim if anything after the claim throws.
  • Restore. POST /admin/publish/:id/restore (admin or owner, audit row publication_restore) and nemar admin dataset publish restore <id>.

Tests

New: test/publication-auto-deny.unit.test.ts, backend/test/publication-auto-deny.test.ts, backend/test/auto-deny-switch-flag.test.ts, test/admin-publish-restore-cli.test.ts, and an end-to-end case in test/publication-review-e2e.test.ts that runs the real workflow steps and job script twice (first run, then confirming run on Sonnet at max, same digest) to a denial. Existing mail tests now expect the pass headline. Ten mutations (anonymous check, widened finding codes, widened mode, shadow denying, cap widened, status guard, earlier-denials check, digest equality, model check, restore's newer-request rule) each turn a named test red.

Deviations

  • denied_reason holds reason codes (question_failed, steering_attempt), per ADR 0139 decision 2 and so a later review is shown them (previousDenialReasonsOf); the finding codes are in the audit row and the mail.
  • The CLI command is nemar admin dataset publish restore (the card's admin repo publish does not exist since Epic: admin command tree grouped by object #2307).
  • The pass mail names the lineage outcome and points at nemar admin dataset publish license-lineage for the sources: a stored review keeps the outcome, not the source records.
  • shared/openapi.json documents only the public catalog, so it has no admin route to add.

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2387

Version: 0.10.40-PR2387.e82c272
Commit: e82c272


🤖 Updated on each push.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Merge gate (lead): head e82c272. Every remote check passes after one rerun of unit-pure shards 2 and 5, which failed on the repull CLI flake (#2377). Review: round 1 panel (code+tests; errors+comments+types) found no path that denies wrongly; 3 important findings (a silent denial-mail failure, confirming runs that did not record confirm_failed, the recipient rule) and 6 more fixed; round 2 delta review resolved all nine items, and its 3 suggestions are fixed in e82c272. The switch PUBLICATION_AUTO_DENY_MODE stays absent (off) and is the owner's; auto-deny-switch-flag.test.ts guards it.

@neuromechanist
neuromechanist merged commit b781c19 into feature/issue-2182-epic-pq-decide Nov 26, 2026
50 of 53 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2369-auto-deny branch November 26, 2026 02:10

This branch was previously deployed

1 inactive deployment
npm — e82c2727 Deployed Nov 26, 2026 by neuromechanist via publish #4935
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