Skip to content

feat(api)!: unified intake, phase 2 — screening, delivery and purge on user-submissions - #791

Merged
sydevs-bot merged 24 commits into
mainfrom
claude/feat-724-submissions-pipeline
Sep 16, 2026
Merged

sydevs-bot merged 24 commits into
mainfrom
claude/feat-724-submissions-pipeline

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Three jobs replace five: screenSubmission (uniform base per type + cross-intake sender history), deliverSubmission (per-type, retried, logged per attempt), purgeSubmissions (per-type windows + the users orphan sweep).
  • Clients.mailingList arrives with three provider adapters behind one interface, a save-time credential check, and a field lock no API client can read through.
  • A registration opt-in now spawns a real subscribe row — a consent record with its own status and retries, not a timestamp that delivered nothing.

Built beside the three collections' own jobs, which keep running unchanged until Phase 3.

Changes

  • src/jobs/ScreenSubmissions/ — the verdict, the history read, proposal content screening. Queues delivery only on a clean verdict, and defers a queue run so it goes on rather than waiting for the next autoRun.
  • src/jobs/DeliverSubmissions/ — one deliverer per type behind a DeliveryOutcome union whose retryable flag is what bounds retries. deliverers.ts is the one Record<UserSubmission['type'], SubmissionDeliverer>, so a new type is one row and omitting it is a compile error.
  • src/jobs/PurgeSubmissions/ — retention.ts holds the windows and why each is its length; the job is the sweep.
  • src/lib/mailingList/ — one MailingListAdapter interface, three adapters implementing it, one registry. Every provider difference lives in its own adapter, and no call site switches on provider.
  • src/collections/UserSubmissions/screeningQueue.ts — the deferred queue run, shared by this collection's intake hook and the delivery hand-off.
  • src/lib/antiSpam/mxRecords.ts, src/lib/notifications/sendSubmissionReview.ts — promoted, not copied. The MX check's own docblock named a third consumer as the trigger for promoting it, and this is the third.

Preview

https://sahajcloud-sahajcloud-pr-791.up.railway.app — Railway rebuilds it on each push.

Migration

Two migrations.

  • src/migrations/20260915_162816_mailing_list_config.ts — five nullable columns on clients and _clients_v, plus three task slugs on the jobs enums. No backfill, no data transformed. down drops the columns and rebuilds the two enums.
  • src/migrations/20260916_045509_spam_submission_status.ts — one ALTER TYPE … ADD VALUE 'spam' on enum_user_submissions_status, for the status split in round 3. No row carries the new value yet, so there is nothing to backfill and nothing for down to strand.

No third migration for the form requirement below: a required field carrying an admin.condition is skipped by drizzle's NOT NULL pass, so the column stays nullable.

Test results

  • Lean gate: ✓ pnpm lint && pnpm typecheck && pnpm typecheck:tests && pnpm test:unit — 2098 unit tests, 148 files
  • Integration: ✓ the whole lane, 1386 tests across 82 files
  • Build: N/A — Railway builds the preview

Review round 3 (2026-09-16)

One thread, answered and adopted: spam is now a status option, and it is the machine's refusal. rejected means a manager's decline and nothing else. Both questions in that thread came back yes, so abuse counting reads status and screeningResult.verdict stops being load-bearing.

What it bought, beyond the simpler rule:

  • isMachineSpam is one comparison on an indexed column, where it was a zod parse of a JSON column.
  • loadSenderHistory selects status rather than screeningResult, and the "never select status" guard that protected the old rule is gone with it.
  • A declined proposal purges at 30 days, not 90. The proposals window can take rejected now that only a machine refusal lands in the spam window — retiring the 90-vs-30 wart round 2 documented rather than fixed.
  • isActiveRegistration excludes spam, rejected and failed, so a machine-refused registration still leaves the reminder sweep and the fullness count.

screeningResult.verdict stays, doing the job it is actually good at: naming which check refused, for the note a manager reads and for triage.

Review round 2 (2026-09-16)

Twenty-three threads. Nineteen adopted, three kept with evidence, one answered in round 3.

