iterate deploy with no flag makes a mind: its kernel and config come from git.iterate.com
Jonas Templestein, 2026-11-26 14:32 UTC · 7b2caff9cd08e595c95efe0132c4c9acb10db1ed · 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
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, @@ -187,6 +190,107 @@ "--kernel-repo git@ada-labs.com:kernel is no address", ); 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([]); }); 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", () => {
M core/lib/src/cli/deploy.ts
Not shown: the change is larger than this page shows. A clone has it.