iterate.com / kernel

git clone https://git.iterate.com/repos/kernel

Merge iterate/private's core at 3de3de7d

46 commits of iterate/private after 216369eb, 28 of them in core/: mail to a
mind as an event, owner email patterns, itx.fetch with an upstream WebSocket,
the catch-up of a failed push to a facet, the mind sign-in on the chooser,
the deploy that signs this computer in and offers its MCP server, and more.

Taken as upstream has it: everything outside the template.

Left out, because this kernel carries no code of a mind:
- core/configs/default, core/configs/minimal and core/repos/onboarding, and
  the tests of the template (config-default-*.test.ts). Their changes belong
  in the repos that hold that code now.
- Upstream's changes to the template follower in the mind's processor, which
  this kernel does not have.
- The seeding of /repos/onboarding by the deploy (seedReposEnvOf): a mind's
  repos come from its list.

Four files conflicted: deploy.ts (both sides kept), the mind's contract (one
comment), its processor and the processor's tests (the template follower).

All nine packages type-check, and their tests pass: 1074 in lib, 526 in itx,
536 in auth-worker, 418 in secrets-worker, 263 in mind-worker, 240 in
boundary-worker.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

Misha Kaletsky, 2026-11-25 15:17 UTC · 0c85e04ac65cd8259cf605f315dd0931dbcb9c3b · a merge of 01edef9 and 0575be7, shown against 01edef9

108 files changed

M core/alchemy/README.md
@@ -81,48 +81,55 @@
 
 A mind takes each of its zones whole: nothing else may use them.
 
+`"ownerEmailPatterns": ["*@company.example"]` names more owners by pattern: every address at
+exactly that domain (no sub-domain) is an owner, with all that an owner may do. Such a person
+proves the address through Cloudflare Access, whose policy then names the whole domain, and adds a
+passkey. So whoever holds a mailbox at the domain, or runs its mail, can become an owner: name a
+domain only when its mail is the company's own, and never a zone of the mind. Each person who
+proves an address takes a seat of the account's Zero Trust team. A person who left keeps the
+passkey that they added, whatever their mail provider does: an owner blocks that address on
+`/members`, which ends that one person (no member, no session, no way back in) while the block is
+there. `iterate deploy --owner-email-patterns none` takes the pattern away for everyone. A mail or a Slack message from a verified address
+at the domain counts as a member's. Absent: the owners are `ownerEmails` alone.
+
 Every Worker of the stack keeps every log line and, by default, every trace in Cloudflare's own
 Workers Logs. `"telemetry": { "traceSampling": 0.1 }` keeps the trace of one request in ten (from 0
 to 1; Cloudflare's head sampling rate). `iterate deploy --trace-sampling 0.1` writes it, and
 `--trace-sampling default` goes back to every trace. On iterate.com on 21 Nov 2026, spans were
 about 86 % of what the store took in.
 
-Each mail to an address at a zone reaches the mind: the boundary stores its files under the mind's
-`/email/`, and a failure there fails the delivery, so Cloudflare delivers again. Then the mind's
-config gets it while the delivery is live, in its `email` method (iterate/sdk
-`IterateConfigEntrypoint`). There `save()` records it on `/integrations/email` (`email/received`);
-a save that the mind does not take fails the delivery too. A mail is off the log only when the
-config's `email` returns without saving it; when the hook throws, runs out of time or is missing,
-or the mind cannot be reached for it, the boundary records the mail itself, with an
-`email/hook-failed` fact beside it. `forward(to)` sends the original on, as it arrived, with Email Routing's
-own forward: its From is the sender's, so a reply goes to the sender.
+Each mail to an address at a zone reaches the mind: the boundary has the mind store its files
+under `/email/` and append `events.iterate.com/email/received` on `/integrations/email`. A failure
+there fails the delivery, so Cloudflare delivers again. No code of the mind's config runs in the
+delivery: the config gets the mail as that event, in `processEvent`. To send the original on, as
+it arrived, the config appends `events.iterate.com/email/forward-requested` (`{ raw, to }`) there.
+The boundary's handler stays open for such requests for 10 s after the receipt, and forwards
+with Email Routing's own forward: its From is the sender's, so a reply goes to the sender.
 
 - The address must be a verified destination address of the account's Email Routing: add it in
   the dashboard (Email Routing, Destination addresses) and confirm the link Cloudflare mails to it.
-- Cloudflare forwards only a mail whose sender is proven. `forward` throws a coded error instead of
-  forwarding: NOT_FORWARDABLE, FORWARDED_BEFORE (a mail goes to one address once, and never to an
-  address that its `X-Forwarded-To` names, so an address that leads back makes no loop), REFUSED
-  (Cloudflare's words) or EXPIRED (after the delivery, or after the hook's time).
-- Each forward is an `events.iterate.com/email/forwarded` fact. The boundary gives the hook 15 s
-  of its own time: the clock stops while Cloudflare answers a forward, which took 3 to 10 s on
-  19 Nov 2026. A forward whose answer does not come within 20 s more is the same fact with
-  `answered: false`. A hook that throws, that runs past its own time, or that the mind could not
-  be reached for, and a config with no `email` (one fact for each config commit), are
-  `events.iterate.com/email/hook-failed` facts, and the boundary records the mail: the delivery
-  stands, unless the mind does not take that record.
+- Cloudflare forwards only a mail whose sender is proven. A forward that does not happen is an
+  `events.iterate.com/email/forward-failed` fact with why: Cloudflare's words, or the boundary's
+  own, which start "not forwarded:" (a mail never goes to an address that its `X-Forwarded-To`
+  names, so an address that leads back makes no loop; a request that no code at the root wrote).
+- Each forward is an `events.iterate.com/email/forwarded` fact, one for each mail and address.
+  Cloudflare answered a forward after 3 to 10 s on 19 Nov 2026. A forward whose answer does not
+  come within 20 s after the requests' time is the same fact with `answered: false`.
+- When the 10 s are up, the mind appends `events.iterate.com/email/forward-requests-closed` for
+  the mail. A request on the log before that fact is served; one after it gets no answer: the
+  message is gone. Nothing
+  that the config does or fails to do fails a delivery.
 
 **The older way, which goes:** with `"mail": { "forwardTo": "team@example.org" }` the boundary
-forwards each mail there itself, before the config's hook and through the same forward, so the
-hook cannot forward the same mail there again. Such a stack records every mail on the log before
-its forward, whatever its config's hook does: a record after the forward could fail the delivery
-after the copy went, and the redelivery would forward a second copy; and a refused forward fails
-the delivery before the hook runs, which must not cost the mail its place on the log. The config refuses an address at a zone of the
+forwards each mail there itself, before the mind's requests and through the same forward, so a
+request for that address forwards nothing more. A refused forward fails the delivery after the
+mail is on the log. The config refuses an address at a zone of the
 mind: its mail would come back. Each forward that fails is an
 `events.iterate.com/email/forward-failed` fact, with Cloudflare's words; a mail whose sender is not
 proven stays in the mind alone, and the delivery stands. **The cost of a forward address that does
 not work:** while the address is not verified, is removed from the account, or refuses mail, every
 mail to the mind fails for its sender: the mind keeps the mail, the delivery fails, the sender gets
-it back, and the config's hook does not run. A mind's config forwards in its own `email` instead.
+it back. A mind's config asks for its forwards by event instead.
 
 `mindId` is the SHA-256 of the mind's signed genesis record (`iterate/mind-identity`). The stack
 signs and checks nothing with it: every Worker gets it as config, and the auth Worker accepts the
@@ -161,10 +168,11 @@
   - **`given`:** the state holds `TelemetryToken`, an owner-created token: the stack keeps using
     it. **Do not delete or roll it:** the sinks keep the token they were made with.
   - **`off`:** neither. The stack makes the telemetry bucket, the three streams and the OTLP
-    destinations, and no catalog, sink, pipeline or token. The mind makes and reads its tables
-    itself, with a token kept as its secret `/secrets/cloudflare-telemetry`
-    (core/configs/default/telemetry.ts); the streams keep what they are sent until then. A
-    destroy removes what the mind made (`src/mind-made-telemetry-tables.ts`).
+    destinations, and no catalog, sink, pipeline or token. The stack has no `events`, `logs` or
+    `spans` table: its mind reads Cloudflare's own datasets and `metrics` through
+    `itx.telemetry.query`, with no token. Until 25 Nov 2026 a mind could turn its tables on with
+    a member's token: a destroy removes what such a mind made
+    (`src/mind-made-telemetry-tables.ts`).
 - The deploy makes a Realtime SFU app and a TURN key (`src/realtime.ts`), which need the
   permission to make Realtime (Calls) resources: "Calls Write" (`calls.write`), which the deploy
   asks for, or "Realtime" or "Realtime Admin". A credential without it is no failure either: the deploy makes neither,
M core/alchemy/src/config.test.ts
@@ -125,6 +125,29 @@
   ]);
 });
 
+void test("owner email patterns are optional, each *@<domain>, and at no zone of the mind", () => {
+  assert.equal(MindConfig.parse(config()).ownerEmailPatterns, undefined);
+  assert.deepEqual(
+    MindConfig.parse({ ...config(), ownerEmailPatterns: ["*@company.example"] }).ownerEmailPatterns,
+    ["*@company.example"],
+  );
+  for (const pattern of [
+    "*@*",
+    "company.example",
+    "ada@company.example",
+    "*@Company.example",
+    // the mind's own zones, and a name under one
+    "*@example.com",
+    "*@mail.sub.example.net",
+  ])
+    assert.deepEqual(
+      MindConfig.safeParse({ ...config(), ownerEmailPatterns: [pattern] }).error?.issues[0]
+        ?.path[0],
+      "ownerEmailPatterns",
+      pattern,
+    );
+});
+
 function config() {
   return {
     mindId: "a".repeat(64),
M core/alchemy/src/config.ts
@@ -2,6 +2,7 @@
 // the person and from Cloudflare. A JSON file, named in ITERATE_MIND_CONFIG. No field is optional
 // for a reason of history, and no variable of the environment changes what it means.
 import { readFileSync } from "node:fs";
+import { domainOfOwnerEmailPattern, OwnerEmailPattern } from "iterate/mind-config";
 import { z } from "zod";
 
 const hostname = z
@@ -24,6 +25,14 @@
      *  with a code mailed to that address and then adds a passkey. An owner may remove another
      *  member's passkeys. Members added later are in the mind, not here. */
     ownerEmails: z.array(z.email().toLowerCase()).min(1),
+    /** MORE OWNERS, BY PATTERN: each `*@<domain>` makes every address at exactly that domain an
+     *  owner, with all that an owner may do (iterate/mind-config `isOwnerEmail`). Such a person
+     *  proves the address through Cloudflare Access, as any owner does, and then adds a passkey:
+     *  so whoever holds a mailbox at the domain, or runs its mail, can become an owner. Name a
+     *  domain only when its mail is the company's own. A person who left keeps the passkey they
+     *  added: an owner's block of that address on `/members` ends that one person
+     *  (core/auth-worker/src/members.ts `isMember`). Absent: no pattern. */
+    ownerEmailPatterns: z.array(OwnerEmailPattern).optional(),
     /** Where the mind Worker runs: in the stack, or elsewhere, connecting in through the
      *  boundary. */
     topology: z.enum(["full-cloudflare", "external-mind-connects-into-cloudflare-boundary"]),
@@ -66,10 +75,10 @@
        *  Absent: no binding, and the platform's fetch sends. */
       egressGatewayWorker: z.string().min(1).optional(),
     }),