Finding Outcome
Provider switch in the validator, and in subscribe Adopted — de9b7ef
MailingListProvider restated rather than derived from Client Adopted — de9b7ef
Per-type branch in DeliverSubmissions Adopted — a8bc92d
screeningKick's name, and its home in lib/jobs Adopted — bda5860
Three thin enqueue-hook files Adopted — bda5860 (two revert to main)
senderHistory needs simplifying Adopted — 49583cb
Verdict shape asserted by hand, not zod Adopted — 49583cb
enforceSubscribeReach should go entirely Adopted — bcd2dd1
retention.ts re-export Adopted — 353f84c, 2ddb1b1
retention.ts comment volume Adopted — 353f84c
adminOnly.ts comment volume Adopted — bbcb5eb
form validation as required + condition Adopted — ec9d8b6
The event field's condition Adopted with one change — ec9d8b6
Two misplaced field descriptions Adopted — ec9d8b6
A cancel button on the registration reminder Filed — #794
contentScreening's walker looks pointless Kept — it is what makes the check see nested values
DeliveryOutcome's failure categories vs throw/catch Kept — retryable is the retry bound
Are we rebuilding Payload's email system? Kept — every send already goes through payload.sendEmail
spam as a status option Adopted — eda4cef (round 3)

The one correction worth reading. admin.condition is not admin-only. beforeChange/promise.js computes passesCondition server-side and skips validation when it is false, so it gates required on a REST write exactly as it hides the field in the browser. The hand-written per-type form branch is gone because of that.

Two places the reviewer's own suggestion was narrowed, both for the same reason — a false condition skips validation rather than refusing a value:

  • event's condition is type !== 'contact', not type !== 'contact' && !data?.form. The form clause would switch the validator off for precisely the row it exists to refuse: one naming both a form and an event.
  • The prohibition half cannot be a condition at all, so it lives in eventField's validator.

Manual verification

  1. In /admin, open a service → Config → Mailing List. Nothing but the switch until it is checked. Cycle provider through all three: doubleOptIn appears for Mailchimp only, and Brevo and Klaviyo each show their own read-only opt-in note under provider.
  2. Enter a deliberately wrong API key and save → the save is refused with the provider's message. Fix it, save, then re-save after editing only the service's name → no provider call in the logs.
  3. curl "$URL/api/clients?limit=1&select[mailingList]=true" -H 'Authorization: clients API-Key <key>' → no mailingList in the response.
  4. Create one submission of each type locally and watch the queue: screening verdicts and delivery attempts appear in activityLog. A refused row reads Spam in the list column, a manager's decline reads Rejected. Mailpit shows the contact delivery and the registration confirmation.
  5. A provider sandbox (or a stubbed adapter) shows a subscribe row landing, and a forced failure retrying.
  6. pnpm payload jobs:run --queue nightly with dryRun against seeded rows covering each retention window.

Items 4–6 need a dev server, Mailpit and a provider sandbox, none of which these sessions had.

Notes for reviewer

Cross-service subscribe is now allowed, on your call. An earlier revision of this PR added enforceSubscribeReach, refusing a subscribe row that named another service's form. Removed in round 2: a registration opt-in spawns a subscribe row for whichever service runs the class, so the route exists regardless, and gating only the direct path made the two disagree without closing anything. The int case is inverted rather than deleted, so re-adding the gate is a red test.

Two places I read the phase boundary and would like the call checked:

  • An untargeted proposal routes to CONTACT_EMAIL. event-submissions resolves a region from a regionHint column and walks its manager chain; user-submissions has neither regionHint nor region in Phase 1's column table, so there is nothing to resolve from. A proposal that names an event routes properly (its manager, then its region chain). Phase 3 brings the columns.
  • The duplicate-body check is scoped to one sender, where the check it descends from was cross-sender — that needed a queryable bodyHash column, which user-submissions does not have. Phase 2's stated base is MX + disposable + cross-intake history, so this is above the bar rather than below it, but the narrowing is real. Filed separately.

