iterate deploy with no flag makes a mind from git.iterate.com, and waits for the Dash (#3)
jonas, 2026-11-26 15:18 UTC · 83650c4cac791095aff7e1f153eefb6fc50a1bbd · parent e194fc9
4 files changed
- M core/lib/src/cli/README.md
- M core/lib/src/cli/cli.ts
- M core/lib/src/cli/deploy.test.ts
- M core/lib/src/cli/deploy.ts
M core/lib/src/cli/README.md
@@ -180,9 +180,15 @@ keeps its own. 7. **The kernel.** Which one a deploy builds: - **A new mind:** the repo that `--kernel-repo <address>` names, at its `main` - (`--ref <branch>` takes another branch). The mind clones the same repo at birth, so its own + (`--ref <branch>` takes another branch). With no flag it is iterate's own, + `https://git.iterate.com/repos/kernel`. The mind clones the same repo at birth, so its own `/repos/kernel` holds the commit that it runs. The command fetches it into `${XDG_CACHE_HOME:-~/.cache}/iterate/kernel` with git, sending no credential. + The mind's `/repos/config` is cloned at birth from `--config-repo <address>`, with no flag + from `https://git.iterate.com/repos/config-template`, and each repo that its package.json + names (`"@repos/stdlib": "../stdlib"`) from beside that address. The mind clones with no + credential. So before anything changes the command asks each of those addresses for its + `main` with none, and stops with the ones that did not answer. - **A mind that is there:** its own `/repos/kernel`, read with the Cloudflare access the command holds. Nothing is fetched from outside the mind. So a deploy for another reason builds the same kernel again, and a new kernel arrives by a pull or a merge into that repo @@ -275,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/cli.ts
@@ -387,13 +387,13 @@ .string() .optional() .describe( - "For a new mind: the https address of the kernel repo, such as https://git.<a mind's domain>/repos/kernel. The deploy builds it, and the mind clones it at birth as its own /repos/kernel. Refused over a mind that is there, whose own /repos/kernel is what a deploy builds", + "For a new mind: the https address of the kernel repo (default: https://git.iterate.com/repos/kernel, or none with --source). The deploy builds it, and the mind clones it at birth as its own /repos/kernel. Refused over a mind that is there, whose own /repos/kernel is what a deploy builds", ), configRepo: z .string() .optional() .describe( - "For a new mind: the https address of the repo that its config starts as, such as https://git.<a mind's domain>/repos/config-template. The mind clones it at birth as its own /repos/config, and the repos that its package.json names from beside it. none starts the mind with empty repos, which get their code by pushes. Refused over a mind that is there", + "For a new mind: the https address of the repo that its config starts as (default: https://git.iterate.com/repos/config-template). The mind clones it at birth as its own /repos/config, and the repos that its package.json names from beside it. none starts the mind with empty repos, which get their code by pushes. Refused over a mind that is there", ), zones: z .string() @@ -427,7 +427,7 @@ .string() .optional() .describe( - "A checkout of iterate's kernel on this computer to deploy, whatever it holds, over any mind (default: none; a new mind's kernel is the repo that --kernel-repo names, and a mind that is there builds its own /repos/kernel)", + "A checkout of iterate's kernel on this computer to deploy, whatever it holds, over any mind (default: none; a new mind's kernel is the repo that --kernel-repo names, iterate's own with no flag, and a mind that is there builds its own /repos/kernel)", ), ref: z .string()
M core/lib/src/cli/deploy.test.ts
@@ -32,6 +32,9 @@ identityKeyLineOf, isColorEnabled, isInteractiveEnv, + birthReposOf, + birthReposRefused, + NEW_MIND_REPOS, kernelPlanOf, mindConfigIn, onboardingUrlOf, @@ -40,6 +43,7 @@ pickDomain, planArgsOf, setupDestinationOf, + setupHomeOf, signInPageOf, PNPM_COMPAT_ENV, pnpmCommandOf, @@ -189,6 +193,108 @@ expect(() => reposOf({})).toThrow("A new mind needs --config-repo"); }); +test("a deploy with no flag takes a new mind's kernel and config from iterate's own mind; a flag names another address, and a kernel from a checkout has none", () => { + expect(birthReposOf({})).toEqual({ + kernelRepo: "https://git.iterate.com/repos/kernel", + configRepo: "https://git.iterate.com/repos/config-template", + }); + expect( + birthReposOf({ kernelRepo: "https://git.ada-labs.com/repos/kernel", configRepo: "none" }), + ).toEqual({ kernelRepo: "https://git.ada-labs.com/repos/kernel", configRepo: "none" }); + expect(birthReposOf({ source: "/work/kernel" })).toEqual({ + kernelRepo: undefined, + configRepo: "https://git.iterate.com/repos/config-template", + }); + // so a new mind with no flag has a kernel to build and two repos to clone + const config = deployConfigOf({ + accountId: "0".repeat(32), + domain: "ada-labs.com", + owner: "ada@example.org", + ...birthReposOf({}), + }); + expect(config.repos).toEqual([ + { path: "/repos/kernel", origin: NEW_MIND_REPOS.kernel }, + { path: "/repos/config", origin: NEW_MIND_REPOS.config }, + ]); + expect(kernelPlanOf({}, { deployed: false, begunWith: NEW_MIND_REPOS.kernel })).toEqual({ + kind: "address", + origin: "https://git.iterate.com/repos/kernel", + ref: "main", + }); +}); + +test("the repos of a birth that a new mind could not clone are named before anything changes: the two of the deploy, and each that the config's package.json names beside it", async () => { + const path = mkdtempSync(join(tmpdir(), "birth-repos-")); + using host = { path, [Symbol.dispose]: () => rmSync(path, { recursive: true, force: true }) }; + const repo = (name: string, files: Record<string, string>) => { + const dir = join(host.path, name); + mkdirSync(dir, { recursive: true }); + const git = (...args: string[]) => + execFileSync("git", ["-c", "user.name=t", "-c", "user.email=t@example.org", ...args], { + cwd: dir, + stdio: "pipe", + }); + git("init", "-q", "-b", "main"); + for (const [path, text] of Object.entries(files)) writeFileSync(join(dir, path), text); + git("add", "."); + git("commit", "-q", "-m", "first"); + return `file://${dir}`; + }; + const kernel = repo("kernel", { "README.md": "kernel" }); + repo("stdlib", { "README.md": "stdlib" }); + const template = repo("config-template", { + "package.json": JSON.stringify({ + dependencies: { "@repos/stdlib": "../stdlib", "@repos/dash": "../dash", zod: "4" }, + }), + }); + const cache = join(host.path, "cache"); + + const refused = await birthReposRefused( + [ + { path: "/repos/kernel", origin: kernel }, + { path: "/repos/config", origin: template }, + ], + cache, + ); + // stdlib is there; dash, which the template names, is not + expect(refused).toHaveLength(1); + expect(refused[0]).toContain(`file://${join(host.path, "dash")} (`); + + repo("dash", { "README.md": "dash" }); + expect( + await birthReposRefused( + [ + { path: "/repos/kernel", origin: kernel }, + { path: "/repos/config", origin: template }, + ], + cache, + ), + ).toEqual([]); + // a config repo that is not there is named itself, and so is a kernel + const none = await birthReposRefused( + [ + { path: "/repos/kernel", origin: `file://${join(host.path, "no-kernel")}` }, + { path: "/repos/config", origin: `file://${join(host.path, "no-config")}` }, + ], + cache, + ); + expect(none.map((line) => line.split(" (")[0])).toEqual([ + `file://${join(host.path, "no-kernel")}`, + `file://${join(host.path, "no-config")}`, + ]); + // repos that start empty are cloned from nowhere + expect( + await birthReposRefused( + [ + { path: "/repos/kernel", origin: null }, + { path: "/repos/config", origin: null }, + ], + cache, + ), + ).toEqual([]); + // about 30 git processes: a loaded computer needs more than the 5 s a test has +}, 60_000); + test("the kernel that a deploy builds: the checkout that --source names, the address that --kernel-repo names for a new mind, and for a mind that is there its own kernel repo", () => { const kernelRepo = "https://git.ada-labs.com/repos/kernel"; const newMind = { deployed: false, begunWith: null }; @@ -1105,6 +1211,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); @@ -1727,6 +1852,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/"; @@ -1735,7 +1876,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([ @@ -1745,7 +1886,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 @@ -1761,10 +1902,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); @@ -1778,7 +1920,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
Not shown: the change is larger than this page shows. A clone has it.