-    /** A FORWARD BY THE STACK, beside the config's own `email` method (iterate/sdk), where a
-     *  mind's config forwards. Absent: the config's `email` alone decides where a mail goes. `forwardTo`:
-     *  each mail is also forwarded there as it arrived (a team's mailbox or group), before the
-     *  config's `email` runs. The address must be a verified destination address of the
+    /** A FORWARD BY THE STACK, beside the forwards that the mind's config asks for by event
+     *  (iterate/email `email/forward-requested`). Absent: the config's requests alone decide
+     *  where a mail goes. `forwardTo`: each mail is also forwarded there as it arrived (a team's
+     *  mailbox or group), before the config's requests. The address must be a verified destination address of the
      *  account's Email Routing, which a person confirms once by the link Cloudflare mails to it. */
     mail: z.strictObject({ forwardTo: z.email() }).optional(),
     /** THE MIND'S TELEMETRY in Cloudflare's own store. `traceSampling` is the share of requests
@@ -105,6 +114,18 @@
     {
       path: ["ownerEmails"],
       error: "no address at a zone of the mind: the mind takes that mail",
+    },
+  )
+  .refine(
+    ({ ownerEmailPatterns, cloudflare }) =>
+      (ownerEmailPatterns || []).every((pattern) =>
+        cloudflare.zones.every(
+          (zone) => !`.${domainOfOwnerEmailPattern(pattern)}`.endsWith(`.${zone}`),
+        ),
+      ),
+    {
+      path: ["ownerEmailPatterns"],
+      error: "no pattern at a zone of the mind: the mind takes that mail",
     },
   )
   .refine(
M core/alchemy/src/mind-made-telemetry-tables.ts
@@ -1,9 +1,10 @@
 // mind-made-telemetry-tables.ts — THE TELEMETRY TABLES THAT A MIND MADE ITSELF, AS A RESOURCE. A
-// stack with no telemetry token makes the bucket and the streams, and the mind's own code makes
-// the catalog, the sinks and the pipelines (core/configs/default/telemetry.ts). This resource makes
-// nothing. Its delete removes what the mind made, with the deploy's own credential: the pipelines,
-// then the sinks, then the catalog with its tables. It reads the bucket's and the streams' names
-// from their resources, so a destroy runs it before they go.
+// stack with no telemetry token makes the bucket and the streams. The mind's own code, with a
+// token of the account that a member gave it, may have made the catalog, the sinks and the
+// pipelines on them; the default config has no code that makes them. This resource makes
+// nothing. Its delete removes what the mind made, with the deploy's own credential: the
+// pipelines, then the sinks, then the catalog with its tables. It reads the bucket's and the
+// streams' names from their resources, so a destroy runs it before they go.
 import type * as Cloudflare from "@alchemy.run/cloudflare";
 import * as pipelines from "@distilled.cloud/cloudflare/pipelines";
 import * as catalog from "@distilled.cloud/cloudflare/r2-data-catalog";
M core/alchemy/src/stack-bindings.test.ts
@@ -107,6 +107,8 @@
   observability: Record<string, any>;
   /** each Access application's name, by its logical id */
   accessNames: Record<string, string>;
+  /** whom each Access application's policies include, by its logical id */
+  accessIncludes: Record<string, unknown[]>;
 };
 
 /** Each Worker's bindings and declared resources, as the program declares them for one config. */
@@ -163,7 +165,15 @@
         .filter((r) => r.Type === "Cloudflare.Access.Application")
         .map((r) => [r.LogicalId, r.Props.name]),
     );
-    return { workers, resources, texts, observability, accessNames };
+    const accessIncludes = Object.fromEntries(
+      Object.values(stack.resources)
+        .filter((r) => r.Type === "Cloudflare.Access.Application")
+        .map((r) => [
+          r.LogicalId,
+          (r.Props.policies as { include: unknown[] }[]).flatMap((policy) => policy.include),
+        ]),
+    );
+    return { workers, resources, texts, observability, accessNames, accessIncludes };
   });
 
 void test("each Worker of the stack holds what stack-bindings.snapshot.json says", async () => {
@@ -205,6 +215,34 @@
   assert.deepEqual(accessNames, { OwnerEmailProof: "iterate.example.com" });
 });
 
+// Cloudflare mails a code to an owner alone. An owner email pattern adds its whole domain to
+// that policy, and each Worker's config; a stack with no pattern, or an empty list, has neither.
+void test("an owner email pattern adds its domain to the Access policy and to each Worker's config, and a stack with none is as it was", async () => {
+  const config = CASES["full-cloudflare, no mail forward"];
+  const owner = { email: "owner@owner.example" };
+  for (const ownerEmailPatterns of [undefined, []]) {
+    const { accessIncludes, texts } = await declared({ ...config, ownerEmailPatterns });
+    assert.deepEqual(accessIncludes, { OwnerEmailProof: [owner] });
+    assert.doesNotMatch(texts.Boundary!.ITERATE!, /ownerEmailPatterns/);
+  }
+  const { accessIncludes, texts } = await declared({
+    ...config,
+    ownerEmailPatterns: ["*@company.example", "*@second.example"],
+  });
+  assert.deepEqual(accessIncludes, {
+    OwnerEmailProof: [
+      owner,
+      { emailDomain: { domain: "company.example" } },
+      { emailDomain: { domain: "second.example" } },
+    ],
+  });
+  for (const worker of ["Secrets", "Boundary"])
+    assert.deepEqual(JSON.parse(texts[worker]!.ITERATE!).ownerEmailPatterns, [
+      "*@company.example",
+      "*@second.example",
+    ]);
+});
+
 // A STACK THAT NAMES NO GATEWAY IS AS IT WAS BEFORE THE GATEWAY'S FIELD EXISTED. Its config
 // variables are written out here character by character: a marker or a new key there would
 // change every mind. Its bindings are read from the declaration and never from the snapshot
@@ -345,7 +383,7 @@
   assert.equal(minted.resources.TelemetryTablesOfTheMind, undefined);
 
   // Off mode binds the three streams and declares the bucket, the streams and the destinations,
-  // and no token, catalog, sink or pipeline: the mind can make those itself
+  // and no token, catalog, sink or pipeline
   assert.deepEqual(off.workers.Telemetry, [
     "ANALYTICS:analytics",
     "EVENTS:Cloudflare.Pipelines.Stream Telemetry_events_stream",
M core/alchemy/src/stack.ts
@@ -18,8 +18,8 @@
 //
 // The stack generates four keys (three with an external mind) and keeps one owner-created
 // telemetry API token in state, when it is given one. With a token it makes the telemetry
-// tables; with none it makes their bucket and streams, and the mind can make the tables itself
-// with a secret of its own (core/configs/default/telemetry.ts). It makes no OAuth client: a
+// tables; with none it makes their bucket and streams and no tables, and the mind reads
+// Cloudflare's own datasets and `metrics` through `itx.telemetry.query`. It makes no OAuth client: a
 // member connects the mind to the account through Cloudflare's MCP server, for which the mind is
 // its own client (core/configs/default/cloudflare.ts).
 // An owner signs in first with a code mailed to their address, by the mind or by Cloudflare
@@ -34,6 +34,7 @@
 import * as Effect from "effect/Effect";
 import * as Redacted from "effect/Redacted";
 import { COMPATIBILITY_DATE } from "iterate/compatibility-date";
+import { domainOfOwnerEmailPattern } from "iterate/mind-config";
 import { z } from "zod";
 import { AccessTeam } from "./access-team.ts";
 import { ArtifactsNamespace } from "./artifacts-namespace.ts";
@@ -68,6 +69,8 @@
   controlPlaneHostname: config.controlPlaneHostname,
   zones: config.cloudflare.zones,
   ownerEmails: config.ownerEmails,
+  // absent with no pattern: JSON leaves it out, so such a mind's variable is as it was
+  ownerEmailPatterns: config.ownerEmailPatterns?.length ? config.ownerEmailPatterns : undefined,
   topology: config.topology,
 });
 /** A stream's fields, as a file of core/telemetry-worker/schemas lists them. */
@@ -101,8 +104,8 @@
     //   - "given": one owner-created TelemetryToken kept in state.
     //   A deploy takes no new token, so a stack's mode never changes from "off".
     //   - "off": no token. The bucket, the streams and the OTLP destinations are made, and no
-    //     catalog, sink or pipeline: the mind can make those itself, with a secret of its own
-    //     (core/configs/default/telemetry.ts). A stream with no pipeline keeps what it is sent,
+    //     catalog, sink or pipeline. A destroy removes the ones that the mind's own code made
+    //     (./mind-made-telemetry-tables.ts). A stream with no pipeline keeps what it is sent,
     //     and a pipeline made later writes it into the table (measured on 20 Nov 2026).
     const telemetryBucket = yield* Cloudflare.R2.Bucket("TelemetryBucket", {
       name: names.telemetryBucket,
@@ -301,8 +304,9 @@
     // ── Cloudflare Access proves an owner's address: one application, at one path ──
     // An owner with no passkey yet opens that path. Cloudflare mails a code to the address, from
     // its own domain, and then signs a token that names the address. The auth Worker checks the
-    // token itself (core/auth-worker/src/access-sign-in.ts). The policy names the owners alone:
-    // nobody else gets a code, so no other person ever takes a seat of the account's team.
+    // token itself (core/auth-worker/src/access-sign-in.ts). The policy names the owners alone,
+    // each by address, and every address at the domain of an owner email pattern: nobody else
+    // gets a code, so no other person ever takes a seat of the account's team.
     // Its name is the control plane's hostname: Cloudflare's code page says "Log in to <name>"
     // to the owner. A new name changes the application in place, and its `aud` stays.
     const accessTeam = yield* AccessTeam("AccessTeam");
@@ -322,7 +326,12 @@
         {
           name: "owners",
           decision: "allow",
-          include: config.ownerEmails.map((email) => ({ email })),
+          include: [
+            ...config.ownerEmails.map((email) => ({ email })),
+            ...(config.ownerEmailPatterns || []).map((pattern) => ({
+              emailDomain: { domain: domainOfOwnerEmailPattern(pattern) },
+            })),
+          ],
           require: [{ loginMethod: accessTeam.pinLoginId }],
         },
       ],
M core/alchemy/src/telemetry-token.ts
@@ -1,7 +1,8 @@
 // telemetry-token.ts — THE TELEMETRY TOKEN THAT A STACK ALREADY KEEPS IN STATE. A stack whose
 // tables an earlier deploy made with a token keeps that token: its Pipelines catalog sinks keep
-// the token they were made with. A deploy takes no new token: a mind turns its tables on itself
-// (core/configs/default/telemetry.ts). The mode is read from the stack's state alone.
+// the token they were made with. A deploy takes no new token, so a stack with none has no
+// telemetry tables: its mind reads Cloudflare's own datasets and `metrics` through
+// `itx.telemetry.query`. The mode is read from the stack's state alone.
 //
 // `AccountApiTokenDeleteFallbackProvider` wraps Alchemy's `AccountApiTokenProvider` so deleting
 // an `AccountApiToken` resource succeeds even with a deploy sign-in that lacks API-token write
@@ -45,7 +46,8 @@
  *    analytics token, which nothing reads since 22 Nov 2026, is not declared: a deploy deletes it.
  *  - `"given"`: state holds `TelemetryToken` — use that one owner-created token.
  *  - `"off"`: neither — the bucket and the streams are made, and no token, catalog, sink or
- *    pipeline: the mind can make those itself (./mind-made-telemetry-tables.ts). */
+ *    pipeline. A destroy removes the ones that the mind's own code made
+ *    (./mind-made-telemetry-tables.ts). */
 export type TelemetryMode = "minted" | "given" | "off";
 
 const isLiveResource = (persisted: PersistedState | undefined): persisted is ResourceState =>
@@ -92,7 +94,7 @@
       output
         ? Effect.succeed({ value: output.value })
         : Effect.die(
-            "This stack holds no telemetry token in its state, and a deploy takes no new one: a mind turns its telemetry tables on itself (onboarding/telemetry.md of /repos/onboarding).",
+            "This stack holds no telemetry token in its state, and a deploy takes no new one: the stack has no telemetry tables, and its mind reads Cloudflare's own datasets and metrics through itx.telemetry.query (onboarding/telemetry.md of /repos/onboarding).",
           ),
     // The token was created by the person in Cloudflare's dashboard, not by the deploy.
     delete: () => Effect.void,
M core/auth-worker/src/asking-app.test.ts
@@ -2,7 +2,15 @@
 // and what the sign-in pages then show.
 import type { SignInMethod } from "iterate/principal";
 import { expect, test, vi } from "vitest";
-import { appOf, appTile, askingAppOf, saidIn, signInOf } from "./asking-app.ts";
+import {
+  appOf,
+  appTakes,
+  appTile,
+  askingAppOf,
+  saidIn,
+  signInOf,
+  takesAddress,
+} from "./asking-app.ts";
 import { emailSignInResponse } from "./email-sign-in.ts";
 import type { Env } from "./env.ts";
 import { hostCallbackOf, hostClientOf, oauthHelpers } from "./oauth.ts";
@@ -41,6 +49,7 @@
     icon: `${ORIGIN}/icon.svg`,
     members: false,
     signIn: FOR_ANYONE,
+    emailDomains: null,
   });
   // a path on the host is the host, as the authorization endpoint reads it
   expect(await askingAppOf(stack.env, next({ resource: `${ORIGIN}/mcp` }))).toMatchObject({
@@ -65,7 +74,13 @@
     expect(await askingAppOf(stack.env, forged)).toBeNull();
 });
 