isActiveRegistration / activeRegistrationWhere — thread still open. The adversarial round asked for them to be dropped and defined in Phase 3. Kept: activeRegistrationWhere is queried by tests/int/screen-submissions.int.spec.ts, which is what proves #724's criterion that a refused registration leaves the fullness count — so deleting the file inlines that clause into the spec as a second definition. The reminder sweep, the follow-up sweep and the fullness count re-point in Phase 3. Round 3 added a third excluded state to the same helper, and #794 will add a fourth.

Deviation from #689's field spec, deliberate: the Brevo and Klaviyo opt-in notes render as the provider select's own per-value description (the existing SelectDescription component) rather than as a separate ui field. admin.description's function form is handed { i18n, t } and never the document, so a ui field could not have switched on the chosen provider without a new component.

Detail

The rule the design turns on. A machine refusal is status: 'spam'; rejected is a manager's decline. Two statuses rather than one, so nothing has to re-derive whose refusal it read — and a manager's judgement is never a spam strike against the person who wrote in. Enough of those strikes would refuse that person's next genuine submission. isMachineSpam is the one definition, pinned in both lanes. screeningResult.verdict says which check refused, never whether one did.

Retention reads the same column, which is the point: each status reaches exactly one window, so the windows stay disjoint by construction and a decline goes with the rest of its type at 30 days. An earlier revision folded both refusals into rejected, and the price was a declined proposal kept 90 days because no cheap predicate could separate them — the verdict that could lived in a JSON column nothing can where on. A spec pins both halves.

Why screening and delivery are two tasks. A transport failure must earn its own retries without re-running the screening work — and the history counts move underneath a retry, so a second screening run could reach a different verdict on the same row. Screening is therefore idempotent by refusing to run twice rather than by reaching the same answer twice. Both hand-offs defer a queue run, so neither leg waits on an autoRun it does not need.

Why the orphan sweep is half the retention story. Every submission upserts its sender into users, so deleting the message while keeping the address leaves the personal data behind and the promise unkept. A contact sender's data lives exactly as long as their message; a registration or a subscription pins the person, because the row itself is kept forever. DURABLE_TYPES is the one list answering both halves: which types no window may reach, and which pin a users row.

The event column is the link. A registration-spawned subscribe row carries the registration's event. That is what ties the consent back to its registration, what exempts the row from needing a form of its own, and what tags the subscription event-registration at delivery. No new column, and the exemption's condition is self-describing.

What the screening walker is for. checkNoUrls inspects top-level string values and never recurses, so handing it a raw proposed patch scans nothing: { address: { street: 'see buy-now.example.com' } } screens ok. Flattening it to dotted paths is what makes the check see the value, and what names the offending field in the message a manager reads. A proposal is an Events patch and Events nests, so that is the normal case, not a corner. The spec asserts the reason names the nested key.

Fixture pre-mortem. Both new int specs assume a forms document shaped actionType + recipient/client + confirmationType: 'redirect' + a fields list. Verified against tests/int/user-submissions-create.int.spec.ts, the working configuration this branch did not write. Rows are aged by injecting the job's now, never by editing createdAt, and the anchor is taken after every create so each row's real createdAt provably precedes it.

Two fixture findings kept in the test commit. The exclusion case first passed for the wrong reason — the MX stub was flipped before both rows were screened, so the row it called "refused" had been screened cleanly. And event-submissions.int.spec.ts mocked ScreenEventSubmissions/emailChecks, which this branch promoted: a vi.mock on a path that no longer exists stubs nothing and says nothing, so the spec ran a real DNS lookup. Both repointed.

managersOnlyFieldAccess asks who the caller is, not who they are not. Spelled !== 'clients' it answered true for a caller with no user at all — denied by the collection's own access today, so it failed open only where nothing currently looks, which is the kind of guard that stops being true quietly.

Not done, and out of scope here: the OpenAPI surface for the new columns, and /api/clients/{id}/subscribe — #695 explicitly does not build that endpoint, the unified create plus the queue replace it.

Closes #724

🤖 Written by the sydevs autonomous loop — see what this is

🤖 Generated with Claude Code

https://claude.ai/code/session_01CqNFA1U7DhDiu21GNrWUfd

Phase 2 of #695, per #724: the pipeline that acts on a `user-submissions`
row, built beside the three collections' own jobs rather than replacing
them — those keep running unchanged until Phase 3.

