documentation: Knowledge note for the contact module (forms, held emails, retention)
Back to our planType
documentation
Summary
Write the short note that explains what happens when a neighbor sends a form on the site: the checks it passes, why its emails wait until the sender confirms their address, who gets what email, and when messages are deleted.
Problem
A form submission runs through about eight hooks from three places (this module, the form-builder plugin and the verification module), in an order that matters. The order and the hand-offs are only visible by reading cms/formBuilder.ts and src/payload.config.ts together.
What the generated reference already shows, so the note doesn't repeat it: forms, opens in a new tab and form-submissions, opens in a new tab list fields, field access and hook names; docs/architecture/data-model.md has a sentence per hook. Neither gives the order as one flow, or the hand-off to the verification module.
Proposed fix
Write src/modules/contact/README.md from the template. Owner's direction for every note (2026-11-06, Claude session, recorded on #712 and #719): a note explains the behavior and logic of its content types and code (what shows, where, when, who publishes or changes it, and the special rules), never a list of fields; and every link between fields is stated near the top, so no agent has to work it out from the code.
Links between fields the note states up front (each one checked in the code first):
senderEmailis copied from the form's first email field that holds one plain address, trimmed and lowercase, andemailConfirmedfrom the verification confirmer (domain/senderEmail.ts,cms/senderEmail.ts).- The emails the form builder made are held in the request context (
HELD_EMAILS,cms/heldEmails.ts), then stored on the submission by the next hook, which knows its id; the verification module'sonConfirmedlistenermarkSubmissionsConfirmedsends them, once, when the sender clicks (wired insrc/payload.config.ts). guardFormEmailsmatches each email to the form's email setting by position (cms/guardFormEmails.ts).- A Reply-To built from
{{email}}is kept only when it is one plain address; a From built from the submission becomes the default sender (domain/formEmails.ts). retentionHoldneeds a reason while on, and is never set on create (cms/retentionHold.ts).keepSendersWithMessagesis handed to the verification retention task, so a confirmed address stays while a message from it is kept (src/payload.config.ts). The periods come fromsrc/platform/lib/retention.ts, shared with verification.- A field's width up to half shares a row from 640 px (
ui/FormBuilderField.client.tsx).
Behaviors and rules the note must cover (each with the file or test named):
- The order of checks, cheapest first: size (413 or 400,
cms/limitSubmissionSize.ts), rate limit per connection (429,cms/rateLimits.ts), robot check (cms/verifyHumanSubmission.ts), then the sender lookup; staff are never limited or checked (cms/formBuilder.ts). - Emails to addresses the visitor typed are dropped; only staff-configured recipients get mail; past the site-wide hourly cap emails are dropped but the submission is stored (
domain/formEmails.ts,domain/rateLimits.ts). - A message reaches the team only once its sender confirms their address; a sender confirmed before gets the fixed acknowledgment instead, so nobody gets both (
cms/acknowledgeSender.ts,domain/acknowledgment.ts). - Retention: unconfirmed messages go after 48 hours, all after 12 months, unless on hold; the delete checks the rule again at the moment it runs (
cms/retention.ts,domain/retention.ts). - Forms are public to read; their email settings are staff-only (
cms/formBuilder.ts). - The page shows fixed texts by status, never the server's message, and a "check your email" note when the form asks for an email (
ui/submitErrorMessage.ts,ui/confirmEmailNote.ts).
Tests to name under "Rules and the tests that protect them": cms/*.test.ts (each hook), cms/deliveryToRecipient.test.ts, domain/*.test.ts, ui/FormBlock.client.test.tsx, ui/formSchema.test.ts, and src/payload.config.confirmation.test.ts.
Map entry: { "note": "src/modules/contact/README.md", "paths": ["src/modules/contact/**"] }
Acceptance criteria
- Not done:
src/modules/contact/README.mdfollowsdocs/knowledge/note-template.mdand is at most 80 lines. - Not done: It explains behavior and logic, not fields: no field lists, props tables or route lists. It links the generated pages named above for those.
- Not done: Right after its opening sentences, a short list states every link between fields named above (relationships, values copied or derived, mapper inputs and the props they become, hooks that copy a value), each with its file.
- Not done: Every behavior listed above is covered or, if the code turns out different, the note says what the code does and this issue gets a comment saying what changed.
- Not done: Every statement names the file or test it comes from, checked against the code at the branch's base.
- Not done:
docs/knowledge/index.mdgets one short line for the note (a few words after the link). It stays within the budget check. - Not done:
docs/knowledge/map.jsongets the entry above. - Not done:
npm run agent-context -- --writehas been run and its generated rule committed, andnpm run agent-contextpasses. If the budget check fails, this issue is not done; trimming other always-loaded files is not part of this issue. - Not done: Known contradictions: none of #279, #366 or #531 applies. For #158: check
docs/roles/legal-compliance.mdagainst the retention and email rules above; fix only statements of fact the code contradicts, and if a fix would change a rule, ask on #158 instead (policy file: the PR says so). - Not done: No code changes. A bug or gap found in the code goes under the note's "Known gaps" and is filed as its own issue (labeled
scope-creep, linked here). - Not done:
Prettier,Knowledge sync,PR PolicyandAgent contextpass.
Files likely touched
src/modules/contact/README.mddocs/knowledge/index.md(one line)docs/knowledge/map.json(one entry).claude/rules/generated/src--modules--contact--README.mddocs/roles/legal-compliance.md(only if a fact is wrong)
Must not touch
- Code under
src/(the note itself excepted): this issue documents behavior and changes none. - Other notes, their generated rules, and the files the other note issues under #712 list.
docs/knowledge/note-template.mdand the session-start set (CLAUDE.md,AGENTS.md,docs/guidelines/guard-rails.md).docs/architecture/data-model.md,docs/ui/data-types.md,docs/ui/component-set-modules.md: read them and fold this area's facts into the note (decision 0019, section 7); report any drift in them in a comment on #712 instead of editing them, since every note issue reads them.src/modules/README.md,src/platform/README.md,docs/project.md(#725 owns them).
Open questions
- Session-start room. The index line needs room at session start, which #799 makes. This issue is blocked by #799 and is not Ready until it lands; the line then stays within the budget check.
- Dead code first. #728 (the audit, waiting for the owner's keep-or-drop marks) removes unused or unwanted code before a note describes it. This issue is marked blocked by #728; it can start once #728 has settled this area, even if other areas are still open there.
- Size: not set; a cloud session can't read the board. Suggested: M.
Area
tooling, cms
Priority
medium
Generated by Claude Code, opens in a new tab