feat(emails): cold-start nudge sweep for welcomed accounts with no artist (chat#1889 row 15)
Matrix row 15 in recoupable/chat#1889. The issue had this deferred pending "detection infra (scheduled sweep + dedupe marker)" — this PR builds that infra. Stacked on #784 (shared email layout) and contains #788's commit (schedule-confirmation email) beneath it; review after both.
Why
The welcome email fires on account creation, regardless of whether a valuation preceded it. So a cold-start signup gets an email telling them to "confirm your artists" and "see your baseline valuation" for records that do not exist.
Measured, email_send_log 2026-07-23 → 2026-07-26: of 9 accounts welcomed, 6 had zero artists, zero catalogs, and had never run a valuation.
There is no event to hang detection on — the signal is the absence of a roster some time later — so this is a scheduled sweep rather than a handler-fired send.
What changed
getColdStartAccountIds(pure) — welcomed, minus rostered, minus already-nudged. Pure so the selection rule is testable without the sweep's three reads.selectRosteredAccountIds— the account side ofaccount_artist_ids, which the existingselectAccountArtistIdsdoes not return (it selects onlyartist_id). Fails closed on a read error: it returns the input set, so a database problem can never make every account look cold-start and trigger a mass nudge.selectEmailSendLoggainscreatedAfter/createdBefore— additive, no existing caller affected.buildColdStartNudgeEmail/sendColdStartNudgeEmail— on the sharedrenderEmailLayout, asking for the one thing that unblocks everything else (pick the artist), CTA to/setup/artists.runColdStartNudgeSweep+coldStartNudgeHandlerbehindCRON_SECRET(validateCronRequest, mirroring the two existing internal cron handlers), wired to a daily Vercel cron at 15:00 UTC invercel.json.
Window: 1 to 14 days after the welcome. Below a day the user may still be mid-setup; past two weeks a nudge reads as spam rather than a reminder. Dedupe is the cold_start_nudge_email marker in email_send_log, so a cron retry or a manual re-run cannot double-send. Sends are sequential on purpose — no latency requirement, and it keeps the send rate gentle.
Verification
TDD, red → green (getColdStartAccountIds RED as "Cannot find module", then green):
```
pnpm exec vitest run lib/onboarding
Test Files 2 passed (2)
Tests 9 passed (9)
```
Sweep tests cover: only-unrostered are nudged, an already-nudged account is skipped (the retry guard), the exact 1-to-14-day window boundaries (createdAfter / createdBefore asserted against an injected now), a no-op empty window that skips the roster read entirely, and sent counting only sends that actually went out (e.g. a wallet-only account with no address).
```
pnpm exec vitest run # full suite, no regressions
Test Files 788 passed (788)
Tests 4266 passed (4266)
```
pnpm exec tsc --noEmit clean for the touched files; vercel.json re-validated as parseable JSON.
Not yet verified live — this needs a cron invocation against the preview with CRON_SECRET to confirm it selects the real cold-start cohort before it is allowed to send to them. I would recommend a dry-run flag or a Telegram-only first pass before this goes to production, since it emails real users.
Tracked in chat#1889 (matrix row 15).
Summary by cubic
Adds a daily cold-start nudge that emails welcomed accounts with no artist to prompt roster setup, fulfilling chat#1889 row 15. Also unifies email styling and confirms newly created schedules so signups know what will arrive and when.
- New Features
- Daily Vercel cron (15:00 UTC) calls GET /api/internal/cold-start-nudge, gated by CRON_SECRET.
- Selection: welcomed 1–14 days ago (from
email_send_log), minus rostered (account_artist_ids), minus already nudged; roster read fails closed to prevent mass sends. - Dedupe via
cold_start_nudge_emailinemail_send_log; sequential sends; logs each attempt. - New email:
buildColdStartNudgeEmail+sendColdStartNudgeEmail, shared layout, CTA to/setup/artists. - Shared
renderEmailLayoutadopted by welcome, valuation, and weekly-report paths (viaprocessAndSendEmail). - New schedule-confirmation email (
sendScheduleConfirmationEmail) sent after task creation; cadence fromdescribeCronCadence; deduped per task inemail_send_log. - Infra:
selectEmailSendLogaddscreatedAfter/createdBefore; newselectRosteredAccountIds; cron wired invercel.json.