Three jobs, replacing five per-collection ones:

- `ScreenSubmissions` runs a uniform base for every type — disposable-list
  re-check, MX lookup, cross-intake sender history — plus content screening
  of a proposal's `proposed` patch, which no create-time scan reaches
  (`prepareUserSubmission` scans `submissionData`; `proposed` is a separate
  column). It writes the verdict and hands off; it never delivers.
- `DeliverSubmissions` is queued only after a clean verdict, which is the
  ordering the whole design turns on: a refused row never reaches a
  recipient, a provider or a manager. Per-type delivery, retries bounded by
  whether the failure could plausibly go differently, and an `activityLog`
  entry per attempt.
- `PurgeSubmissions` sweeps the per-type windows and then the `users`
  orphans. The second half is what makes retention mean anything: every
  submission upserts its sender, so deleting a message while keeping the
  address leaves the personal data and breaks the promise. A registration
  or subscribe row pins the person; a contact row does not.

Abuse counting reads `screeningResult.verdict`, never `status`. The four
shared statuses fold a machine verdict and a human decline into one
`rejected`, so counting off `status` would make a manager's judgement a
spam strike against the person who wrote in. `isMachineSpam` is the one
definition. Retention deliberately reads `status` instead — "has anyone
finished with this row" is a different question, and a declined proposal
is finished with at 30 days either way.

A spam verdict on a registration flags and nothing else: the row stands,
any email already sent stands, and `isActiveRegistration` /
`activeRegistrationWhere` are what exclude it from reminders and fullness.
Their consumers re-point in Phase 3, when `registrations` is deleted; the
pair exists now so the rule has one definition when they do.

Two modules were promoted rather than copied. `hasMxRecords` moves to
`@/lib/antiSpam/mxRecords` on its own docblock's terms — it named a third
consumer as the trigger, and this is the third. `sendSubmissionReview`
moves to `@/lib/notifications` for the same reason.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MTsH1PFSWfoHDtUeeEY2s7
All five columns nullable on both `clients` and `_clients_v`, no backfill,
plus the three new task slugs on the jobs enums. Generated, not hand-written.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MTsH1PFSWfoHDtUeeEY2s7
…tention

Six spec files. Each one is written against a defect it was first watched to
fail on — the rule the design turns on is verified twice, once in each lane:

- `submission-screening.spec.ts` and `screen-submissions.int.spec.ts` pin
  that abuse counting reads `screeningResult.verdict` and never `status`.
  Reintroducing the defect (`isMachineSpam` reading `status === 'rejected'`)
  turns both red. The int case seeds two senders with an identical shape —
  six `rejected` rows each — differing only in whether the machine or a
  person refused them, since that is the whole distinction.
- `submission-retention.spec.ts` pins the lower bound nothing else would
  catch: retention shorter than the screening window makes sender history
  find nothing, count zero and pass everything, with no error anywhere. It
  also walks every window proving none can select a `failed` row.
- `registration-active.spec.ts` pins the in-memory predicate against the
  `Where` on every status, so the two cannot drift before Phase 3 gives
  them their consumers.
- `mailing-list.spec.ts` pins the mapping, not the request shape: each
  provider names "this address opted out" differently, and getting that
  wrong re-adds an address that unsubscribed. It also pins that the Klaviyo
  request carries nothing which skips suppression.
- `purge-submissions.int.spec.ts` moves the clock rather than editing
  `createdAt`, and covers the orphan sweep on both sides — the sender who
  goes with their last message, and the one a registration still pins.

Two fixture findings worth keeping. The `screen-submissions` exclusion case
first passed for the wrong reason: the MX stub was flipped before both rows
were screened, so the row it called "refused" had been screened cleanly.
And `event-submissions.int.spec.ts` mocked `ScreenEventSubmissions/emailChecks`,
which this branch promoted to `@/lib/antiSpam/mxRecords` — a `vi.mock` on a
path that no longer exists stubs nothing and says nothing, so the spec ran a
real DNS lookup. Both are repointed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MTsH1PFSWfoHDtUeeEY2s7
A create-only client could already post a subscribe row naming **another**
service's form. Nothing delivered subscribe rows before, so the row simply
sat there — this branch is what turns it into a push to that other service's
provider, spending their list quota and sender reputation and putting a
stranger's address on their list. The row's own `client` column is stamped
from the key and cannot be forged, but it is not what delivery reads when a
form is named.

