Repository navigation
Conversation
Every class sign-up the spam check refuses now reaches admins in a digest, configured on a new `refused_registrations` notification preference (sydevs/SahajAtlasWeb#259). - `registration-refusals` records one row per refusal: the class and the code. A refusal at the form is recorded by a `user-submissions` afterError hook and keeps nothing the visitor typed; a registration screening files as spam links the row that already holds who it was. Admin-only access, restricted, swept after 90 days. - `SendRefusedRegistrationDigests` sends to managers with `type: 'admin'`, daily or weekly by the same cadence and watermark as the registration digest, whose cadence logic both now share. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g ones atomically From an adversarial review of the refused sign-ups digest: - A refusal at the form is now an hourly count per class and code, upserted on the pool against a unique (event, reason, hour) index, and counted only for a published class taking registrations. Anyone holding the published widget key can be refused for free, so a flood now moves a number rather than adding rows, and cannot put an arbitrary class in the digest. - The digest reads whole hours that ended before it ran, so an hour is never split, and lists at most 50 classes, most-refused first. - `screenSubmission` writes the spam status and the refusal row in one explicit transaction. A task gets no transaction of its own, so a failed refusal insert used to leave a settled `spam` row no retry would record. - No fallback cadence: the migration writes `Daily Summary` into every existing manager's preferences, so what an admin sees is what is sent. An admin at Never has their watermark advanced, so re-enabling starts fresh. - The migration's down no longer drops a constraint CASCADE already removed, and clears the new task's job rows before recreating the enum. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🚅 Deployed to the SahajCloud-pr-1052 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
Holistic. The shape is the one #259's own build plan asked this repo for — record a refusal, add a fifth notification type with its digest job and email — and nothing is smuggled in beside it. The cost is real: a collection, a hook, a job, an email, a cadence module and a backfill. The two refusal stages are stored as two record shapes in one table, which is what forces the nullable hour and submission, the two-armed query and the two-shape email — and only one of those stages has nowhere else to live (finding 2). For your call: every existing manager is backfilled to Daily Summary, and #259 still records production as serving the always-pass test sitekey with TURNSTILE_SECRET_KEY unread. If that secret is the real one, the first digest is every atlas sign-up, to every admin. This is also the repo's first collection-level afterError, and the int spec iterates collection.hooks.afterError itself, so nothing here proves Payload dispatches it over HTTP.
Findings
should-fix—REASON_LABELSrestatesVERDICT_NOTESin a second, untyped vocabulary (SendRefusedRegistrationDigests.ts:38).consider— the screening half ofregistration-refusalscopies thespamsubmission row it points at (ScreenSubmissions.ts:142).consider— engineer-voiced copy forcaptcha_unavailable(SendRefusedRegistrationDigests.ts:40).
What was checked. Diff against origin/main: 29 files, 29.8k of it the generated snapshot. Read whole: the new collection, recordRefusedRegistration, both digest jobs, digestCadence, the migration up/down, verdicts.ts. Window math: [hour(since), hour(until)) leaves no gap and no overlap. The up backfill carries method: email, so a hidden row cannot fail validation. Preview answers 200; not signed in — no PREVIEW_ADMIN_EMAIL in a routine.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The digest held one untyped `Record<string, string>` restating all six screening verdicts in second words. A verdict added to `VERDICT_NOTES` reached an admin's inbox as `no_mx_records`, with nothing to catch it, and the two wordings of the same verdict could drift apart silently. Each stage now answers for its own vocabulary: the form reads a `Record<AntiSpamCode, string>`, so a code added to the write guard is a compile error; screening reads `VERDICT_NOTES` itself. That also fixes a collision the one map could not express — `invalid_email` and `disposable_email` are a name each stage spells for its own check. The int spec pins the screening card against `VERDICT_NOTES`, so a second wording cannot come back. Watched it fail with the old label restored. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWQwPuSpyyL8KPkmy2
"our own configuration, or Cloudflare unreachable" names our internals, and this is the one code that means a real visitor was turned away — the line an admin most needs to read at a glance. The email prints each form reason after a count, so the label stays a noun phrase; the section's own note already says these were turned away. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWQwPuSpyyL8KPkmy2
|
Addressed the adversarial review: two commits pushed, three threads resolved. Adopted
Rebutted
Lean gate green: 234 unit files, 2971 tests. The body's Notes for reviewer still describes round one only. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
All three conflicts were the same figure: the unit lane's file and test counts, which `tests/unit/perf-figures-pinned.spec.ts` pins to the specs on disk. Neither side described the merged tree — this branch recorded 234 / 2971, `main` 234 / 2992 — so both were replaced by a measurement of the merge: 235 files / 2996 tests, now a row of its own in tests/PERF.md. `main`'s own changes to the digest area merged without a conflict and need nothing from this branch. `formatShortDate` grew a time-zone argument, and the refused-sign-up digest renders no dates. `evaluateRegistrationGate` grew a started-session rejection, and its `registration_closed` is not an `AntiSpamCode`, so a gating refusal is still outside what this digest records. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZWtuvUBV5JTvHVhry
|
Merged All three conflicts were one figure: the unit lane's file and test counts, which
Lean gate green. Int specs The body's "234 unit files / 2971 tests" line is stale by the same figure. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
One conflict: `src/migrations/index.ts`, where #1059 and this branch each added an import. Both kept, in timestamp order. The merge leaves this branch's `20261030_203909_registration_refusals` behind #1059's newer `20261101_191500_atlas_drop_time_in_place`, so the newest snapshot no longer carries the collection and `migrate:create` re-emits every statement of it. `20261102_012821_merge_1052_main_snapshot` keeps that snapshot with no DDL, which heals the chain: replaying the two `task_slug` enum values would abort the boot migration. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXjBYEEvGDHNLg5Zan
`registration-refusals` made six, so the sentence naming what the holding pattern misses was one short in both copies of it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXjBYEEvGDHNLg5Zan
|
Merged What the diff cannot show: the merge puts Also fixed a stale ordinal this PR left in Lean gate green — lint, format, both typechecks, 234 unit files. CI runs the rest. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Superseded by #1067. The refused-sign-ups digest becomes one section of the per-role digest in #1070, which keeps this branch's |
Summary
captcha_failedis alogger.warn, andcaptcha_unavailableis alogger.errorplus Sentry. So a captcha refusing every real visitor, which the goal says may be happening in production today, was invisible. A refusal at screening was already stored as aspamrow, but nothing told anyone about it, and the visitor had been shown a success message.registration-refusals, records both kinds. The digest job reads it with the same cadence and watermark pattern asSendRegistrationDigests.Change outline
Flow — where a refused sign-up is recorded
POST /api/user-submissions (type: registration, x-turnstile-token) writeGuard beforeValidate # captcha, URL scan, email checks prepareUserSubmission # the same checks over submissionData → throws APIError { code } # nothing is written: the create rolls back + user-submissions afterError src/collections/UserSubmissions/hooks/recordRefusedRegistration.ts + a client caller, a spam-check code (AntiSpamCode), type: registration, + a published class not in external mode + → INSERT … ON CONFLICT (event, reason, hour) DO UPDATE count + 1 # on the pg pool + # the class, the code and the hour only: nothing the visitor typed screenSubmission job src/jobs/ScreenSubmissions/ScreenSubmissions.ts verdict ≠ ok → status: spam + registration → registration-refusals { stage: screening, reason: verdict, submission } + # same explicit transaction as the status writeBehaviour — the digest
Files
The migration is generated. It has two hand edits.
upbackfillsrefused_registrations: Daily Summaryinto every existing manager's preferences, leaving a choice already stored alone.downfollows theimport_pluginmigration: it drops the constraintCASCADEalready removed, and clears the new task's job rows before recreating the enum.Preview
On this PR's Railway preview (
https://sahajcloud-sahajcloud-pr-<this PR>.up.railway.app):/admin/account, Contact tab: the Refused Sign-ups notification row, which only admins see./admin/collections/registration-refusals: the admin list the digest links to. It is empty until something is refused.Data: nothing to seed for these. A refusal needs a client key and a published class, as in the manual steps below.
Test results
refused-registration-digests.intandscreen-submissions.int, 31 passed.pending, and the retry records it.refused-registration-digest(template and text twin, the cadence helper),job-schedules,notification-preferences,retention-discovery,json-field-schemas,lib-boundary,sanitized-config-rules,client-bundle-safety.up,migrate:down(the batch, including thisdown) andupagain. The backfill statement was run against real rows: one with other keys, one withNULL, one that had already chosenNever.Manual verification
On the preview, with an atlas client key:
POST /api/user-submissionswithtype: registration, a published class'sevent, andx-turnstile-token: bogus. Expect a 403captcha_failed, and one Refused Sign-ups row for that class: stage "At the form", count 1. Send it again in the same hour and the count goes to 2. No row is added.sendRefusedRegistrationDigestsfrom the Jobs UI once the hour has ended, or wait for 07:00 UTC. Mailpit should show "Refused sign-ups: 2" with the class and "2× The captcha check failed".Decisions for the maintainer
user-submissionsrow with statusspam. That would let an admin contact the person. But registrations are durable, so those rows would never be swept. It would also give a captcha-less caller a way to put spam strikes on any email address.type: 'admin'. A refusal can land on any class, and only an admin sees every one. Alternative: each class's own manager also gets their class's refusals, on their own preference.MACHINE_SPAM_DAYS. A screening row only points at the registration; that registration is durable and was kept before this change.registration-refusalsis a new collection. It holds no visitor PII and declares its own retention, so it falls outside the stop condition in the brief.Notes for reviewer
An adversarial review ran on the first commit. Adopted:
runJobsisolatestransactionIDasundefined). So thespamstatus committed alone, and a failed refusal insert left a settled row that the retry's guard skips. The fix is an explicitinitTransaction/commitTransactionaround both writes, plus a spec that makes the insert fail.downfailed. It dropped a constraintCASCADEhad already removed, and recreated an enum while job rows still used the new value. Both fixed, and verified against a real database.Not adopted:
captcha_failed. True, and they cannot be told apart without identifying the visitor. The email now says the counts include repeated attempts and automated requests, and should be read as a pattern.submissionDataimport and the per-admin Sentry capture. Both are copied fromSendRegistrationDigestson purpose: the brief asked for the same pattern, not a parallel one.Security review: the diff matches
securityReview.triggerPattern(src/plugins/access/,src/collections/Managers/, auser-submissionshook). The adversarial review covered access, privacy and abuse, but/security-reviewitself was not run.Detail
Why
afterError, not the write guard. It is one seam for both refusal sites, the write guard andprepareUserSubmission, and for any code added toAntiSpamCode. TheRecord<AntiSpamCode, true>makes a new code a compile error until someone classifies it. It runs fromrouteErroronly, after the create's transaction is killed (create.js→killTransaction), so the count is written on the pool. A client only ever creates over REST. The int spec drives the real create through the Local API, then hands the caught error to the collection's hooks asrouteErrordoes. That mirrors howdatabase-cast-errors.inttests the rootafterError.Hour buckets. The digest reads
[hour(since), hour(runStart)). Each run'ssinceis the previous run'srunStart, so every hour lands in exactly one digest, and the hour still being counted waits for the next one. A screening row is read by its owncreatedAt, as the registration digest reads its rows.Unverified:
TURNSTILE_SECRET_KEYis the real secret or the test one. That decides whether the first digest shows every sign-up refused (captcha_failed) or none.Part of sydevs/SahajAtlasWeb#259. It does not close it: the goal's other open lines belong to other tickets.
🤖 Generated with Claude Code