-const NOTHING = { name: null, icon: null, members: false, signIn: FOR_ANYONE };
+const NOTHING = {
+  name: null,
+  icon: null,
+  members: false,
+  signIn: FOR_ANYONE,
+  emailDomains: null,
+};
 
 test.for([
   {
@@ -115,37 +130,60 @@
     said: { name: "Guestbook", signIn: ["email"] },
   },
   {
+    name: "the domains whose addresses a mailed code signs in, each once",
+    description: { name: "Shop", emailDomains: ["example.com", "second.example", "example.com"] },
+    said: { name: "Shop", emailDomains: ["example.com", "second.example"] },
+  },
+  {
     name: "what a browser's manifest would say is passed over",
     description: { name: "Guestbook", short_name: "Book", icons: [{ src: "/other.svg" }] },
     said: { name: "Guestbook" },
   },
-  // a text that is no description says nothing at all: the app is its host, for anyone
+  // a JSON object that is no description is wrong, and is not the app's word (null): the issuer
+  // keeps what the app last said
   {
     name: "a method that this issuer does not know",
     description: { name: "G", signIn: ["email", "google"] },
-    said: {},
+    said: null,
   },
-  { name: "an empty list of methods", description: { name: "G", signIn: [] }, said: {} },
-  { name: "methods that are no list", description: { name: "G", signIn: "email" }, said: {} },
+  { name: "an empty list of domains", description: { name: "G", emailDomains: [] }, said: null },
+  ...["@example.com", "*.example.com", "Example.com", "example", "a@example.com"].map((domain) => ({
+    name: `a domain that is none: ${domain}`,
+    description: { name: "G", emailDomains: [domain] },
+    said: null,
+  })),
+  { name: "an empty list of methods", description: { name: "G", signIn: [] }, said: null },
+  { name: "methods that are no list", description: { name: "G", signIn: "email" }, said: null },
   {
     name: "any other word than 'members'",
     description: { name: "Dash", for: "everyone" },
-    said: {},
+    said: null,
   },
   {
     name: "an icon that is no path",
     description: { name: "G", icon: "https://elsewhere.test/logo.png" },
-    said: {},
+    said: null,
   },
-  { name: "no name", description: { icon: "/icon.svg", signIn: ["passkey"] }, said: {} },
-  { name: "a name that is no text", description: { name: 7 }, said: {} },
+  { name: "no name", description: { icon: "/icon.svg", signIn: ["passkey"] }, said: null },
+  { name: "a name that is no text", description: { name: 7 }, said: null },
+  // a text that is no JSON object says nothing at all: the app is its host, for anyone
   { name: "not an object", description: ["Guestbook"], said: {} },
 ])("what an app's description says: $name", ({ description, said }) => {
-  expect(saidIn(JSON.stringify(description), DESCRIPTION)).toEqual({ ...NOTHING, ...said });
+  expect(saidIn(JSON.stringify(description), DESCRIPTION)).toEqual(said && { ...NOTHING, ...said });
 });
 
-test("a description that is no JSON, is empty or is too long says nothing", () => {
-  for (const text of ["", "<!doctype html>", `{"name":"${"x".repeat(20_000)}"}`])
+test("a JSON object that broke off, or that is too long to read, is no word of the app", () => {
+  const long = JSON.stringify({
+    name: "Shop",
+    emailDomains: Array.from({ length: 2000 }, (_, n) => `shop-${n}.example.com`),
+  });
+  expect(long.length).toBeGreaterThan(20_000);
+  for (const text of ['{"name":"Shop","emailDomains":["exam', " {", "{<", long])
+    expect(saidIn(text, DESCRIPTION), text.slice(0, 40)).toBeNull();
+});
+
+test("a text that is no JSON object, of any length, or that is empty says nothing", () => {
+  for (const text of ["", "<!doctype html>", `<!doctype html>${"x".repeat(20_000)}`])
     expect(saidIn(text, DESCRIPTION)).toEqual(NOTHING);
 });
 
@@ -162,6 +200,7 @@
     icon: `${ORIGIN}/icon.svg`,
     members: false,
     signIn: ["passkey"],
+    emailDomains: null,
   });
   expect(await appOf(stack.env, ORIGIN)).toEqual(app);
   // the one address that is asked: no web app manifest is read
@@ -212,6 +251,7 @@
       icon: `${ORIGIN}/icon.svg`,
       members: true,
       signIn: FOR_MEMBERS,
+      emailDomains: null,
     });
     expect(stack.askedAgainIn(HOST, before)).toBe("1 minute");
     // and the client that the list of sign-ins reads still names the app
@@ -222,6 +262,49 @@
   },
 );
 
+test("an app whose description is wrong is still what it last said, and is asked again after a minute; one that the issuer never heard takes the passkey alone until it says", async () => {
+  const stack = stackWith({});
+  {
+    using _web = answers({ name: "Shop", emailDomains: ["example.com"] });
+    await appOf(stack.env, ORIGIN);
+  }
+  stack.due(HOST);
+  const policyOf = async (origin: string) => {
+    const app = (await appOf(stack.env, origin))!;
+    return { signIn: app.signIn, emailDomains: app.emailDomains };
+  };
+  {
+    // a list that is not whole, in a description that is otherwise right
+    using _web = answers({ name: "Shop", for: "members", emailDomains: ["@example.com"] });
+    const before = Date.now();
+    expect(await policyOf(ORIGIN)).toEqual({ signIn: FOR_ANYONE, emailDomains: ["example.com"] });
+    expect(stack.askedAgainIn(HOST, before)).toBe("1 minute");
+  }
+  // NOTHING IS KEPT OF THESE: the app's first answer is wrong, or it does not answer. The issuer
+  // mails no code and takes no mailed code's session for an app that it has not heard.
+  for (const [n, answer] of [
+    () => Response.json({ name: "Shop", emailDomains: ["@example.com"] }),
+    () => new Response("down", { status: 503 }),
+    () => new Response("too many requests", { status: 429 }),
+    () => new Response('{"name":"Shop","emailDomains":["exam'),
+    () => Promise.reject(new Error("no answer")),
+  ].entries()) {
+    const spy = vi.spyOn(globalThis, "fetch").mockImplementation(async () => answer());
+    using _down = { [Symbol.dispose]: () => spy.mockRestore() };
+    const origin = `https://shop-${n}.${DOMAIN}`;
+    expect(await policyOf(origin), String(n)).toEqual({ signIn: ["passkey"], emailDomains: null });
+    // and once it answers, it is what it says
+    spy.mockImplementation(async () =>
+      Response.json({ name: "Shop", emailDomains: ["a.example"] }),
+    );
+    stack.due(`shop-${n}.${DOMAIN}`);
+    expect(await policyOf(origin), String(n)).toEqual({
+      signIn: FOR_ANYONE,
+      emailDomains: ["a.example"],
+    });
+  }
+});
+
 test("an app that answers with no description any more has said so: it is its host again, for anyone", async () => {
   const stack = stackWith({});
   const client = await hostClientOf(stack.env, HOST);
@@ -238,6 +321,7 @@
     icon: null,
     members: false,
     signIn: FOR_ANYONE,
+    emailDomains: null,
   });
   expect(await oauthHelpers(stack.env, ORIGIN).lookupClient(client)).toMatchObject({
     clientName: HOST,
@@ -255,6 +339,7 @@
     icon: null,
     members: false,
     signIn: FOR_ANYONE,
+    emailDomains: null,
   });
   expect(appTile(app)).toBe(`<div class="tile" data-app-mark="initials">GU</div>`);
   await appOf(stack.env, ORIGIN);
@@ -287,7 +372,12 @@
   });
   // an MCP client that signs a person in to the app: its own client and callback, the app's server
   const mcp = `/oauth2/auth?${new URLSearchParams({ client_id: "an-mcp-client", redirect_uri: "http://127.0.0.1:4100/callback", resource: `${ORIGIN}/mcp` })}`;
-  expect(await signInOf(stack.env, mcp)).toEqual({ app: null, methods: ["passkey"] });
+  expect(await signInOf(stack.env, mcp)).toEqual({
+    app: null,
+    methods: ["passkey"],
+    // a row that was kept before the issuer read `emailDomains` names none
+    mailedCode: expect.objectContaining({ name: "Guestbook", emailDomains: null }),
+  });
   // the control plane's own sign-in, and one for the mind's API or its MCP server
   for (const next of [
     "/",
@@ -295,9 +385,51 @@
     `/oauth2/auth?resource=https://${MIND}/mcp`,
     "https://elsewhere.test/",
   ])
-    expect(await signInOf(stack.env, next), next).toEqual({ app: null, methods: FOR_MEMBERS });
+    expect(await signInOf(stack.env, next), next).toEqual({
+      app: null,
+      methods: FOR_MEMBERS,
+      mailedCode: null,
+    });
 });
 