`enforceSubscribeReach` refuses the write instead, registered before
`prepareUserSubmission` so a forbidden target never upserts a `users` row.
The We Meditate roles keep reaching any form, which is the rule #695 states;
a row with no form is out of scope, since it inherits the provenance client
and can only reach the caller's own list.

`managersOnlyFieldAccess` now asks who the caller **is** rather than who they
are not. Spelled `!== 'clients'` it answered `true` for a caller with no user
at all — denied by the collection's own access today, so it failed open only
where nothing looks, which is exactly the kind of guard that stops being true
quietly.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MTsH1PFSWfoHDtUeeEY2s7
…ld lock

`docs/architecture.md` gains the three jobs and the verdict-vs-status rule.
`docs/rules/api-clients.md` gains what happens after the 201, the spawned
consent row, and the whole mailing-list group — including that no client can
read it at any depth, and that an opted-out address is never re-added.
`docs/rules/access.md` gains `managersOnlyFieldAccess` as the field-level
answer for a collection that is not restricted. `tests/COVERAGE.md` gains a
row per job.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MTsH1PFSWfoHDtUeeEY2s7
@railway-app

railway-app Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-791 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Sep 16, 2026 at 5:24 am UTC
1 service not affected by this PR
  • mailpit

@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-791 September 15, 2026 16:49 Destroyed
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 15, 2026
@sydevs-bot

sydevs-bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running
CI fix 1

recent dispatches
  • 05:13Z fix-ci · attempt 1 · session · done
  • 05:13Z fix-ci · attempt 1 · session
  • 04:48Z address-review · attempt 1 · session · done
  • 04:48Z address-review · attempt 1 · session
  • 00:58Z address-review · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

Phase 2 matches its ticket's shape: three jobs, the mailingList group, a real consent row. The rule it turns on — abuse counts the verdict, retention counts the status — is stated once and pinned. Two pieces exceed the ticket. src/lib/registrations/active.ts ships with no caller, and RETENTION_DAYS is a table the sweep never reads and actively contradicts. The subscribe-reach fix belongs here.

should-fix

  • RETENTION_DAYS has no consumer, and the sweep contradicts it — retention.ts:51
  • A third byte-similar copy of the deferred queue kick — enqueueSubmissionScreening.ts:15
  • isActiveRegistration / activeRegistrationWhere have no caller — active.ts:26
  • UNRESTRICTED_ROLES is an untyped role allowlist — enforceSubscribeReach.ts:14

consider

  • Docblock says a declined proposal purges at 30 days; it gets 90 — retention.ts:78
  • Screening kicks the queue, delivery does not — ScreenSubmissions.ts:130

Checked: whole diff less the migration snapshot; payload.config.ts autoRun; access/config/roles.ts grants; grepped every new export for consumers; both existing kick hooks; submission-retention.spec.ts.


Generated by Claude Code

Comment thread src/jobs/PurgeSubmissions/retention.ts Resolved
Comment thread src/lib/registrations/active.ts Resolved
Comment thread src/jobs/PurgeSubmissions/retention.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 15, 2026
The `machineSpam` window named no `type`, so every `rejected` row went at
90 days — registrations and subscriptions included, the two the retention
docblock called "kept forever". `RETENTION_DAYS` stated that policy and
nothing read it, so the guarantee was untested and untrue.

Drop the table, name the exclusion in the window, and fold the rationale
into `DURABLE_TYPES` — which now answers both questions it was always the
answer to: which types no window may reach, and which pin a `users` row.

`submission-retention.spec.ts` asserts the sweep instead of the table: a
window reaches a durable type by naming it or by naming no type at all,
and both shapes fail. Verified by reintroducing the missing clause.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bnig7vwVabvMNuZbxAQ8Rq
The `PURGE_WINDOWS` docblock claimed a manager-declined proposal is
finished with at 30 days "exactly like a refused one". It is not: a
decline is `rejected`, `proposals` selects `accepted`, and only the spam
window takes it — at 90 days.

