Skip to content

Email conferees a weekly update and mail readers' input to their legislators - #2359

Open
fastfadingviolets wants to merge 16 commits into
codeforboston:mainfrom
hyphacoop:conference-update
Open

fastfadingviolets wants to merge 16 commits into
codeforboston:mainfrom
hyphacoop:conference-update

Conversation

@fastfadingviolets

@fastfadingviolets fastfadingviolets commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Legislators on a conference committee now hear what the public thinks in two ways: a weekly email to each conference's conferees summarizing that week's input, and each reader's own input as a letter to their rep and senator, copying the reader. Readers are told before posting where their input goes and can preview the letter, with a reply-to of their choosing. Both streams send from their own authenticated subdomain, and outside production nothing reaches a legislator because recipients are swapped for a test address.

Closes hyphacoop#140
Closes hyphacoop#137
Closes hyphacoop#138
Closes hyphacoop#142
Closes hyphacoop#143

What's in it

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
maple-dev Ready Ready Preview Nov 13, 2026 6:00pm UTC

Request Review

fastfadingviolets and others added 12 commits November 13, 2026 10:01
Letters to legislators now come from noreply@letters.mapletestimony.org
and the weekly update to conferees from noreply@updates.mapletestimony.org,
on dev and prod, instead of notifications@. Each stream keeps its own
sender reputation, apart from the other and from the digests on the main
domain. Merge only after SendGrid has verified both subdomains, since it
rejects mail from a sender domain it has not authenticated.

Not verified: a send from either address; the subdomains' DNS was not
live, so SendGrid has not verified either yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A trigger on published testimony records each add, edit and withdrawal of
conference input in conferenceInputEvents, kept apart from
notificationEvents so the digest never sees them. On Mondays at 8:00
Eastern a job reads the previous Monday-to-Sunday window of events for the
net change, reads the conference's live input for where it stands, renders
the email HTML, and creates conferenceUpdates/{court}_{id}_{week}. A week
with no change stores nothing, and a second run leaves the first update as
it was. All conference input counts; an admin deletion counts as a
withdrawal. The update has no number and no unsubscribe line, and follows
the designer's mockup without its open-questions section and form.

The conference stance wording moves to shared/conferences so the digest
and the update use one copy.

Closes #137

Verified: functions jest and the conference component tests (119) pass;
the integration cases "conference weekly update" pass on a throwaway
emulator with the opt-in removed: the trigger, a callable edit, an admin
deletion, the job, an idempotent rerun and an empty week; functions and
website type checks pass apart from untracked scratch scripts under
scripts/firebase-admin.

Not verified: the HTML was laid beside the mockup before two lines of its
wording changed (the footer, and the note under "Read the testimony"); how
it renders in real mail clients; a full run of the integration file; the
job on a deployed schedule. "Read the testimony" links the conference page
without a total because Public Input has no date filter.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The job that compiles a conference's update now also queues its email, in
the same batch that stores the update, so a second run in the week finds the
update and sends nothing. The email goes out from MAPLE with replies to
info@ and a SendGrid category for the update, set in the document's
top-level headers: the send-email extension ignores message.headers. The
update records which conferees it went to and which were skipped for having
no email address.

Outside production no email reaches a legislator: the To line becomes
LETTER_TEST_RECIPIENT and the subject names who it would have gone to. With
no test address set, nothing is sent. The sending address comes from
CONFEREE_UPDATE_FROM and defaults to notifications@ until the updates
subdomain is authenticated.

Closes #138

Verified: functions jest (176); integration "conference weekly update" on a
throwaway emulator: swapped recipient and subject prefix, headers, replyTo,
no second email on rerun, real addresses in production mode, skipped
conferee without an address, update stored with no email when none has one;
that extension 0.1.36 reads headers from the top level of the document, from
its source; a run on the local emulator with the send-email extension sent
an update through SendGrid that reached the test inbox.

Not verified: the SendGrid category arriving; the sending address on the
updates subdomain, which waits on #140.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The review step before posting new conference input or a cosign now says
where it goes (public on MAPLE, emailed to the reader's own rep and
senator, counted in the weekly update), shows the letter as it will be
sent with a Cc row, and lets the reader give a different reply-to for that
letter alone. A cosign gains a review step after writing; a cosign without
a note gets the mockup's "add a line" banner. A reader whose profile has no
rep or senator is told MAPLE has no one to notify, and sees no letter.

The reply-to is kept on the reader's private draft and never copied to the
publication. The letter text comes from one pure renderer under
functions/src, so the daily sender can mail exactly what was previewed.