+test("an app that names domains takes a mailed code's session for an address at one of them alone; a passkey's session counts whatever its address", () => {
+  const shop = {
+    signIn: FOR_ANYONE as SignInMethod[],
+    emailDomains: ["example.com", "second.example"],
+  };
+  const takes = (method: SignInMethod, email: string) => appTakes(shop, { method, email });
+  expect({
+    atADomain: takes("email", "eve@example.com"),
+    atTheOther: takes("email", "eve@second.example"),
+    inCapitals: takes("email", "Eve@EXAMPLE.com"),
+    // a subdomain is another domain, and so is a name that ends as the domain does
+    atASubdomain: takes("email", "eve@mail.example.com"),
+    atALookalike: takes("email", "eve@notexample.com"),
+    // the address is the text after the last "@"
+    quotedLocalPart: takes("email", '"eve@example.com"@elsewhere.test'),
+    elsewhere: takes("email", "eve@elsewhere.test"),
+    passkeyElsewhere: takes("passkey", "ada@elsewhere.test"),
+  }).toEqual({
+    atADomain: true,
+    atTheOther: true,
+    inCapitals: true,
+    atASubdomain: false,
+    atALookalike: false,
+    quotedLocalPart: false,
+    elsewhere: false,
+    passkeyElsewhere: true,
+  });
+  // the list binds the mailed code alone: a method that the app does not name is still refused,
+  // and an app that names no domains takes any address
+  expect(
+    appTakes(
+      { signIn: ["passkey"], emailDomains: ["example.com"] },
+      { method: "email", email: "eve@example.com" },
+    ),
+  ).toBe(false);
+  expect(takesAddress({ emailDomains: null }, "eve@elsewhere.test")).toBe(true);
+});
+
 test("the mailed code's page for an app's sign-in names the host it signs in to, under the app's own icon", async () => {
   const stack = stackWith({ [HOST]: { name: "Guestbook", icon: `${ORIGIN}/icon.svg` } });
   const client = await hostClientOf(stack.env, HOST);
@@ -339,6 +471,7 @@
     name: "Guestbook",
     icon: `${ORIGIN}/icon.svg`,
     members: false,
+    emailDomains: null,
     signIn: ["email", "passkey"] as SignInMethod[],
   };
   stack.challenge.next = next;
@@ -411,6 +544,7 @@
     name: "Dash",
     icon: null,
     members: true,
+    emailDomains: null,
     signIn: ["passkey"] as SignInMethod[],
   };
   expect(appSignIn(dash)).toMatchObject({
@@ -449,6 +583,7 @@
     name: HOST,
     icon: null,
     members: false,
+    emailDomains: null,
     signIn: ["email", "passkey"] as SignInMethod[],
   };
   const passkey = await signInPage({
@@ -514,6 +649,7 @@
       keyOf(host),
       JSON.stringify({
         members: false,
+        emailDomains: null,
         signIn: FOR_ANYONE,
         ...value,
         askAfter: Date.now() + 5 * 60_000,
M core/auth-worker/src/asking-app.ts
@@ -20,7 +20,9 @@
 // no redirect, and asks again after five minutes. An icon counts only from the app's own origin,
 // so the page's policy allows that one origin. An app that says nothing is shown by its host and
 // its initials. An app that DOES NOT ANSWER (no answer in two seconds, or a 5xx) has said nothing
-// new: it is still what it last said, and it is asked again after a minute.
+// new: it is still what it last said, and it is asked again after a minute. So is an app whose
+// description is a JSON object that is wrong. With nothing kept of such an app, the issuer takes
+// the passkey alone for it until it says (`UNHEARD`): it never opens an app that it has not heard.
 //
 // "For members" changes the page's words and the default of `signIn`, and nothing else: who may
 // come is the guard in the app's own code (the mind's worker.ts), which this Worker does not
@@ -32,6 +34,12 @@
 // methods alone, in the app's order (`signInOf`). It is read from the app, never from the
 // request, so an MCP client that signs a person in to the app gets the same list.
 //
+// WHOSE ADDRESS A MAILED CODE SIGNS IN (`emailDomains`) is enforced with it: for an app that
+// names domains, no code is mailed to an address at any other (./email-sign-in.ts), and a session
+// that a mailed code opened for such an address gets no code for the app's host (`appTakes`). So
+// the list holds at the sign-up, and not only at the app's own guard. It binds the method
+// "email" alone; a list that changes binds the grants made after it.
+//
 // AN APP IS AN OAUTH CLIENT, as Codex is: the host's client holds the app's name and icon (its
 // `clientName` and `logoUri`), written here whenever the description is read and says something
 // else. So the list of a person's sign-ins by client (./oauth.ts `sessionsByClientOf`) names the
@@ -62,6 +70,8 @@
   /** How the app's people sign in, in the app's order: what it names, or the default for whom it
    *  is for (`saidIn`). The sign-in page opens on the first. */
   signIn: SignInMethod[];
+  /** The domains whose addresses a mailed code signs in to the app, or null: any address. */
+  emailDomains: string[] | null;
 };
 
 const text = (value: string) =>
@@ -81,12 +91,22 @@
 export async function signInOf(
   env: Env,
   next: string,
-): Promise<{ app: AskingApp | null; methods: SignInMethod[] } | null> {
+): Promise<{
+  app: AskingApp | null;
+  methods: SignInMethod[];
+  /** For a mind hostname's sign-in: the app's name, and whose address a mailed code signs in to
+   *  it (`takesAddress`). The pages' refusal names the app by it, whichever client asks. */
+  mailedCode: Pick<AskingApp, "name" | "emailDomains"> | null;
+} | null> {
   const authorization = hostAuthorizationIn(env, next);
-  if (!authorization) return { app: null, methods: CONTROL_PLANE_SIGN_IN };
+  if (!authorization) return { app: null, methods: CONTROL_PLANE_SIGN_IN, mailedCode: null };
   const app = await appOf(env, authorization.origin);
   if (!app) return null;
-  return { app: (await isOwnSignIn(env, authorization)) ? app : null, methods: app.signIn };
+  return {
+    app: (await isOwnSignIn(env, authorization)) ? app : null,
+    methods: app.signIn,
+    mailedCode: app,
+  };
 }
 
 /** The app whose own sign-in `next` goes on to (a path of this issuer), or null: for any other
@@ -97,11 +117,23 @@
   return appOf(env, authorization.origin);
 }
 
-/** WHETHER AN APP TAKES A SESSION THAT `method` OPENED, for a code for the app's host: a
- *  passkey's counts at every app, and any other when the app names its method. */
-export const appTakes = (app: Pick<AskingApp, "signIn">, method: SignInMethod) =>
-  method === "passkey" || app.signIn.includes(method);
+/** WHETHER AN APP TAKES A SESSION, for a code for the app's host: a passkey's counts at every
+ *  app, and any other when the app names its method. A mailed code's counts only for an address
+ *  that the app takes (`takesAddress`). */
+export const appTakes = (
+  app: Pick<AskingApp, "signIn" | "emailDomains">,
+  session: { method: SignInMethod; email: string },
+) =>
+  session.method === "passkey" ||
+  (app.signIn.includes(session.method) &&
+    (session.method !== "email" || takesAddress(app, session.email)));
 
+/** WHETHER A MAILED CODE SIGNS `email` IN TO THE APP: the app names no domains, or the address is
+ *  at one of them, whole (the text after its last "@", in lowercase). */
+export const takesAddress = (app: Pick<AskingApp, "emailDomains">, email: string) =>
+  !app.emailDomains ||
+  app.emailDomains.includes(email.slice(email.lastIndexOf("@") + 1).toLowerCase());
+
 /** `next` as an authorization request of this issuer for a mind hostname: the hostname's origin,
  *  and the request's parameters. Null for anything else. */
 function hostAuthorizationIn(env: Env, next: string) {
@@ -146,19 +178,21 @@
       redirect: "manual",
       signal: AbortSignal.timeout(2000),
     })
-      // an answer of the app: its description's text, which is empty for an app that has none
-      // (a 404, a sign-in). Null: the app did not answer, or its answer broke off.
+      // What the app says: its description's text is empty for an app that has none (a 404, a
+      // sign-in). Null: the app did not answer, its answer broke off, or its description is
+      // wrong (`saidIn`). None of those is the app's word.
       .then(async (answer) => {
-        if (answer.status >= 500) return null;
-        return { description: answer.status === 200 ? await answer.text() : "" };
+        // a 5xx, and a 4xx that says "not now" (408, 425, 429), are no answer
+        if (answer.status >= 500 || [408, 425, 429].includes(answer.status)) return null;
+        return saidIn(answer.status === 200 ? await answer.text() : "", document);
       })
       .catch(() => null);
-    const last = kept || NOTHING;
     kept = heard
       ? // "nothing" is kept too: an app with no description is not asked at each page
-        { ...saidIn(heard.description, document), askAfter: Date.now() + 5 * 60_000 }
-      : // it did not answer: it is what it last said, and is asked again after a minute
-        { ...last, askAfter: Date.now() + 60_000 };
+        { ...heard, askAfter: Date.now() + 5 * 60_000 }
+      : // no word of the app: it is what it last said, or `UNHEARD`, and is asked again after a
+        // minute
+        { ...(kept || UNHEARD), askAfter: Date.now() + 60_000 };
     // The row goes a day after it was last written: an app that is asked about is written again
     // within five minutes, and a hostname that nobody asks about any more leaves no row.
     await env.OAUTH_KV.put(key, JSON.stringify(kept), { expirationTtl: 24 * 3600 });
@@ -171,11 +205,13 @@
     icon: kept.icon,
     members: kept.members,
     signIn: kept.signIn,
+    // a row that was kept before the issuer read this field has none
+    emailDomains: kept.emailDomains || null,
   };
 }
 
 /** What an app said of itself (`saidIn`), and when to ask it again. */
-type Kept = ReturnType<typeof saidIn> & { askAfter: number };
+type Kept = typeof NOTHING & { askAfter: number };
 
 /** The host's own client says what the app says: written when it says something else. */
 async function keepOnClient(env: Env, origin: string, said: { name: string; icon: string | null }) {
@@ -195,25 +231,40 @@
   icon: string | null;
   members: boolean;
   signIn: SignInMethod[];
-} = { name: null, icon: null, members: false, signIn: ["email", "passkey"] };
+  emailDomains: string[] | null;
+} = { name: null, icon: null, members: false, signIn: ["email", "passkey"], emailDomains: null };
 
+/** AN APP THAT THE ISSUER HAS NO WORD OF YET: it did not answer, or its description is wrong, and
+ *  nothing that it said before is kept. The issuer does not know whom the app takes, so it takes
+ *  the passkey alone until the app says: a code that is mailed meanwhile, or a grant for an
+ *  address, could be one that the app's own list refuses (`signIn`, `emailDomains`). */
+const UNHEARD: typeof NOTHING = { ...NOTHING, signIn: ["passkey"] };
+
 /** WHAT THE TEXT OF AN APP'S DESCRIPTION SAYS (iterate/app-description `AppDescription`): a name
  *  of at most sixty characters, its icon when that is on the description's own origin, over
  *  https, whether the app is for members, and how its people sign in: the list it names, as it is
  *  written, or the passkey alone for an app for members (a member signs in with nothing else),
- *  and email then passkey for any other. A text that is no `AppDescription` says nothing: one
- *  that names a method this issuer does not know is such a text, so no app is held to a list that
- *  it did not write. */
-export function saidIn(descriptionText: string, descriptionUrl: string): typeof NOTHING {
-  if (!descriptionText || descriptionText.length > 20_000) return NOTHING;
+ *  and email then passkey for any other, and whose address a mailed code signs in. A text that is
+ *  no JSON object says nothing: an app with no description answers with a page, or with none.
+ *  NULL: A JSON OBJECT THAT IS NO `AppDescription`, such as one that names a method this issuer
+ *  does not know, or a domain that is none, and one that broke off or is over 20,000 characters. The app wrote a description and it is wrong, so it is
+ *  held to no list that it did not write, and it is not opened to anyone either: the caller keeps
+ *  what the app last said (`appOf`). */
+export function saidIn(descriptionText: string, descriptionUrl: string): typeof NOTHING | null {
+  // An object that is too long to read, or that broke off, is a description that did not arrive
+  // whole. Any other text (a page, of any length) is none.
+  const unread = descriptionText.trimStart().startsWith("{") ? null : NOTHING;
+  if (!descriptionText) return NOTHING;
+  if (descriptionText.length > 20_000) return unread;
   let json: unknown;
   try {
     json = JSON.parse(descriptionText);
   } catch {
-    return NOTHING;
+    return unread;
   }
+  if (typeof json !== "object" || !json || Array.isArray(json)) return NOTHING;
   const parsed = AppDescription.safeParse(json);
-  if (!parsed.success) return NOTHING;
+  if (!parsed.success) return null;
   const name = parsed.data.name
     // a name is one line of text
     .replace(/[\p{Cc}\p{Cf}]/gu, " ")
@@ -230,6 +281,7 @@
     signIn: [
       ...new Set<SignInMethod>(parsed.data.signIn || (members ? ["passkey"] : NOTHING.signIn)),
     ],
+    emailDomains: parsed.data.emailDomains ? [...new Set(parsed.data.emailDomains)] : null,
   };
 }
 