Ninety is the right answer, not a bug to fix the other way. The sweep
cannot tell a decline from a machine refusal, because the verdict that
would separate them lives in a JSON column nothing can `where` on
cheaply. Erring long keeps the evidence a refusal is.

So the comment moves to the code, and a spec pins both halves, since a
claim no test reads is what produced the first one.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bnig7vwVabvMNuZbxAQ8Rq
`UNRESTRICTED_ROLES` was a bare `string[]` holding a second copy of role
knowledge that lives in `src/plugins/access/config/roles.ts`. Renaming a
role there left this file compiling, and the gate would have gone on
refusing writes it means to allow — a security boundary failing quietly.

`RoleSlug` is generated from that registry, so the rename is now a build
error. The membership test asks from the allowlist's side, since the
reverse needs a cast that would undo exactly that.

Also records that `wemeditate-app-client` holds no `user-submissions`
grant today and so cannot reach this hook — it stays named because the
exemption is about which surfaces render platform forms, not about which
of them currently has a key.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bnig7vwVabvMNuZbxAQ8Rq
This PR added the third near-identical copy of the deferred queue kick,
while promoting `hasMxRecords` on exactly that rule — three consumers is
a shared utility, two is a coincidence. The same rule applies here.

What was duplicated is the mechanism, not the queue call: the create
guard, the status sentinel, the two-second kick and its warning line.
`screeningKickHook` takes those. The queue call stays at each call site
with its own literal task slug, because passing the slug through as a
union needs a cast, and that would trade the duplication for the type
safety it is the only thing protecting.

Each hook is now its sentinel, its label and its queue call.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bnig7vwVabvMNuZbxAQ8Rq
`enqueueSubmissionScreening` kicks the queue once the transaction
commits; the delivery hand-off did not, so delivery waited for the next
15-minute autoRun rather than running on from the screening pass.

Harmless for the rows this phase serves. In Phase 3 it would move a
registrant's confirmation email from inside the 201 to a quarter of an
hour later, and `deliverRegistration` notes that email was in-request
before. Kicking costs nothing and closes that gap ahead of the phase
that would feel it.

Uses the same helper as the create hooks, so the delay, the
best-effort handling and the test suppression have one definition.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bnig7vwVabvMNuZbxAQ8Rq
The existing case seeded `accepted` rows, which is why it passed while
the spam window deleted a durable row at 90 days: that window selects
`rejected`. A refused registration is flagged and kept — #724's own
criterion — so the guarantee needed asserting in that status.

Verified by reintroducing the missing `type` clause and watching it go
red.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bnig7vwVabvMNuZbxAQ8Rq
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-791 September 15, 2026 17:22 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Review addressed — 5 adopted, 1 rebutted. Pushed 015ca9d. Lean gate and the five touched int specs are green.

One real defect: the machineSpam window named no type, so a rejected registration or subscription went at 90 days, not "forever". Both lanes now assert the sweep, not the table beside it.

Thread Outcome
RETENTION_DAYS unread, sweep contradicts it 4e253d8
Third copy of the deferred kick fe798b3
Declined proposal purges at 90, not 30 3ff13be
Untyped role allowlist 801b0d0
Delivery never kicked its queue 2addf13
active.ts has no caller Rebutted — open for you

On the open one: activeRegistrationWhere is queried by screen-submissions.int.spec.ts:306, which proves #724's fullness-count criterion. Dropping the file inlines that clause as a second definition.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 15, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review September 15, 2026 17:34
@sydevs-bot
sydevs-bot requested a review from Ardnived September 15, 2026 17:34
Comment thread src/lib/mailingList/subscribe.ts Resolved
Comment thread src/lib/mailingList/types.ts Resolved
Comment thread src/lib/mailingList/types.ts Resolved
Comment thread src/lib/registrations/active.ts Resolved
Comment thread src/plugins/access/adminOnly.ts Resolved
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 16, 2026
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-791 September 16, 2026 01:13 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Addressed all 23 threads — pushed ec9d8b6, eight commits. Lean gate green: lint, both typechecks, 2097 unit tests.

