ADR-185 — An account's email changes only on proof of the new mailbox, and an address it left stays its own
- Status: Accepted
- Date: 2026-12-03
- Deciders: jo (the direction and the three arbitrations below), Claude (the design)
- Amends: ADR-159 — the erasure reaches every address the account held, not only its current one
- Relates to: ADR-037 (SSO auto-link gated on a DNS-verified domain) · ADR-157 (the audit's peppered subject)
- Serves: #4053 · epic #1407
Context
Until this change, nobody could change an account's email: not its owner, not a super-admin. The address is more than a label. Several things key on it:
- password sign-in and the password-reset request;
- the SSO auto-link onto an existing account, gated by a DNS-verified org domain (ADR-037);
- invitation acceptance (
Invitation.AddressedTo); - the bootstrap admin's reconcile at boot (
ITERION_BOOTSTRAP_ADMIN_EMAIL).
The erasure (ADR-159) also finds a person's traces by the current address: invitations sent to it, run notes it authored, audit rows naming it (meta.email, and meta.subject_hash for refused sign-ins).
Two risks follow:
- A new address accepted without proof is a takeover tool. Set it to an address in an org's verified domain, and that org's IdP can sign into the account. Set it to an invited address, and you accept the invitation.
- An address freed after a change can name two people. Suppose the address left behind is registered by someone else. Erasing the first account then re-attributes the second person's run notes to the first person's pseudonym, and scrubs the second person's audit rows. Keeping the old addresses for the erasure does not help on its own.
Decision
The new address is proven by a link sent to it.
- The owner asks from the studio (
/account→ Profile) withPOST /api/me/email. A signed-in session only: the CLI stores a personal access token, which the route refuses. - The request is proven by the current password (
provePassword: the sign-in's lockout and counter) and goes through the derivation chokepoint. A personal access token is refused. - A single-use
iae_link, valid 60 minutes, goes to the new address. Only its hash is stored, inemail_changes, one row per account; a new request replaces the old one. - Redeeming it (
POST /api/auth/email/confirm, public) moves the account in onePatchUser, guarded by the address and status the request saw (UserPatch.IfEmail,IfNotStatus). - The confirmation page sends nothing on load; it asks for a click.
- The password-reset links sent to the old address end before the commit, and a reset link redeems only while the account still has the address it was sent to. The old address is notified. Sessions are kept.
- Every account revocation (a password change or reset, a sign-out everywhere, a disable, a refresh-token reuse, an erasure) ends the pending change: whoever knew the password cannot finish a move after the owner's compromise response. The change carries the account's session generation read before the proof; the request takes it back and the confirmation refuses it once a revocation has raised the generation, so a revocation racing the request's write is covered too.
- The owner asks from the studio (
An account without a password sets one first (jo, 2026-12-03). It uses "Forgot password", which is itself a proof of the current mailbox. There is no second proof mechanism.
A super-admin moves an address directly (jo, 2026-12-03), with
PATCH /api/admin/users/{id}email:- no link — the administrator vouches;
- one write with the rest of the edit;
- both addresses are notified;
- a
user.email_changedaudit line names both; - the pending change and reset links end.
This is no new power: a super-admin can already set a temporary password. On the caller's own account, a personal access token is refused (the address is the recovery channel; a reset would mint a password the token may not mint).
An address belongs to one account until that account is erased.
users.email_historylists every address the account has held, the current one included, under the unique multikey indexemail_history_unique.- No other account registers or moves onto an address in someone's history. The owner may move back to it.
- The erasure reaches every address in the history (
auth.ErasureAddresses): invitations, run notes, audit rows with their digests, andmeta.previous_email, which joinsaudit.ScrubbedMetaKeys. - The erasure reads the addresses from the row as it stands once marked erased (no change lands after the mark), leaves out a past address another account currently holds (a state only a writer predating the history can leave), then
$unsets the history: the addresses are free again. - Invitations to any address an account under erasure holds are refused.
- This amends ADR-159, whose erasure keyed on the current address only.
The operator-declared bootstrap address does not move, and no account moves onto it (
email_declared_by_operator). Moving it away would silently end the declarative reconcile, which is keyed on it; moving onto it would hand that reconcile — a super-admin — to the account that moved.No mail, no self-service change. A deployment without a real mailer refuses the request (
email_delivery_unavailable): the proof cannot exist. The super-admin path stays open.The personal space follows the address (jo, 2026-12-03). A registration names the account's personal organization and team after its address: the slug is the slugified address (or a
-Nvariant a collision chose), the name is the address itself when the account has no name. Once a change is committed, by the link or by a super-admin,auth.Service.FollowAddressInPersonalSpacerewrites whichever of the two is still derived from an address the account held — the one it left or an older one in its history, so a rename that failed at one change is made at the next — into what the new address derives, so no left address stays on what the account and the administrators read — it matters most to someone who changes address because their name changed. A slug or a name that is not the derived one was chosen and stays; a personal space another account created is not touched. It runs after the commit: a write that fails there does not undo the change, and theuser.email_changedaudit line names what moved (personal_space_renamed) and what did not (personal_space_error).
Options considered
- Change the address without verification. Simplest. It opens the ADR-037 takeover and invitation capture. Rejected.
- Rewrite the old address's copies at change time (notes, audit rows) instead of keeping a history. It rewrites the audit — a record of what happened — and still lets the freed address name a second person. Rejected.
- Keep past addresses without reserving them. The erasure would reach them, but also the next owner's traces. Rejected for the index.
- A recent-SSO-sign-in proof, or a second link to the old address, for SSO-only accounts. Both add a proof mechanism. The reset already proves the mailbox. Rejected by arbitration (decision 2).
- Revoke every session on change. Not a compromise response: the refresh re-reads the row, and an access token carries the old address for at most its 15-minute lifetime. Rejected.
Consequences
- An address someone used once cannot be reused by another account while the first one exists. A company that recycles addresses has the admin erase the departed account: only an erasure frees an address (moving the account keeps the address in its history).
- Rows written before
email_historyexisted carry none. Their current address is held byemail_unique; their first change writes both addresses. No migration. - Pending invitations sent to the old address stop matching the account. The inviter re-invites.
- A run note written in the ≤15 minutes after a change carries the old address (the access token's claim). The history keeps it within the erasure's reach.
- A script that names the personal team by its old slug (the
X-Iterion-Teamheader,--team <slug>) must use the new one. Ids do not move: personal access tokens and the CLI's stored team keep working.
Witnesses
pkg/identity/email_patch_conformance_test.go(memory + Mongo).pkg/identity/user_patch_mongo_test.go(the$set/$addToSettwin and theIfEmailfilter).pkg/auth/email_change_test.go.pkg/auth/personal_space_address_test.go: the personal space moves with the address where it is derived from it, and only there.pkg/server/email_change_routes_test.go: the routes, the admin edit, and the erasure by every address held.