Closes #142

Verified: yarn test:website, yarn test, check-types, lint on the changed
files and yarn build:dev pass. A throwaway-emulator integration test shows the reply-to stays
on the draft and is absent from the publication. The review blocks were laid
beside the mockup's Review frame at panel width.

Not verified: phone width, and the review flow in the real panel with a
signed-in reader on the emulator. The cosign screens were not laid beside
their mockup frames.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A daily job reads the previous Eastern day's newly added conference input
and writes one email per letter, using the same renderer as the review
step's preview, to whichever of the reader's rep and senator has an
address. The reader is copied and replies go to the address they chose for
that letter, else their verified one. The email is created under the input
event's id, so a rerun sends nothing twice, and an input posted twice in a
day sends only its last. Inputs that are not mailed are recorded with the
reason. Outside production recipients are swapped for the test address.

Tracking headers go in the email document's top-level headers: the
send-email extension ignores message.headers.

Closes #143

Verified: unit tests for the day window, From header and email document;
an integration test on a throwaway emulator covering a sent letter, rerun,
reply-to override, a legislator without an address, each skip reason, and
a repost; input posted through the review step on the local emulator
was mailed through the send-email extension and SendGrid and reached the
test inbox, copying the reader.

Not verified: the letter's look beside the mockup, and DKIM and DMARC from
the letters subdomain.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The text part of each email was the HTML's textContent, which drops
line breaks: a letter's signature ran together ("Fake VioletHouse
district: 12th Suffolk...") and the update's figures ran into their
labels. Each is now rendered from the same data as its HTML, with a
line per signature line or figure and the cosigned input quoted.

Verified: letter and update unit tests (36) and functions tsc pass; a
letter and two weekly updates sent through the local emulator's
send-email extension and SendGrid arrived with readable text parts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The emulators never fire schedules, so a new admin script runs the
letters or weekly-update job as its next scheduled run would, or at a
given --now. It is local only, and mails LETTER_TEST_RECIPIENT as read
from the functions env files. The README says how to start the
emulators with the send-email extension, and the extension's local
secret file is ignored.

Verified: with the extension emulator and a SendGrid key, letters and
updates runs reached the test inbox; the only recipients were the test
address and the reader's reply-to, with legislators named only in the
subject; a bad --job is refused with the usual arguments error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An edit to posted conference input now mails a new letter, its subject
marked "(updated)" unless the input was also first posted in the same
day's run; the preview shows the same subject while editing. The letter's
footer links the conference's page rather than nothing. The draft holding
the reply-to is found by court as well as conference, and a reply-to that
is not a single address is refused on the draft and ignored by the sender,
which falls back to the reader's verified email. The conference's name
comes from one helper in functions/src/shared.

Verified: functions jest (letter, letters, testimony); yarn test:website
conference tests (128); check-types; lint; integration conferenceLetters
and testimony on a throwaway emulator (edit mailed as update, post and
edit the same day mailed once as new, conference link).

Not verified: yarn build:dev. An edit whose original letter was skipped is
still marked "(updated)"; a same-day post and edit previews "(updated)" but
sends without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The update's changes ran Monday 00:00 to Monday 00:00 but the job runs at
8:00, so input in those eight hours waited a week. They now run from a week
before the compile to the compile. The update keeps the Monday it is named
for in its id, weekStart and heading. A Monday run that fails and is rerun
later in the week misses or repeats about a day of changes.

Verified: functions jest (weekWindow across the week and daylight saving);
integration testimony.test.ts on a throwaway emulator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The daily letter job ran at 9:00 Eastern but mailed the previous calendar
day, so input posted before 9:00 waited a day, and a post at 23:00 edited
at 8:00 was mailed twice. The day's window now runs from the run a day
before to this one, as the weekly update's does, stepping back a calendar
day so the windows meet at 9:00 across clock changes.

Both scheduled jobs now take the time the run was due from the scheduler,
not the time it started, so each window begins exactly where the last one
ended. The jobs take that time as a required argument, and the local
run-once script runs the letters as of now.

Closes #145

Verified: dayWindow tests for the 9:00-to-9:00 window, input posted at
00:30 mailed that morning, and both clock changes; functions jest for
conferenceLetters and conferenceUpdates (38); check-types, functions tsc,
lint and prettier; the conferenceLetters integration test (10/10) on a
throwaway emulator with a Typesense stand-in, before now became required.