19 adopted, each with a commit and a reply in its thread: provider adapters replace both switches, one deliverer table, screeningKick relocated and the thin hooks gone (two revert to main), enforceSubscribeReach removed, form as required + condition, plus the comment and description trims.

3 kept, with evidence in the thread: the screening walker, DeliveryOutcome, and Payload's email system.

1 waiting on you: spam as a status option. Two questions in that thread — it deletes this PR's central rule, so I did not assume.

Filed #794 for the cancel button.

You were right that admin.condition does the job: it is evaluated server-side, so it gates required on the API path too. I narrowed your event condition to type !== 'contact' — the && !data?.form clause would switch it off for the row shape it judges.

Full table in the PR body.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 16, 2026
Picks up the corrected .github/workflows/workflow-state.yml. This branch was
cut before the legacy job was removed, so its copy still names the deleted
state-machine.yml and GitHub rejects the whole file on every
pull_request_review event.
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-791 September 16, 2026 01:49 Destroyed
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed awaiting labels Sep 16, 2026
`spam` joins the shared status vocabulary, and screening writes it instead
of `rejected`. `rejected` is now a manager's decline and nothing else.

The rule this replaces existed because one status carried both refusals:
abuse counting had to read `screeningResult.verdict` to avoid treating a
manager's judgement as a spam strike against the person who wrote in. With
two statuses the distinction is an indexed column, so `isMachineSpam` is one
comparison, `loadSenderHistory` selects `status` rather than the JSON
column, and the verdict goes back to saying only which check refused.

It pays for itself in retention too. The `proposals` window can take
`rejected`, so a declined proposal goes at 30 days instead of waiting out
the 90-day evidence window — the wart that existed only because no cheap
predicate could tell the two refusals apart.

`isActiveRegistration` excludes both, so a machine-refused registration
still leaves the reminder sweep and the fullness count.

Ardnived's call, on the thread at verdicts.ts:77.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CqNFA1U7DhDiu21GNrWUfd
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-791 September 16, 2026 05:09 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Adopted your spam call — eda4cef. One thread, one commit. Lean gate and the whole int lane green (1386 tests).

spam is the machine's refusal; rejected is a manager's decline. Both your questions answered yes, so abuse counting reads status and the verdict stops being load-bearing.

Thread Outcome
spam as a status option eda4cef

Three things it bought beyond the simpler rule:

  • isMachineSpam is one comparison on an indexed column, not a zod parse of JSON.
  • loadSenderHistory selects status, so the "never select status" guard goes too.
  • A declined proposal purges at 30 days, not 90 — the wart round 2 documented rather than fixed.

Migration 20260916_045509 adds the enum value. No row carries it yet, so nothing to backfill.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 16, 2026
`LIVE_PREVIEW_SIGNING_KEY` is declared twice in the server env schema, so
`tsc` refuses the file with TS1117 and every check after lint stops. The
duplicate is on `main`: #787 and #788 each added the same block, and a
squash merge of the second produced no conflict with the first. CI runs
only on pull requests here, so nothing typechecked `main` after the second
landed — this PR's merge ref is where the error first appears.

Both copies are byte-identical, docblock included, so the fix is to keep
one. Merging `main` in is what brings the defect into reach: the branch's
own copy of the file still carried the `SAHAJCLOUD_PREVIEW_SECRET` the two
preview PRs replaced.

`main` stays broken until this merges or another PR carries the same
removal.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KLoFETxwioFUddzP4kssBE
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-791 September 16, 2026 05:22 Destroyed
@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 16, 2026
@sydevs-bot sydevs-bot moved this from Revising to Approved in SYDevelopers Technical Roadmap Sep 16, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Sep 16, 2026
Merged via the queue into main with commit 68885e4 Sep 16, 2026
11 checks passed
@sydevs-bot
sydevs-bot deleted the claude/feat-724-submissions-pipeline branch September 16, 2026 05:51
@sydevs-bot sydevs-bot moved this from Approved to Done in SYDevelopers Technical Roadmap Sep 16, 2026

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-791 — 8a89f1cc Deployed Sep 16, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

feat(api)!: unified intake, phase 2 — screening, delivery and purge on user-submissions

3 participants