M core/auth-worker/src/authorize.ts
@@ -10,6 +10,7 @@
 import { appOf, appTakes, askingAppOf } from "./asking-app.ts";
 import {
   clearGuestCookie,
+  clearMindChoiceCookie,
   clearMindCookie,
   clearMindFreshCookie,
   clearSessionCookie,
@@ -17,13 +18,17 @@
   guestCookie,
   guestOf,
   MIND_FRESH_COOKIE,
+  mindChoiceCookie,
+  mindChoiceOf,
   mindFreshOf,
   mindSessionOf,
   type PersonSession,
+  requestHashOf,
   personSessionOf,
 } from "./cookies.ts";
 import { configOf, type Env, issuerOf } from "./env.ts";
 import {
+  AUTHORIZE_ENDPOINT,
   type GrantProps,
   grantedScopes,
   hostCallbackOf,
@@ -32,7 +37,7 @@
   mindHostResourceOf,
 } from "./oauth.ts";
 import { isMemberSession } from "./members.ts";
-import { chooserPage, consentPage, errorPage, notMemberPage } from "./pages.ts";
+import { CHOICE_FIELD, chooserPage, consentPage, errorPage, notMemberPage } from "./pages.ts";
 import { signInHref } from "./sign-in.ts";
 import { admitted, TOO_MANY } from "./device/limits.ts";
 import { GUEST_SESSIONS_PER_TEN_MINUTES, guestRefusal } from "./guest-sign-in.ts";
@@ -44,6 +49,13 @@
   const answer = await authorizeAnswer(env, request);
   // a mind sign-in's fresh mark answers this authorization or none (./cookies.ts `mindFreshCookie`)
   if (!cookieValueOf(request.headers.get("cookie"), MIND_FRESH_COOKIE)) return answer;
+  // a mark that was begun for another request stays for that one (`freshAnswers`)
+  const fresh = await mindFreshOf(env, request);
+  if (
+    fresh?.request &&
+    fresh.request !== (await requestHashOf(promptOf(new URL(request.url)).here))
+  )
+    return answer;
   const headers = new Headers(answer.headers);
   headers.append("set-cookie", clearMindFreshCookie);
   return new Response(answer.body, {
@@ -70,7 +82,13 @@
   }
 }
 
