Mail relay: launch and a domain move need no click; a non-public copy neither enrols nor sends by itself

The copy rule now goes by direction. A public site that finds another host's connection in its database
(its development address after launch, its old domain after a move) enrols by itself. A site that says it
is not public - IAPL_NOINDEX=1, or a host in the new mail.relay.developmentHosts - and holds another host's
connection is a copy of that site's data: it neither enrols nor sends until "Connect again", also when it
has a token of its own (production's database copied back onto the development address). The consent is
stored with the copy (acceptedHosts), so the next fresh copy waits again.

- mail.relay.otherHosts: 'auto' (default) | 'wait' | 'enrol' | list of the site's own hosts
- mail.relay.developmentHosts, siteIsNonPublic() exported
- the copy refusal ends when its reason does (no cool-down; the panel recomputes it on every read)
- doctor: info for a public site whose database knows another host (the launched site, or a copy that
  forgot IAPL_NOINDEX)
- contract copy 1.7.1 (wording only)
- docs, AGENT.md, skills, changelog draft

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 00:46:16 +01:00
co-authored by Claude Fable 5.2
parent acfcf72c03
commit 49927205bb
30 changed files with 443 additions and 119 deletions
+18 -7
View File
@@ -24,6 +24,12 @@ export type RelayOptions = {
accountMail?: { perAddress?: number; perVisitor?: number; windowMinutes?: number } | false
/** Calls to the public confirm route per address. Default 10 a minute. */
confirmRateLimit?: { max?: number; windowMs?: number }
/**
* Host patterns of development and preview addresses (`*` = any characters), for example
* `['*.dev.example-agency.pl']`. A site on such a host is treated as a non-public copy for `otherHosts`,
* exactly like a site with `IAPL_NOINDEX=1`. Nothing is built in: name the agency's own pattern here.
*/
developmentHosts?: string[]
/**
* `'auto'` (default): the site enrols by itself on the first send without a token, and again after
* the service asks for it. `'manual'`: only "Connect" in the panel or `enrolRelay()` enrols.
@@ -40,14 +46,19 @@ export type RelayOptions = {
/** The kind of a message that carries no mark of its own; return undefined to keep the default (`system`). */
kind?: (message: SendEmailOptions) => MailKind | undefined
/**
* What a site does when its database already holds the connection of ANOTHER host and none of its own —
* the sign of a copied database (staging made from production), of a moved domain, or of two sites on one
* database. Default `'wait'`: the site does not enrol by itself (a copy with production's data would start
* mailing real people); an admin presses "Connect again", once. `'enrol'`: enrol by itself all the same.
* A list: these hosts are this site's own (its old domain, its second domain) — beside them it enrols by
* itself, beside any other it waits. `www.` and the bare domain are always one site.
* What a site does when its database holds the connection of ANOTHER host — a launch (the development
* address's entry is still there), a moved domain, or a copy of another site's database.
*
* Default (`'auto'`): by direction. A **public** site enrols by itself — launch day and a domain move need
* nobody. A **non-public** site (`IAPL_NOINDEX=1`, or a host in `developmentHosts`) that finds another
* host's connection it was never told about is a copy of that site's data: it does not enrol and does not
* send by itself (it would mail real people), until an admin presses "Connect again".
*
* `'wait'`: every site waits for "Connect again" when it has no connection of its own (the rule of the
* first cut). `'enrol'`: no rule at all. A list: these hosts are this site's own (never "another host").
* `www.` and the bare domain are always one site; a site with an empty store always enrols by itself.
*/
otherHosts?: 'enrol' | 'wait' | string[]
otherHosts?: 'auto' | 'enrol' | 'wait' | string[]
/**
* The wait before the next attempt when the service names none, in ms, multiplied by the attempt's
* number. Default 1000. The ten seconds of waiting in all are not changed by it. Mostly for tests.