Skip to content

Phase P1: mail categories, storage and migration - #2270

Merged
neuromechanist merged 11 commits into
feature/issue-2260-epic-mail-categoriesfrom
feature/issue-2261-phase1-mail-categories
Nov 21, 2026
Merged

neuromechanist merged 11 commits into
feature/issue-2260-epic-mail-categoriesfrom
feature/issue-2261-phase1-mail-categories

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2261. Part of epic #2260.

Phase P1 declares the community mail categories once (news, rfcs, maintenance, recall) in shared/contract/mail-categories.ts, with their labels as account copy, and stores the three switchable ones in users.email_preferences. A recall has no stored key and no setter; preference responses report it as {on: true, locked: true} and any request naming recall is refused by name.

Migration 0146 carries each live account's announcements value into news, rfcs and maintenance explicitly and keeps the announcements key unchanged so the previous worker still honors opt-outs in the deploy window (phase P3 removes it); only strict JSON false is an opt-out, as the parser reads every key. It writes one summary audit row only when some account had stored preferences, so fresh test databases gain no audit row. It also adds category, recall_reference and skipped_count to broadcast_emails and rebuilds broadcast_outcomes so it accepts a skipped outcome, which counts toward done.

The admin alerts are now their own type, and getAdminEmailsForCategory accepts only those, so no community category can reach its first-admin fallback. communityRecipients in mail-recipients.ts is the one place a categorized send selects people (audiences per the owner's D3, never pending, test, deleted or the system account). saveEmailPreferences writes only the changed keys as a per-key json_set and one mail_category_changed audit row per community category whose stored value actually changes, in the same batch, so a concurrent write to another key is never reverted.

Owner answers applied (2026-11-20): news is on by default with opt-out (D1); owners and admins may turn a community category on or off for another account, audited, while another account's admin alerts stay the owner's (D8). nemar admin email-preferences gains --news, --rfcs and --maintenance; --announcements is refused with the replacement flags. ADR 0132 records the decisions (0130 and 0131 are reserved by the RFC program and biosig branches, so test/adr-index.unit.test.ts tolerates those two gaps until they land).

Deviations from the plan: the uncategorized group send keeps working through getBroadcastRecipients, now requiring all three categories on, until P3 makes category required and retires it; a new services/mail-preferences.ts holds the audited writer so P4 and P2 reuse it; the plan's "turn off only" ?user= rule is replaced by D8.

Website follow-up, not in this PR: the nine new mail.* account-copy keys must be transcribed to nemarOrg/website src/lib/account-copy.ts on staging (ADR 0045), and test/account-copy-parity.test.ts in the unit-pure job stays red until that lands; the keys are mail.category.{news,rfcs,maintenance,recall}.{label,description} and mail.recall.why, values in shared/contract/account-copy.ts.

Tested: bun run typecheck and bun run lint clean; targeted tests pass (110 in the new and changed files, 384 across the neighbors named in the plan); bun run migrations:d1-check passes on real local D1, and the migration's seeded cases were replayed on local D1 through cfman wrangler with the same results as the bun:sqlite test. Not run: the full bun test (epic to dev gate) and test/account-copy-parity.test.ts against an updated website, because the website copy is not transcribed yet.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2270

Version: 0.10.37-PR2270.be4efad
Commit: be4efad


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit d912386 into feature/issue-2260-epic-mail-categories Nov 21, 2026
29 of 31 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2261-phase1-mail-categories branch November 21, 2026 01:59

This branch was previously deployed

1 inactive deployment
npm — be4efad0 Deployed Nov 20, 2026 by neuromechanist via publish #4652
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