Not verified: a real scheduled run passing scheduleTime; the testimony
integration test's weekly update cases; yarn build:dev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each letter and weekly conference update is now recorded at
/legislatorMail under its /emails document's id, created in the same
batch, so neither exists without the other and a rerun adds nothing.
The record keeps the kind, court, the legislators' member codes (the real
ones outside production), the subject as they see it and the body; a
letter adds the reader, testimony, version, conference and whether it
went out as an update, and an update adds its week, standing and changes.
It replaces /conferenceUpdates, so an update no conferee can receive is
no longer stored. Readers can read the records of their own letters.

Closes #146

Verified: conferenceLetters and testimony integration suites (89) on a
throwaway emulator with a Typesense stub, including records, reruns and
the read rule; functions jest for conference letters, updates and email;
check-types, functions tsc, lint, build:dev.

Not verified: the composite index deploys; a real scheduled run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The letter job decided whether an edit was an update from the events in
its own run, so a version already mailed could go out again and an edit
could be marked "(updated)" after an original that was never sent. It now
reads /legislatorMail: an event whose own letter is on record is done, an
input whose current version already has a letter is skipped with the new
reason alreadySent, and a letter is an update only when an earlier one
for that input is on record. The reader's preview asks the same question
of their own records, so its subject matches the letter that is sent.

Closes #147

Verified: conferenceLetters and testimony integration suites (92) on a
throwaway emulator with a Typesense stub, including each version mailed
once, an edit after a skipped original going out unmarked, an edit after
a sent letter marked updated, and the preview's query under the read rule;
InputForm and CosignForm tests for the preview's subject; functions jest
for conference letters, updates and email; test:website, check-types,
lint, build:dev.

Not verified: the preview in a running site; the preview's two-field
query against real Firestore indexes; a real scheduled run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fastfadingviolets and others added 3 commits November 13, 2026 10:01
The letter and weekly update jobs read the events whose publication was
written in their window, but the trigger records an event after that
write, sometimes after the run has read the window. Such an event was in
no window: no letter, no skip, missing from the update. Events now carry
recordedAt, the time the event itself was written, and both jobs read by
it, so a late event goes out with the next run. The trigger creates the
event, so a second delivery keeps the first time.

A letter or update that fails now fails the run after the others, and
the schedules retry it; what was sent or skipped is created by id, so a
retry repeats nothing. An event already mailed or skipped is left alone
on any later run, read once for the window, so a rerun no longer records
a mailed event as superseded and a skip is final.

Verified: conferenceLetters and testimony integration (94) on a
throwaway emulator with a Typesense stub, including an edit recorded
just after a run going out on the next, and a rerun after a later edit
leaving the first letter alone; functions jest for conference letters,
updates and email; functions tsc, check-types, lint, formatting.

Not verified: a run failing and being retried; that a retried run gets
the original scheduleTime from Cloud Scheduler; a real scheduled run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Editing a posted cosign mailed the legislators an updated letter the
reader never previewed: the edit posted straight from its note screen.
Both forms now end at one review step, with the letter preview, the
reason for the change and the post rule (changed, and a reason when
editing) worked out in one place. The write screens stay separate, as
the mockup draws them. The panel keeps one step state for both.

Posting an edit also clears the form's reason, so the next edit no
longer starts with the last one's.

Closes #148

Verified: test:website (296), check-types, lint, formatting. On the
local stack: a cosign edit goes write, review, post with a reason
required; after the letter job mailed it, the next edit previews
"(updated)"; the next edit's reason is empty; the cosign review stacks
at about 560px.
Not verified: build:dev (the dev server held .next); exactly 390px;
the review laid beside the mockup's compose review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The functions sync every testimony and bill write to Typesense, which CI
runs as a service. Without it locally, each sync threw, the emulator
killed that function's worker, and every later event waited on a cold
start; the backlog timed out triggers the tests wait on, the cosign tally
most often. The runner now checks the TYPESENSE_API_URL in the demo
project's env file and stops with the command to start it.

Verified: without Typesense, 160 worker loads and tally timeouts; with a
stand-in answering on 8108, 16 loads and testimony plus conferenceLetters
pass (88/88); the runner stops with its message when nothing answers.

Not verified: a full run against a real Typesense container.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fastfadingviolets

Copy link
Copy Markdown
Contributor Author

Posting testimony:

image

legislator email:

image

CC to poster:

image

Editing testimony:

image

Legislator email:

image

CC:

image

Cosigning with input:

image

Legislator email:

image

CC:

image

Cosigning, no input:

image

Legislator email:

image

I goofed and did not edit the CC address, so this has no CC.


Update emails:

image image

This branch was successfully deployed

1 active deployment
Preview – maple-dev — b0d9ee9d Deployed Nov 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant