iterate.com / kernel

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

A deploy waits for the Dash, and setup goes on in the onboarding app only when the mind has one

The config that a new mind starts with (config-template) serves dash, tasks and
git, and no onboarding app. The command still waited for
https://onboarding.<zone>/.well-known/iterate-app: a birth from the new repos
ended after ten minutes with "answered 404" and exit 1, with the mind deployed.

- The first pages of a new mind now ask the Dash's description,
  https://dash.<zone>/.well-known/iterate-app. onboarding.<zone> still proves
  the name and the route, and its 404 is an answer.
- After the pages answer, one read says where setup goes on (`setupHomeOf`): the
  onboarding app when its description answers 200, else the Dash. A first
  deploy then names the Dash as `next` of /sign-in/access, because the auth
  Worker sends a first passkey to onboarding.<zone>.

Tests: core/lib src/cli/deploy.test.ts
Session: claude 73d3e13d-325d-4361-a28d-147e1d1d8f36 on beelink

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NCuxgYXVqrHkU8FNrQYbz4

Jonas Templestein, 2026-11-26 14:46 UTC · 5f0a4ebeb142aced0ae4eccdeed25a21ec5e1cef · parent 7b2caff

3 files changed

M core/lib/src/cli/README.md
@@ -281,9 +281,16 @@
 
 - `https://<control plane>/sign-in` answers 200.
 - `https://<zone>/` answers below 400.
-- `https://onboarding.<zone>/`, the page that the command opens, answers: for a new mind below
-  400 or the app's own 401 (the command's read is no browser navigation), over a mind that was
-  there anything below 500.
+- `https://dash.<zone>/` answers: for a new mind below 400 or the app's own 401 (the command's
+  read is no browser navigation), with the Dash's description at `/.well-known/iterate-app`
+  answering 200; over a mind that was there anything below 500.
+- `https://onboarding.<zone>/` answers anything below 500. A mind's config may have no
+  onboarding app, and its 404 is then the mind's own answer.
+
+Setup goes on in the onboarding app when the mind's config serves one (its
+`/.well-known/iterate-app` answers 200), else in the Dash: where this text says
+`https://onboarding.<zone>/` below, such a mind has `https://dash.<zone>/`.
+
 - For a new mind, `https://<control plane>/sign-in/access` redirects to the account's Cloudflare
   Access sign-in. It is the first owner's one way in, and until the Access application is live
   the page there refuses.
M core/lib/src/cli/deploy.test.ts
@@ -43,6 +43,7 @@
   pickDomain,
   planArgsOf,
   setupDestinationOf,
+  setupHomeOf,
   signInPageOf,
   PNPM_COMPAT_ENV,
   pnpmCommandOf,
@@ -1209,6 +1210,25 @@
     url: "https://onboarding.ada-labs.com/",
     prompt: "Continue setup in your browser (sign in with ada@example.org):",
   });
+  // a mind whose config has no onboarding app goes on in its Dash: a first deploy names it as next
+  expect(
+    setupDestinationOf({
+      controlPlaneHostname: "iterate.ada-labs.com",
+      zone: "ada-labs.com",
+      ownerEmails: [],
+      firstDeploy: true,
+      home: "https://dash.ada-labs.com/",
+    }).url,
+  ).toBe("https://iterate.ada-labs.com/sign-in/access?next=https%3A%2F%2Fdash.ada-labs.com%2F");
+  expect(
+    setupDestinationOf({
+      controlPlaneHostname: "iterate.ada-labs.com",
+      zone: "ada-labs.com",
+      ownerEmails: [],
+      firstDeploy: false,
+      home: "https://dash.ada-labs.com/",
+    }).url,
+  ).toBe("https://dash.ada-labs.com/");
   expect(isInteractiveEnv({}, true)).toBe(true);
   expect(isInteractiveEnv({ CI: "1" }, true)).toBe(false);
   expect(isInteractiveEnv({ CI: "true" }, true)).toBe(false);
@@ -1831,6 +1851,22 @@
   expect(source).toContain("deployed && !resuming?.firstDeploy");
 });
 
+test("setup goes on in the onboarding app when the mind's config serves one, else in its Dash", async () => {
+  const asked: string[] = [];
+  const answering = (status: number) =>
+    (async (address: string | URL | Request) => {
+      asked.push(String(address));
+      return new Response(null, { status });
+    }) as typeof fetch;
+  expect(await setupHomeOf("ada-labs.com", answering(200))).toBe("https://onboarding.ada-labs.com/");
+  expect(asked).toEqual(["https://onboarding.ada-labs.com/.well-known/iterate-app"]);
+  expect(await setupHomeOf("ada-labs.com", answering(404))).toBe("https://dash.ada-labs.com/");
+  const failing = (async () => {
+    throw new Error("no answer");
+  }) as typeof fetch;
+  expect(await setupHomeOf("ada-labs.com", failing)).toBe("https://dash.ada-labs.com/");
+});
+
 test("the deploy opens no page until the pages a browser asks first work: iterate.<domain>, the apex, onboarding.<zone>, dash.<zone> and, for a new mind, the app description and Cloudflare Access", async () => {
   const mind = { controlPlaneHostname: "iterate.ada-labs.com", zone: "ada-labs.com" };
   const CONTROL_PLANE = "https://iterate.ada-labs.com/";
@@ -1839,7 +1875,7 @@
   const APEX = "https://ada-labs.com/";
   const ONBOARDING = "https://onboarding.ada-labs.com/";
   const DASH = "https://dash.ada-labs.com/";
-  const ONBOARDING_APP = "https://onboarding.ada-labs.com/.well-known/iterate-app";
+  const DASH_APP = "https://dash.ada-labs.com/.well-known/iterate-app";
   const ACCESS = "https://iterate.ada-labs.com/sign-in/access";
   const pages = firstPagesOf({ ...mind, firstDeploy: true });
   expect(pages.map((page) => page.address)).toEqual([
@@ -1849,7 +1885,7 @@
     APEX,
     ONBOARDING,
     DASH,
-    ONBOARDING_APP,
+    DASH_APP,
     ACCESS,
   ]);
   // a deploy over a mind asks no first owner's way, and takes the mind's own 404 for an app
@@ -1865,10 +1901,11 @@
   ]);
   expect(over[4]!.works({ status: 404, location: null })).toBe(true);
   expect(over[4]!.works({ status: 522, location: null })).toBe(false);
-  // a new mind's Onboarding and Dash apps answer 401 to Node's fetch, which is no navigation; a
-  // 404 says that the app is not there yet
+  // a new mind's Dash answers 401 to Node's fetch, which is no navigation; a 404 says that the
+  // app is not there yet. Its config may have no onboarding app, so that page's 404 is an answer
   expect(pages[4]!.works({ status: 401, location: null })).toBe(true);
-  expect(pages[4]!.works({ status: 404, location: null })).toBe(false);
+  expect(pages[4]!.works({ status: 404, location: null })).toBe(true);
+  expect(pages[4]!.works({ status: 522, location: null })).toBe(false);
   expect(pages[5]!.works({ status: 401, location: null })).toBe(true);
   expect(pages[5]!.works({ status: 404, location: null })).toBe(false);
   expect(pages[6]!.works({ status: 200, location: null })).toBe(true);
@@ -1882,7 +1919,7 @@
     [APEX]: { status: 200, location: null },
     [ONBOARDING]: { status: 401, location: null },
     [DASH]: { status: 401, location: null },
-    [ONBOARDING_APP]: { status: 200, location: null },
+    [DASH_APP]: { status: 200, location: null },
     [ACCESS]: {
       status: 302,
       location: "https://ada.cloudflareaccess.com/cdn-cgi/access/login/iterate.ada-labs.com",
M core/lib/src/cli/deploy.ts
@@ -585,10 +585,12 @@
  *   - the apex of the first zone answers below 400: the mind's own code (that request is also
  *     the one at which a new mind is born);
  *   - `https://onboarding.<zone>/` and `https://dash.<zone>/` (plus on a first deploy
- *     `https://onboarding.<zone>/.well-known/iterate-app` returning 200): proves the wildcard
+ *     `https://dash.<zone>/.well-known/iterate-app` returning 200): proves the wildcard
  *     record, certificate, route, and config Worker apps are live. Node's fetch sends
  *     `sec-fetch-mode: cors`, so member apps answer 401 here (a browser redirects to sign-in);
- *     404 says the app is not live yet.
+ *     404 from the Dash says the app is not live yet. A mind's config may have no onboarding
+ *     app (the config that a new mind starts with has none), so its 404 is an answer: the page
+ *     proves the name and the route, and `setupHomeOf` says where setup goes on.
  *   - for a new mind, `/sign-in/access`, the one way in for an owner with no passkey yet
  *     (core/auth-worker/src/access-sign-in.ts): Cloudflare Access redirects it to the team's
  *     sign-in. Until the Access application is live at the edge, the auth Worker itself answers
@@ -609,12 +611,12 @@
       works: ({ status }) => status === 200,
     },
     { address: `https://${mind.zone}/`, works: ({ status }) => status < 400 },
