documentation: Knowledge note for the verification module (email confirmation by link)
Back to our planType
documentation
Summary
Write the short note that explains how the site checks that an email address belongs to the person who typed it: the confirmation link, its limits, the Confirm button, the welcome email, and how long confirmed and unconfirmed addresses are kept.
Problem
Contact and sign-up both depend on this module, but only through a service and listeners src/payload.config.ts hands over. What happens on a click, and what the other modules get, is visible only by reading the confirmer, the endpoint and the config together.
What the generated reference already shows, so the note doesn't repeat it: email-confirmations, opens in a new tab lists fields (admin-only, server-set), access and the confirm endpoint; routes.md lists /confirm-email. Missing: the link rules, limits, listeners, keepers and retention.
Proposed fix
Write src/modules/verification/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):
- The link's token is never stored: the record keeps its SHA-256 (
cms/token.ts), found again by hash when the link is followed (cms/store.ts). onConfirmedlisteners and retentionkeeperscome fromsrc/payload.config.ts: contact'smarkSubmissionsConfirmedsends the held emails, contact's and accounts' keepers keep a confirmed address while it is used (decision 0008).- The service shape is
src/platform/payload/emailConfirmer.ts; contact and sign-up call it without importing this module. - Retention periods come from
src/platform/lib/retention.ts(shared with contact), the link lifetime fromsrc/platform/lib/linkLifetimes.ts. - The per-address window fields are hidden and set only by the server (
cms/emailConfirmations.ts,domain/rules.ts).
Behaviors and rules the note must cover (each with the file or test named):
- Nothing confirms on page load: the Confirm button posts the token with the robot check, because mail scanners open links (
cms/confirmEndpoint.ts,ui/ConfirmEmail.client.tsx, #303). - The first valid click within 24 hours confirms, runs the listeners (one failing doesn't stop the others) and sends the welcome email once; a later click says already confirmed (
cms/confirmEmail.ts). - Limits: per connection per hour, per address per day, site-wide per hour, and clicks per connection; over any, nothing is sent and the answer is the same (
domain/limits.ts,cms/requestConfirmation.ts). - The confirmer never throws, so a failure never loses the message or sign-up that asked; it runs in its own transaction (
cms/emailConfirmer.ts,cms/ownTransaction.ts). - An address Payload's email check refuses gets no record and no link; the asking message is kept (
cms/emailConfirmations.ts). - The page reads where a link stands without changing it, and hides the button for a dead link (
use-cases/getConfirmationLinkStatus.ts, #391). - Retention: unconfirmed addresses go 48 hours after their last link, confirmed ones 12 months after confirming unless a keeper needs them; a failing keeper stops the run before anything confirmed is deleted (
cms/retention.ts). - Logs carry only the failure's kind, never the address (
cms/logFailure.ts).
Tests to name under "Rules and the tests that protect them": cms/*.test.ts, domain/emails.test.ts, domain/rules.test.ts, ui/ConfirmEmail.client.test.tsx, use-cases/getConfirmationLinkStatus.test.ts, and src/payload.config.confirmation.test.ts.
Map entry: { "note": "src/modules/verification/README.md", "paths": ["src/modules/verification/**"] }
Acceptance criteria
- Not done:
src/modules/verification/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, #158, #366 or #531 applies to this module.
- 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/verification/README.mddocs/knowledge/index.md(one line)docs/knowledge/map.json(one entry).claude/rules/generated/src--modules--verification--README.md
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, auth
Priority
medium
Generated by Claude Code, opens in a new tab