-async function describe(env: Env, request: Request) {
+/** `choice`: whom the chooser's own POST chose for this request (`chosen`), of the two people
+ *  that its page named: the person signed in here (`person`, their user id) or the mind's person
+ *  (`user`). The request is then answered for that one alone, or not at all. Nothing else passes
+ *  it. */
+type Choice = { as: "mind" | "person"; person: string; user: string; app: string };
+
+async function describe(env: Env, request: Request, choice?: Choice) {
   const config = configOf(env);
   const hostResource = mindHostResourceOf(
     config,
@@ -101,34 +119,68 @@
   const { prompt, here } = promptOf(new URL(request.url));
   // a hostname's own sign-in: the code goes to ingress on that host alone, and is not a consent
   const hostSignIn = hostResource && authRequest.redirectUri === hostCallbackOf(hostResource);
-  // Anyone signed in: a mind hostname takes a person who is no member (`grantRefusal`). A guest's
-  // cookie counts only where nobody is signed in, for a host's own sign-in whose app names guests
-  // (`guestAt`).
-  const session: SignedIn | null =
-    (await personSessionOf(env, request)) ||
-    (hostSignIn
-      ? (await guestAt(env, hostResource, request)) ||
-        (await mindPersonAt(env, hostResource, request))
-      : null);
+  // Anyone signed in: a mind hostname takes a person who is no member (`grantRefusal`).
+  const person = await personSessionOf(env, request);
+  // AN APP NAMES HOW ITS PEOPLE SIGN IN, and this endpoint holds every code for the app's host to
+  // it, whichever client asks. A session that the app does not take is no session here: the
+  // person goes to the sign-in for this request, which offers the app's methods alone, unless
+  // their mind vouched for them and the app names "mind".
+  const takesPerson = !person || !hostResource || (await hostTakes(env, hostResource, person));
+  if (takesPerson === null) return errorPage(TOO_MANY, 429);
+  // A guest's cookie counts only where nobody is signed in, for a host's own sign-in whose app
+  // names guests (`guestAt`), and a mind's cookie too (`mindPersonAt`). BESIDE A PERSON'S SESSION
+  // a mind's cookie counts in two cases alone. The app does not take that session, and the mind
+  // sign-in that was begun for THIS REQUEST just completed (a fresh mark that names it): the
+  // person was sent to the sign-in for this request, and that was their answer. A sign-in that
+  // an app's page began names no request, and answers nothing here: the sign-in page comes. Or the app takes the session, and the person chose
+  // the mind's person on the chooser's page (`choice`).
+  let session: SignedIn | null = null;
+  // whether this request spent the fresh mark, which answers a `select_account` too
+  let fresh = false;
+  if (choice) {
+    if (!hostSignIn || new URL(hostResource).host !== choice.app) return choiceEnded();
+    if (choice.as === "person") {
+      // the person whom the page named, still signed in and still taken: no other, and never
+      // the mind's person in their place
+      if (person?.userId !== choice.person || !takesPerson) return choiceEnded();
+      session = person;
+    } else {
+      const mind = await mindPersonAt(env, hostResource, request);
+      if (mind?.userId !== choice.user) return choiceEnded();
+      session = mind;
+    }
+  } else if (person && takesPerson) session = person;
+  else if (hostSignIn && person) {
+    const mind = await mindPersonAt(env, hostResource, request);
+    fresh = Boolean(
+      mind &&
+      (await freshAnswers(env, request, mind.userId, new URL(hostResource).host, here, true)),
+    );
+    if (fresh) session = mind;
+  } else if (hostSignIn)
+    session =
+      (await guestAt(env, hostResource, request)) ||
+      (await mindPersonAt(env, hostResource, request));
   const guest = session?.method === "guest";
   // a member of another mind, as a guest: a cookie of their own, with no session row
   const cookieOnly = guest || session?.method === "mind";
   const signIn = `${issuerOf(env)}${signInHref(here)}`;
   if (!session) return Response.redirect(signIn, 302);
-  // AN APP NAMES HOW ITS PEOPLE SIGN IN, and this endpoint holds every code for the app's host to
-  // it, whichever client asks. A session that the app does not take is no session here: the
-  // person goes to the sign-in for this request, which offers the app's methods alone.
-  const taken = hostResource ? await hostTakes(env, hostResource, session) : true;
-  if (taken === null) return errorPage(TOO_MANY, 429);
-  if (!taken) return Response.redirect(signIn, 302);
   // A MIND SIGN-IN THAT JUST COMPLETED for this host is the answer to its `select_account`, once:
   // the person signed out here, then signed in with their mind (./cookies.ts `mindFreshCookie`).
   const answered =
     prompt === "select_account" &&
     hostSignIn &&
     session.method === "mind" &&
-    (await freshAnswers(env, request, session.userId, new URL(hostResource).host));
+    (fresh || (await freshAnswers(env, request, session.userId, new URL(hostResource).host, here)));
   const asked = answered ? null : prompt;
+  // BESIDE A PERSON'S SESSION the same mind sign-in answers nothing by itself: the chooser offers
+  // both people, and the person's press decides (`chosen`). So a mind sign-in that another site
+  // ran in this browser replaces nobody.
+  const offer =
+    asked === "select_account" && hostSignIn && !cookieOnly
+      ? await mindOffer(env, request, hostResource, here, session.userId)
+      : null;
   // OpenID Connect's `prompt`. `login`: sign in again, whoever is signed in. `select_account`: say
   // who is signed in and offer another account. Either comes back here without it. A guest's
   // cookie ends for either: the name form is the page that says who they are, and its answer is
@@ -160,6 +212,10 @@
       // the mind's own
       app: (await isMemberSession(env, session)) ? null : await askingAppOf(env, here),
       signedOutOf: hostSignIn ? new URL(hostResource).host : undefined,
+      mindHostname: offer?.hostname,
+      headers: offer
+        ? new Headers({ "set-cookie": offer.cookie, "cache-control": "no-store" })
+        : undefined,
     });
   const refused = await grantRefusal(env, session, hostResource, here);
   if (refused) return refused;
@@ -233,6 +289,7 @@
   if (request.headers.get("origin") !== issuerOf(env))
     return errorPage("Approve this from its own page.", 403);
   const form = await request.formData().catch(() => null);
+  if (form?.has(CHOICE_FIELD)) return chosen(env, request, form);
   const handle = form?.get("handle");
   if (typeof handle !== "string") return errorPage("This form is incomplete. Start again.", 400);
   const session = await personSessionOf(env, request);
@@ -300,24 +357,114 @@
 
 /** Whether this browser's fresh mind sign-in (./cookies.ts `mindFreshCookie`) is the one of
  *  `userId` for the app at `host`, taken now for the first time. */
-async function freshAnswers(env: Env, request: Request, userId: string, host: string) {
+async function freshAnswers(
+  env: Env,
+  request: Request,
+  userId: string,
+  host: string,
+  here: string,
+  boundOnly = false,
+) {
   const fresh = await mindFreshOf(env, request);
   if (!fresh || fresh.user !== userId || fresh.app !== host) return false;
-  // once: a repeat cannot insert (the statements' table, as ./mind-sign-in.ts takes a vouch)
+  // `boundOnly`: only a sign-in that was begun for this very request answers
+  if (boundOnly && !fresh.request) return false;
+  // a sign-in that was begun for one request answers that request alone: another request for
+  // the same host does not spend its mark
+  if (fresh.request && fresh.request !== (await requestHashOf(here))) return false;
+  return once(env, `mind-fresh:${fresh.jti}`, fresh.exp * 1000);
+}
+
+/** Whether `mark` is taken now for the first time: a repeat cannot insert (the statements'
+ *  table, as ./mind-sign-in.ts takes a vouch). */
+async function once(env: Env, mark: string, expires: number) {
   const [, inserted] = await env.DB.batch([
     env.DB.prepare(`delete from statements where expires <= ?1`).bind(Date.now()),
     env.DB.prepare(
       `insert into statements (hash, expires) values (?1, ?2) on conflict do nothing`,
-    ).bind(`mind-fresh:${fresh.jti}`, fresh.exp * 1000),
+    ).bind(mark, expires),
   ]);
   return Boolean(inserted?.meta.changes);
 }
 
+/** THE MIND PERSON THAT THE CHOOSER OFFERS beside a person's session, for the request `here` of
+ *  the host's own sign-in, or null: this browser's mind sign-in for that host just completed
+ *  (the fresh mark, spent here), and the app names "mind". The cookie is the choice that the
+ *  page's POST takes (./cookies.ts `mindChoiceCookie`): for that person, that host and that
+ *  request alone. */
+async function mindOffer(
+  env: Env,
+  request: Request,
+  hostResource: string,
+  here: string,
+  person: string,
+) {
+  const mind = await mindPersonAt(env, hostResource, request);
+  const { host } = new URL(hostResource);
+  if (!mind?.mind || !(await freshAnswers(env, request, mind.userId, host, here))) return null;
+  return {
+    hostname: mind.mind.hostname,
+    cookie: await mindChoiceCookie(
+      env,
+      { person, user: mind.userId, app: host, request: await requestHashOf(here) },
+      AUTHORIZE_ENDPOINT,
+    ),
+  };
+}
+
+/** THE CHOOSER'S PRESS, when it offered a mind person too (`mindOffer`): a POST from the page
+ *  (`decide` checked its origin) with the request it showed, `here`, and "mind" or "person". The
+ *  choice is this browser's, for that request, and is taken once: so one page makes one code,
+ *  for one of the two, and a second request for the same host needs a page of its own. Then the
+ *  request is answered as a GET of it is, with every check of `describe`: for "mind", as the
+ *  mind person, whose cookie and whose app's "mind" are read again. */
+async function chosen(env: Env, request: Request, form: FormData) {
+  const here = form.get("here");
+  const as = form.get(CHOICE_FIELD);
+  if (typeof here !== "string" || (as !== "mind" && as !== "person")) return choiceEnded();
+  const issuer = issuerOf(env);
+  const url = URL.parse(here, issuer);
+  if (!url || url.origin !== issuer || url.pathname !== AUTHORIZE_ENDPOINT) return choiceEnded();
+  // the choice of this request's own page: a chooser for another request has another cookie,
+  // which this press neither reads nor ends
+  const hash = await requestHashOf(here);
+  const choice = await mindChoiceOf(env, request, hash);
+  if (!choice) return choiceEnded();
+  if (!(await once(env, `mind-choice:${choice.jti}`, choice.exp * 1000))) return choiceEnded(hash);
+  const headers = new Headers(request.headers);
+  headers.delete("content-type");
+  headers.delete("content-length");
+  const answer = await describe(env, new Request(url, { headers }), {
+    as,
+    person: choice.person,
+    user: choice.user,
+    app: choice.app,
+  });
+  console.info({ event: "auth.chooser-chose", as, host: choice.app, status: answer.status });
+  const answered = new Headers(answer.headers);
+  answered.append("set-cookie", clearMindChoiceCookie(hash, AUTHORIZE_ENDPOINT));
+  answered.set("cache-control", "no-store");
+  return new Response(answer.body, {
+    status: answer.status,
+    statusText: answer.statusText,
+    headers: answered,
+  });
+}
+
+/** A choice that is gone: used, timed out, or for another request or another person. With
+ *  `requestHash`, that request's own cookie ends with it. */
+function choiceEnded(requestHash?: string) {
+  const headers = new Headers({ "cache-control": "no-store" });
+  if (requestHash)
+    headers.set("set-cookie", clearMindChoiceCookie(requestHash, AUTHORIZE_ENDPOINT));
+  return errorPage("This choice ended. Go back to the app and sign in again.", 403, headers, []);
+}
+
 /** Whether the app at `hostResource` takes `session` (./asking-app.ts `appTakes`). Null: the
  *  app could not be asked, since too many new hostnames were asked about just now. */
 async function hostTakes(env: Env, hostResource: string, session: SignedIn) {
   const app = await appOf(env, hostResource);
-  return app && appTakes(app, session.method);
+  return app && appTakes(app, session);
 }
 
 /** WHY A SESSION GETS NO GRANT, or null. A mind hostname takes the identity of anyone signed in,
M core/auth-worker/src/config.test.ts
@@ -92,3 +92,41 @@
     "https://iterate.example.com/api/provide-connect",
   ]);
 });
+
+test("an owner is also an address at the exact domain of an owner email pattern", () => {
+  const config = { ownerEmails: ["owner@example.net"], ownerEmailPatterns: ["*@company.example"] };
+  expect([
+    isOwner(config, "owner@example.net"),
+    isOwner(config, " Bo@Company.example"),
+    isOwner(config, "bo@sub.company.example"),
+    isOwner(config, "bo@company.example.evil.example"),
+    isOwner(config, "bo@example.net"),
+  ]).toEqual([true, true, false, false, false]);
+});
+
+test.for([
+  ["at a zone", "*@example.com"],
+  ["under a zone", "*@mail.example.com"],
+  ["at the second zone", "*@second.example"],
+])(
+  "an owner email pattern %s of the mind is refused: the mind receives its mail",
+  ([, pattern]) => {
+    const vars = configVars({
+      zones: ["example.com", "second.example"],
+      ownerEmailPatterns: [pattern!],
+    });
+    expect(() => authConfigOf(vars)).toThrow(
+      /ITERATE__OWNER_EMAIL_PATTERNS.*names a zone of the mind/,
+    );
+  },
+);
+
+test("a config whose owner email pattern is no pattern is refused, and one with a pattern elsewhere is taken", () => {
+  expect(() => authConfigOf(configVars({ ownerEmailPatterns: ["*@*"] }))).toThrow(
+    "ownerEmailPatterns",
+  );
+  expect(authConfigOf(configVars({ ownerEmailPatterns: ["*@company.example"] }))).toMatchObject({
+    ownerEmailPatterns: ["*@company.example"],
+  });
+  expect(authConfigOf(configVars())).not.toHaveProperty("ownerEmailPatterns");
+});
M core/auth-worker/src/config.ts
@@ -4,7 +4,15 @@
 // is the mind's own. Pure: ./env.ts reads it out of the Worker's variables.
 import { fieldNameOf, redacted } from "iterate/app-config";
 import { mindApiUrlOf, mindMcpUrlOf, mindProvideConnectResourceOf } from "iterate/mind-api";
-import { Hostname, type MindConfig, mindConfigOf, zoneOfMailAddress } from "iterate/mind-config";
+import {
+  domainOfOwnerEmailPattern,
+  Hostname,
+  isOwnerEmail,
+  type MindConfig,
+  mindConfigOf,
+  zoneOf,
+  zoneOfMailAddress,
+} from "iterate/mind-config";
 import { z } from "zod";
 
 const ownFields = {
@@ -30,6 +38,14 @@
     throw new Error(
       `${fieldNameOf(["ownerEmails"], { prefix: "ITERATE" })}: ${own} is at a zone of the mind, which receives that address's mail, so the mind could sign in as that owner`,
     );
+  // the same for a pattern: every address that it names is one the mind receives the mail of
+  const ownPattern = (config.ownerEmailPatterns || []).find((pattern) =>
+    zoneOf(config, domainOfOwnerEmailPattern(pattern)),
+  );
+  if (ownPattern)
+    throw new Error(
+      `${fieldNameOf(["ownerEmailPatterns"], { prefix: "ITERATE" })}: ${ownPattern} names a zone of the mind, which receives that domain's mail, so the mind could sign in as an owner`,
+    );
   return config;
 }
 
@@ -38,10 +54,21 @@
 export const atMindsZone = (config: Pick<MindConfig, "zones">, email: string) =>
   zoneOfMailAddress(config, email.trim()) !== null;
 
-/** An owner is a member the config names: the people a deploy lets in, so the only ones who let
- *  another member in again. */
-export const isOwner = (config: Pick<MindConfig, "ownerEmails">, email: string) =>
-  config.ownerEmails.includes(email.trim().toLowerCase());
+/** An owner is a member the config names, by address (`ownerEmails`) or by an owner email
+ *  pattern (`ownerEmailPatterns`, `*@<domain>`): the people a deploy lets in, so the only ones
+ *  who let another member in again. */
+export const isOwner = (
+  config: Pick<MindConfig, "ownerEmails" | "ownerEmailPatterns">,
+  email: string,
+) => isOwnerEmail(config, email);
+
+/** AN OWNER BY A PATTERN ALONE: at the domain of an owner email pattern, and not named by
+ *  address. Such a person's standing is the one that an owner can end for one address: by a
+ *  block (./members.ts `isMember`, `block`). An owner by address is ended by a deploy alone. */
+export const isOwnerByPattern = (
+  config: Pick<MindConfig, "ownerEmails" | "ownerEmailPatterns">,
+  email: string,
+) => !config.ownerEmails.includes(email.trim().toLowerCase()) && isOwnerEmail(config, email);
 
 /** THE AUDIENCES OF THE TOKENS THIS WORKER ISSUES TO MEMBERS (RFC 8707 resources), each a
  *  canonical URI: the mind's API and its MCP server, and the address an external mind connects in
M core/auth-worker/src/cookies.ts
@@ -489,12 +489,20 @@
 // the authorization endpoint at once. There it answers that host's `prompt=select_account` once
 // (./authorize.ts): a host that the person signed out of asks who they are, and they just said.
 // Any authorization clears it, and its `jti` is taken once (`statements`), so it answers one
-// prompt at most.
+// prompt at most. `request`: when the sign-in was begun for one authorization request (the
+// sign-in page's `next`), a hash of that request (`requestHashOf`), and the mark answers no
+// other. A sign-in that an app's page began (iterate/sdk `auth.mindSignIn`) has none: its
+// request does not exist yet.
 export const MIND_FRESH_COOKIE = "__Host-iterate-auth-mind-fresh";
 const MIND_FRESH_SECONDS = 30;
 
-export async function mindFreshCookie(env: Env, fresh: { user: string; app: string }) {
-  const token = await signed(env, "mind-fresh", fresh)
+export async function mindFreshCookie(
+  env: Env,
+  fresh: { user: string; app: string; request: string | null },
+) {
+  const claims: Record<string, string> = { user: fresh.user, app: fresh.app };
+  if (fresh.request) claims.request = fresh.request;
+  const token = await signed(env, "mind-fresh", claims)
     .setJti(crypto.randomUUID())
     .setExpirationTime(`${MIND_FRESH_SECONDS}s`)
     .sign(keyOf(env));
@@ -506,6 +514,7 @@
     .object({
       user: z.string().min(1),
       app: z.string().min(1),
+      request: z.string().min(1).optional(),
       jti: z.string().min(1),
       exp: z.number(),
     })
@@ -514,6 +523,63 @@
 }
 
 export const clearMindFreshCookie = cookie(MIND_FRESH_COOKIE, "", 0);
+
+/** A hash of an authorization request, as its path and query without `prompt` (./authorize.ts
+ *  `promptOf`, `here`): what a fresh mark and a chooser's choice are bound to. */
+export async function requestHashOf(here: string) {
+  const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(here));
+  return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
+}
+
+// THE CHOICE THAT THE CHOOSER OFFERS between a person's session here and a mind sign-in that just
+// completed (./authorize.ts `chosen`): set with the chooser's page, for the two people that the
+// page names (`person`, `user`), the app's host and that one authorization request (`request`, a
+// hash of it), for two minutes. The chooser's POST takes it once (`jti`, `statements`), so one
+// page makes one code. `SameSite=Strict` and the authorization endpoint's path: only that page's
+// own form sends it. The cookie's name ends with the start of the request's hash, so a chooser
+// for another request, in another tab, has a choice of its own.
+const MIND_CHOICE_SECONDS = 120;
+
+const mindChoiceNameOf = (requestHash: string) =>
+  `__Secure-iterate-auth-mind-choice-${requestHash.slice(0, 16)}`;
+
+export async function mindChoiceCookie(
+  env: Env,
+  choice: { person: string; user: string; app: string; request: string },
+  path: string,
+) {
+  const token = await signed(env, "mind-choice", choice)
+    .setJti(crypto.randomUUID())
+    .setExpirationTime(`${MIND_CHOICE_SECONDS}s`)
+    .sign(keyOf(env));
+  return mindChoiceCookieOf(choice.request, token, MIND_CHOICE_SECONDS, path);
+}
+
+/** The choice that this browser holds for the request with the hash `requestHash`. */
+export async function mindChoiceOf(env: Env, request: Request, requestHash: string) {
+  const choice = z
+    .object({
+      person: z.string().min(1),
+      user: z.string().min(1),
+      app: z.string().min(1),
+      request: z.literal(requestHash),
+      jti: z.string().min(1),
+      exp: z.number(),
+    })
+    .safeParse(await claimsOf(env, request, mindChoiceNameOf(requestHash), "mind-choice"));
+  return choice.success ? choice.data : null;
+}
+
+const mindChoiceCookieOf = (
+  requestHash: string,
+  value: string,
+  maxAgeSeconds: number,
+  path: string,
+) =>
+  `${mindChoiceNameOf(requestHash)}=${value}; HttpOnly; Secure; SameSite=Strict; Path=${path}; Max-Age=${maxAgeSeconds}`;
+
+export const clearMindChoiceCookie = (requestHash: string, path: string) =>
+  mindChoiceCookieOf(requestHash, "", 0, path);
 
 const signed = (env: Env, audience: string, claims: Record<string, string>) =>
   new SignJWT(claims)
M core/auth-worker/src/email-sign-in.ts
@@ -12,6 +12,12 @@
 //   or with none                (`memberRefusal`): the passkey, Cloudflare Access for an owner
 //                               (./access-sign-in.ts), an owner's sign-in link for an added member
 //