-    { address: onboardingUrlOf(mind.zone), works: memberHostWorks },
+    { address: onboardingUrlOf(mind.zone), works: ({ status }) => status < 500 },
     { address: `https://dash.${mind.zone}/`, works: memberHostWorks },
     ...(mind.firstDeploy
       ? [
           {
-            address: `https://onboarding.${mind.zone}/.well-known/iterate-app`,
+            address: `https://dash.${mind.zone}/.well-known/iterate-app`,
             works: ({ status }: { status: number }) => status === 200,
           },
           {
@@ -815,9 +817,21 @@
 export const formatMindConfigForStdout = (config: Record<string, unknown>) =>
   JSON.stringify(redactMindConfig(config), null, 2);
 
-/** Where setup continues in the browser once the mind is deployed and answering. */
+/** Where setup continues in the browser once the mind is deployed and answering, when the
+ *  mind's config has an onboarding app. */
 export const onboardingUrlOf = (zone: string) => `https://onboarding.${zone}/`;
 
+/** WHERE SETUP GOES ON FOR THIS MIND: its onboarding app when its config serves one (the app's
+ *  description answers 200 to anyone), else its Dash. One read, after the first pages answered. */
+export async function setupHomeOf(zone: string, read: typeof fetch = fetch) {
+  const onboarding = onboardingUrlOf(zone);
+  const described = await read(`${onboarding}.well-known/iterate-app`, {
+    signal: AbortSignal.timeout(10_000),
+    redirect: "manual",
+  }).catch(() => null);
+  return described?.status === 200 ? onboarding : `https://dash.${zone}/`;
+}
+
 /** THE PAGE THE COMMAND OPENS AT THE END OF A DEPLOY, and the line printed right before
  *  "Press Enter to open in browser...".
  *  - On a first deploy, deep-links straight to `https://<controlPlaneHostname>/sign-in/access`
@@ -825,16 +839,21 @@
  *    `auth-worker` redirects to `onboarding.<zone>/` automatically — saving a click through `/sign-in`).
  *  - On a redeploy, opens `https://onboarding.<zone>/` directly (the owner already has a passkey,
  *    and `/sign-in/access` refuses owners who already have one).
+ *  `home` is where setup goes on when it is not the onboarding app (`setupHomeOf`): a first
+ *  deploy then names it as `next`, since the auth Worker sends a first passkey to onboarding.
  *  Always prints the owner email address to sign in with before the Enter prompt. */
 export function setupDestinationOf(mind: {
   controlPlaneHostname: string;
   zone: string;
   ownerEmails: string[];
   firstDeploy: boolean;
+  home?: string;
 }) {
-  const url = mind.firstDeploy
-    ? `https://${mind.controlPlaneHostname}/sign-in/access`
-    : onboardingUrlOf(mind.zone);
+  const onboarding = onboardingUrlOf(mind.zone);
+  const home = mind.home || onboarding;
+  const access = `https://${mind.controlPlaneHostname}/sign-in/access`;
+  const first = home === onboarding ? access : `${access}?${new URLSearchParams({ next: home })}`;
+  const url = mind.firstDeploy ? first : home;
   const emails = mind.ownerEmails.join(" or ");
   const prompt = emails
     ? `Continue setup in your browser (sign in with ${emails}):`
@@ -3054,7 +3073,7 @@
     // after their no, the command still ends every later step, opens nothing and then fails.
     const isFirstDeploy = !deployed || Boolean(resuming?.firstDeploy);
     const primaryZone = config.cloudflare.zones[0] || domain;
-    const setup = setupDestinationOf({
+    let setup = setupDestinationOf({
       controlPlaneHostname,
       zone: primaryZone,
       ownerEmails: config.ownerEmails,
@@ -3099,7 +3118,15 @@
     if (keyLine) p.log.info(keyLine);
     // the pages that did not answer end the command non-zero, with setup's address and no open
     if (unanswered) throw new Error(unanswered);
-    const onboarding = onboardingUrlOf(primaryZone);
+    // setup goes on in the onboarding app when this mind's config has one, else in its Dash
+    const onboarding = await setupHomeOf(primaryZone);
+    setup = setupDestinationOf({
+      controlPlaneHostname,
+      zone: primaryZone,
+      ownerEmails: config.ownerEmails,
+      firstDeploy: isFirstDeploy,
+      home: onboarding,
+    });
     const here =
       input.setup === false
         ? { opened: false, signedIn: false }
@@ -3109,7 +3136,7 @@
             setup,
             onboarding,
           });
-    // signed in, the owner has a passkey: setup is the onboarding page itself
+    // signed in, the owner has a passkey: setup is the onboarding page itself (or the Dash)
     const next = here.signedIn ? { ...setup, url: onboarding } : setup;
     // a browser that went toward setup already is not sent there twice
     if (!here.opened) {