+// AN APP MAY NAME WHOSE ADDRESS A CODE SIGNS IN (`emailDomains`, ./asking-app.ts). For such an
+// app the address page says which domains, and an address at any other is refused there with
+// that reason, for every such address alike, a member's too: no challenge is made and nothing is
+// mailed, so it spends none of the limits below. The app's description is public, so the words
+// tell nothing that it does not.
+//
 // A SIGN-IN THAT DOES NOT NAME "email" HAS NO SUCH PAGE: an app says how its people sign in
 // (./asking-app.ts `signInOf`), and for one that names the passkey alone, as for the control
 // plane's own sign-in, the address page leads back to the sign-in page, and no code is mailed in
@@ -26,7 +32,7 @@
 import { zoneOf } from "iterate/mind-config";
 import { z } from "zod";
 import { AccountFacts } from "./account-facts.ts";
-import { type AskingApp, askingAppOf, signInOf } from "./asking-app.ts";
+import { type AskingApp, askingAppOf, signInOf, takesAddress } from "./asking-app.ts";
 import { isBlocked } from "./blocked.ts";
 import { isOwner } from "./config.ts";
 import { emailSessionCookie, MIND_FORM_PATH, sessionsOverRemoved } from "./cookies.ts";
@@ -170,7 +176,7 @@
     imageOrigin: asking?.imageOrigin,
     status: error ? 400 : 200,
     body: `${asking?.heading || `<h1>Sign in to ${text(mind)}</h1>`}
-      <p class="muted">Enter your email. We send you a code to sign in with.</p>
+      <p class="muted">Enter your email. We send you a code to sign in with.${onlyAt(signIn)}</p>
       ${ruleAbove(env, asking)}
       ${error ? `<p role="alert">${text(error)}</p>` : ""}
       <form method="post" action="${EMAIL_SIGN_IN_PATH}" class="stack">
@@ -183,6 +189,16 @@
   });
 }
 
+/** The domains that an app's mailed code is for, as a list in words: "a.com or b.com". */
+const domainsOf = (domains: string[]) =>
+  new Intl.ListFormat("en", { type: "disjunction" }).format(domains);
+
+/** One more sentence on the address page of an app that names domains: whose address it takes. */
+const onlyAt = ({ mailedCode }: SignIn) =>
+  mailedCode?.emailDomains
+    ? ` ${text(mailedCode.name)} takes an address at ${text(domainsOf(mailedCode.emailDomains))} only.`
+    : "";
+
 /** The way to "sign in with your mind" (./mind-sign-in.ts), for an app that names it. */
 const mindWay = (next: string) => `<form method="get" action="${MIND_FORM_PATH}" class="stack">
         <input type="hidden" name="next" value="${text(next)}">
@@ -202,6 +218,13 @@
   const email = typed.trim().toLowerCase();
   const again = (error: string) => emailAddressPage(env, next, signIn, error, typed);
   if (!z.email().safeParse(email).success) return again("Enter an email address.");
+  // an app that names domains: no code for an address at any other, and no challenge
+  if (signIn.mailedCode?.emailDomains && !takesAddress(signIn.mailedCode, email)) {
+    console.info({ event: "auth.sign-in-refused", method: "email", reason: "domain" });
+    return again(
+      `${signIn.mailedCode.name} takes an address at ${domainsOf(signIn.mailedCode.emailDomains)} only. Use such an address.`,
+    );
+  }
   const id = crypto.randomUUID();
   const code = String(crypto.getRandomValues(new Uint32Array(1))[0]! % 1_000_000).padStart(6, "0");
   // both are read for every address alike, so the answer's time says nothing
M core/auth-worker/src/enrolment.test.ts
@@ -898,6 +898,96 @@
   expect(stack.mailed).toHaveLength(before);
 });
 
+// AN APP NAMES WHOSE ADDRESS A MAILED CODE SIGNS IN (iterate/app-description `emailDomains`), and
+// the issuer holds the sign-up to the list: at the mail, and at every code for the app's host.
+test("an app that names domains: no code is mailed to an address at another domain and no challenge is made, from the app's own page and from an MCP client alike; a session of such an address gets no code for the host; a passkey's session passes", async () => {
+  const stack = stackOf();
+  const shop = "https://shop.example.com";
+  const inside = "eve@shop-people.dev";
+  stack.described.set("shop.example.com", {
+    name: "Shop",
+    signIn: ["email", "passkey"],
+    emailDomains: ["shop-people.dev"],
+  });
+  const mcp = await oauthHelpers(stack.env).createClient({
+    clientName: "An MCP client",
+    redirectUris: [MCP_CALLBACK],
+    tokenEndpointAuthMethod: "none",
+    grantTypes: ["authorization_code", "refresh_token"],
+    responseTypes: ["code"],
+  });
+  const nextOf = async (client?: string) =>
+    new URL((await authorized(stack.env, "", shop, client)).location).searchParams.get("next")!;
+  const own = await nextOf();
+  const fromMcp = await nextOf(mcp.clientId);
+
+  // the address page says whose address the app takes, on the app's page and on the mind's
+  for (const next of [own, fromMcp])
+    expect(
+      await (await ask(stack.env, `/sign-in/email?${new URLSearchParams({ next })}`)).text(),
+    ).toContain("Shop takes an address at shop-people.dev only.");
+
+  const challenges = () =>
+    stack.db.prepare("select count(*) as n from email_challenges").get() as { n: number };
+  const asked = async (email: string, next: string) => {
+    const before = { mailed: stack.mailed.length, challenges: challenges().n };
+    const answer = await ask(stack.env, "/sign-in/email", {
+      method: "POST",
+      body: new URLSearchParams({ email, next: `${ISSUER}${next}` }),
+    });
+    return {
+      status: answer.status,
+      mailed: stack.mailed.length - before.mailed,
+      challenges: challenges().n - before.challenges,
+      says: answer.status === 400 ? /role="alert">([^<]*)</.exec(await answer.text())?.[1] : "",
+    };
+  };
+  const refused = {
+    status: 400,
+    mailed: 0,
+    challenges: 0,
+    says: "Shop takes an address at shop-people.dev only. Use such an address.",
+  };
+  expect({
+    // an address at another domain, a subdomain of the app's, and a member's: one answer for all
+    outsider: await asked(GUEST, own),
+    outsiderFromMcp: await asked(GUEST, fromMcp),
+    subdomain: await asked("eve@mail.shop-people.dev", own),
+    member: await asked(MEMBER, own),
+    insider: await asked(inside, own),
+    insiderInCapitals: await asked("Bo@Shop-People.dev", fromMcp),
+  }).toEqual({
+    outsider: refused,
+    outsiderFromMcp: refused,
+    subdomain: refused,
+    member: refused,
+    insider: { status: 303, mailed: 1, challenges: 1, says: "" },
+    insiderInCapitals: { status: 303, mailed: 1, challenges: 1, says: "" },
+  });
+
+  // A SESSION THAT A MAILED CODE OPENED ELSEWHERE, at an app that takes any address, is no
+  // session at the shop for an address outside its list.
+  const outsider = (await codeRedeemed(stack, GUEST)).cookie;
+  const insider = (await codeRedeemed(stack, inside)).cookie;
+  const member = await passkeyAdded(stack, MEMBER);
+  const ends = async (cookie: string) => ({
+    own: (await authorized(stack.env, cookie, shop)).ends,
+    mcp: (await authorized(stack.env, cookie, shop, mcp.clientId)).ends,
+  });
+  expect({
+    outsider: await ends(outsider),
+    insider: await ends(insider),
+    // a passkey's session counts at every app: which members come is the app's own guard
+    member: await ends(member.cookie),
+    outsiderAtAnother: (await authorized(stack.env, outsider, GUESTBOOK)).ends,
+  }).toEqual({
+    outsider: { own: "the sign-in page", mcp: "the sign-in page" },
+    insider: { own: "a code for the host", mcp: "the consent page" },
+    member: { own: "a code for the host", mcp: "the consent page" },
+    outsiderAtAnother: "a code for the host",
+  });
+});
+
 test("a consent that a session of another method approves gives no code for an app that does not take that method", async () => {
   const stack = stackOf();
   const letters = "https://letters.second.example";
M core/auth-worker/src/members.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/auth-worker/src/mind-sign-in.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/auth-worker/src/mind-sign-in.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/auth-worker/src/oauth.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/auth-worker/src/oauth.ts

Not shown: the change is larger than this page shows. A clone has it.

A core/auth-worker/src/owner-email-patterns.test.ts
@@ -0,0 +1,177 @@
+// owner-email-patterns.test.ts — WHAT AN OWNER EMAIL PATTERN OPENS, AND WHAT IT DOES NOT
+// (iterate/mind-config `isOwnerEmail`): on a mind at example.com with one owner by address, one
+// added member, and the pattern `*@company.example`.
+import { expect, test, vi } from "vitest";
+import { sessionCookie, sessionOf } from "./cookies.ts";
+import { enrolmentCookie } from "./enrolment.ts";
+import type { Env } from "./env.ts";
+import { authResponse } from "./http.ts";
+import { isMember, isMemberSession } from "./members.ts";
+import { sqliteStack } from "./test-support.ts";
+import { userOf } from "./users.ts";
+
+const OWNER = "ada@adas-mail.example";
+const ADDED = "bo@bos-mail.example";
+const AT_PATTERN = "cy@company.example";
+const PATTERNS = ["*@company.example"];
+const ISSUER = "https://iterate.example.com";
+const ctx = { waitUntil() {}, passThroughOnException() {} } as unknown as ExecutionContext;
+const NOT_AT_PATTERN = [
+  "cy@sub.company.example",
+  "cy@company.example.evil.example",
+  "cy@evilcompany.example",
+  "cy@company.example@evil.example",
+  "cy@other.example",
+];
+
+test("with no pattern, and with an empty list, the members are the owner and the added member alone", async () => {
+  for (const ownerEmailPatterns of [undefined, []]) {
+    const { env } = stackOf({ ownerEmailPatterns });
+    expect(await membersAmong(env, [OWNER, ADDED, AT_PATTERN, ...NOT_AT_PATTERN])).toEqual([
+      OWNER,
+      ADDED,
+    ]);
+  }
+});
+
+test("a pattern makes an address at exactly its domain a member, and leaves every other answer as it was", async () => {
+  const { env } = stackOf({ ownerEmailPatterns: PATTERNS });
+  expect(
+    await membersAmong(env, [OWNER, ADDED, AT_PATTERN, " Cy@Company.Example ", ...NOT_AT_PATTERN]),
+  ).toEqual([OWNER, ADDED, AT_PATTERN, " Cy@Company.Example "]);
+});
+
+test("a session acts as a member by a pattern only when a passkey opened it: a mailed code's never does", async () => {
+  const { env } = stackOf({ ownerEmailPatterns: PATTERNS });
+  expect(await isMemberSession(env, { method: "passkey", email: AT_PATTERN })).toBe(true);
+  expect(await isMemberSession(env, { method: "email", email: AT_PATTERN })).toBe(false);
+  expect(await isMemberSession(env, { method: "passkey", email: NOT_AT_PATTERN[0]! })).toBe(false);
+});
+
+test("Cloudflare's proof of an address at a pattern opens the first passkey's session, as an owner's does; with no pattern it opens none", async () => {
+  const request = new Request("https://iterate.example.com/sign-in/access");
+  const withPattern = stackOf({ ownerEmailPatterns: PATTERNS });
+  expect(
+    await enrolmentCookie(withPattern.env, request, AT_PATTERN, "cloudflare-access"),
+  ).toMatchObject({ setCookie: expect.any(String) });
+  // an owner's link is for an added member: an owner by a pattern is an owner
+  expect(await enrolmentCookie(withPattern.env, request, AT_PATTERN, "member-link")).toEqual({
+    refused: `${AT_PATTERN} is an owner of iterate.example.com. An owner's link signs in no owner.`,
+  });
+  for (const email of NOT_AT_PATTERN)
+    expect(
+      await enrolmentCookie(withPattern.env, request, email, "cloudflare-access"),
+    ).toMatchObject({ refused: expect.stringContaining("is not an owner") });
+  expect(
+    await enrolmentCookie(stackOf().env, request, AT_PATTERN, "cloudflare-access"),
+  ).toMatchObject({ refused: expect.stringContaining("is not an owner") });
+});
+
+test("a deploy that takes the pattern away ends the membership of the people it named", async () => {
+  const stack = stackOf({ ownerEmailPatterns: PATTERNS });
+  expect(await isMember(stack.env, AT_PATTERN)).toBe(true);
+  const without = stack.envOf({ ownerEmailPatterns: undefined });
+  expect(await isMember(without, AT_PATTERN)).toBe(false);
+  expect(await isMemberSession(without, { method: "passkey", email: AT_PATTERN })).toBe(false);
+  expect(await membersAmong(without, [OWNER, ADDED])).toEqual([OWNER, ADDED]);
+});
+
+// A PERSON WHO LEFT: the mail provider closes the mailbox, and the passkey that the person added
+// still works. An owner's block is what ends that one person, while the pattern stays.
+test("an owner's block ends one person of a pattern: no member, no session, no way back in; the others of the pattern stay", async () => {
+  const stack = stackOf({ ownerEmailPatterns: PATTERNS });
+  const { env } = stack;
+  const request = new Request("https://iterate.example.com/sign-in/access");
+  const owner = await passkeyCookie(env, OWNER);
+  const leaver = await passkeyCookie(env, AT_PATTERN);
+  const asLeaver = new Request("https://iterate.example.com/keys", { headers: { cookie: leaver } });
+  expect(await sessionOf(env, asLeaver)).toMatchObject({ email: AT_PATTERN });
+  // a removal would change nothing, and says what does
+  expect(await posted(env, owner, "remove", AT_PATTERN)).toContain("Block this address");
+  expect(await isMember(env, AT_PATTERN)).toBe(true);
+
+  expect(await posted(env, owner, "block", AT_PATTERN)).toContain(
+    `${AT_PATTERN} is blocked: it is no owner and no member now`,
+  );
+  expect(await membersAmong(env, [OWNER, ADDED, AT_PATTERN, "cy+tag@company.example"])).toEqual([
+    OWNER,
+    ADDED,
+  ]);
+  expect(await isMember(env, "dee@company.example")).toBe(true);
+  expect(await isMemberSession(env, { method: "passkey", email: AT_PATTERN })).toBe(false);
+  expect(await sessionOf(env, asLeaver)).toBeNull();
+  // neither Cloudflare's proof nor the recovery command's link opens a first passkey's session
+  for (const proof of ["cloudflare-access", "recovery-link"] as const)
+    expect(await enrolmentCookie(env, request, AT_PATTERN, proof)).toEqual({
+      refused: `${AT_PATTERN} is not a member of iterate.example.com.`,
+    });
+  // a deploy that takes the pattern away and one that brings it back: the block is still there
+  expect(await isMember(stack.envOf({ ownerEmailPatterns: undefined }), AT_PATTERN)).toBe(false);
+  expect(await isMember(stack.envOf({ ownerEmailPatterns: PATTERNS }), AT_PATTERN)).toBe(false);
+
+  expect(await posted(env, owner, "unblock", AT_PATTERN)).toContain("is no longer blocked");
+  expect(await isMember(env, AT_PATTERN)).toBe(true);
+});
+
+test("a block of a person of a pattern takes their row of /members with it, and an owner by address and an added member are never blocked", async () => {
+  const stack = stackOf({ ownerEmailPatterns: PATTERNS });
+  const { env } = stack;
+  stack.db
+    .prepare("insert into members (email, added_by, added_at) values (?, ?, 0)")
+    .run(AT_PATTERN, OWNER);
+  const owner = await passkeyCookie(env, OWNER);
+  await posted(env, owner, "block", AT_PATTERN);
+  expect(stack.db.prepare("select email from members order by email").all()).toEqual([
+    { email: ADDED },
+  ]);
+  expect(await isMember(env, AT_PATTERN)).toBe(false);
+  for (const member of [OWNER, ADDED])
+    expect(await posted(env, owner, "block", member)).toContain("a member is never blocked");
+  expect(stack.db.prepare("select email from blocked").all()).toEqual([{ email: AT_PATTERN }]);
+});
+
+function stackOf(config: { ownerEmailPatterns?: string[] } = {}) {
+  const stack = sqliteStack({ zones: ["example.com"], ownerEmails: [OWNER], ...config });
+  vi.stubGlobal("fetch", async () => new Response("Not found", { status: 404 }));
+  stack.db
+    .prepare("insert into members (email, added_by, added_at) values (?, ?, 0)")
+    .run(ADDED, OWNER);
+  return stack;
+}
+
+/** The cookie of `email`'s session by a passkey, which the test gives them. */
+async function passkeyCookie(env: Env, email: string) {
+  const person = await userOf(env.DB, email);
+  const key = `key-of-${person.id}`;
+  await env.DB.prepare(
+    `insert into keys (id, user_id, public_key, format, label, added_via, added_by, added_at)
+     values (?2, ?1, ?2, 'webauthn', 'a passkey', 'keys-page', ?1, 1)`,
+  )
+    .bind(person.id, key)
+    .run();
+  const { setCookie } = await sessionCookie(env, new Request(ISSUER), person, key);
+  return setCookie.split(";")[0]!;
+}
+
+/** The text of the members page after `cookie`'s person posted `action` for `email`. */
+async function posted(env: Env, cookie: string, action: string, email: string) {
+  const answer = await authResponse(
+    new Request(`${ISSUER}/members`, {
+      method: "POST",
+      headers: { origin: ISSUER, cookie },
+      body: new URLSearchParams({ action, email }),
+    }),
+    env,
+    ctx,
+  );
+  // a removal answers with a redirect, and the page writes an apostrophe as a numbered entity
+  return (await answer.text()).replaceAll(/&#(\d+);/g, (_all, code) =>
+    String.fromCharCode(Number(code)),
+  );
+}
+
+async function membersAmong(env: ReturnType<typeof stackOf>["env"], emails: string[]) {
+  const members: string[] = [];
+  for (const email of emails) if (await isMember(env, email)) members.push(email);
+  return members;
+}
M core/auth-worker/src/page-tag.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/auth-worker/src/pages.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/auth-worker/src/pages.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/boundary-worker/src/env.ts
@@ -37,7 +37,16 @@
   PROVIDED_MIND?: {
     getByName(
       name: string,
-    ): Pick<MindTarget, "fetch" | "append" | "runAct" | "receiveEmail" | "email" | "api"> &
+    ): Pick<
+      MindTarget,
+      | "fetch"
+      | "append"
+      | "runAct"
+      | "receiveEmail"
+      | "emailForwardRequest"
+      | "emailForwardClaim"
+      | "api"
+    > &
       Required<Pick<MindTransport, "appendOrKeep">>;
   };
 };
M core/boundary-worker/src/http.ts
@@ -25,7 +25,13 @@
 /** The mind, as the boundary reaches it. */
 export type MindTransport = Pick<
   MindTarget,
-  "fetch" | "append" | "runAct" | "receiveEmail" | "email" | "api"
+  | "fetch"
+  | "append"
+  | "runAct"
+  | "receiveEmail"
+  | "emailForwardRequest"
+  | "emailForwardClaim"
+  | "api"
 > & {
   /** Only where the mind runs elsewhere: the answer to its dial, a session of the API that ends
    *  in the object which holds the mind's link (./provided-mind.ts). */
M core/boundary-worker/src/mail.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/boundary-worker/src/mail.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/boundary-worker/src/mind-transport.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/boundary-worker/src/provided-mind.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/boundary-worker/src/provided-mind.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/boundary-worker/src/session-mind.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/boundary-worker/src/stamp.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/boundary-worker/src/worker.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/home-lab/README.md

Not shown: the change is larger than this page shows. A clone has it.

M core/home-lab/src/link/relay.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/home-lab/src/main.ts

Not shown: the change is larger than this page shows. A clone has it.

A core/home-lab/src/seed-repos.test.ts

Not shown: the change is larger than this page shows. A clone has it.

A core/home-lab/src/seed-repos.ts
@@ -0,0 +1,10 @@
+import { existsSync } from "node:fs";
+import path from "node:path";
+
+/** The same `ITERATE_SEED_REPOS` env as `seedReposEnvOf` in `core/lib/src/cli/deploy.ts`,
+ *  so a home-lab mind is born with `/repos/onboarding` when `core/repos/onboarding` exists. */
+export function seedReposEnv(coreDir: string): { ITERATE_SEED_REPOS?: string } {
+  const onboarding = path.join(coreDir, "repos/onboarding");
+  if (!existsSync(onboarding)) return {};
+  return { ITERATE_SEED_REPOS: JSON.stringify({ "/repos/onboarding": onboarding }) };
+}
M core/itx/src/caller.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/itx/src/caller.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/itx/src/context/built-ins.ts

Not shown: the change is larger than this page shows. A clone has it.

D core/itx/src/context/telemetry-query-rule.test.ts

Not shown: the change is larger than this page shows. A clone has it.

D core/itx/src/context/workers-root-email.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/itx/src/iterate-context.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/itx/src/serve-host.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/itx/src/stream/core-processor.ts

Not shown: the change is larger than this page shows. A clone has it.

A core/itx/src/stream/facet-push-catch-up.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/itx/src/stream/stream-versions.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/itx/src/stream/stream.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/itx/src/stream/subscription-delivery.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/README.md

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/agents/README.md

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/agents/api.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/agents/catalog.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/agents/catalog.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/agents/collection.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/agents/collection.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/api.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/app-description.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/app-description.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cause.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/README.md

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/chatgpt.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/chatgpt.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/cli.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/cloudflare-access.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/cloudflare-access.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/deploy.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/deploy.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/device-login/index.ts

Not shown: the change is larger than this page shows. A clone has it.

A core/lib/src/cli/mcp-clients.test.ts

Not shown: the change is larger than this page shows. A clone has it.

A core/lib/src/cli/mcp-clients.ts

Not shown: the change is larger than this page shows. A clone has it.

A core/lib/src/cli/oauth.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/oauth.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/recover.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/cli/recover.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/client/event-log.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/client/event-log.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/client/live-state.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/client/live-state.ts

Not shown: the change is larger than this page shows. A clone has it.

A core/lib/src/client/new-version.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/client/new-version.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/email.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/integrations.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/lib.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/mind-config.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/mind-config.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/node-renewal.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/node.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/sdk/index.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/sdk/index.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/sdk/itx-scope.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/sdk/itx-scope.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/lib/src/workers.ts

Not shown: the change is larger than this page shows. A clone has it.

A core/mind-worker/src/context/egress-upgrade.test.ts

Not shown: the change is larger than this page shows. A clone has it.

A core/mind-worker/src/context/fixtures/egress-upgrade.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/mind-worker/src/context/telemetry.ts

Not shown: the change is larger than this page shows. A clone has it.

D core/mind-worker/src/integrations/email-hook.test.ts

Not shown: the change is larger than this page shows. A clone has it.

D core/mind-worker/src/integrations/email-hook.ts

Not shown: the change is larger than this page shows. A clone has it.

A core/mind-worker/src/integrations/email-receive.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/mind-worker/src/integrations/email.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/mind-worker/src/mind/contract.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/mind-worker/src/mind/processor.test.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/mind-worker/src/mind/publication.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/mind-worker/src/rpc.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/telemetry-worker/src/rpc.ts

Not shown: the change is larger than this page shows. A clone has it.

M core/telemetry-worker/src/store-query.test.ts

Not shown: the change is larger than this page shows. A clone has it.