diff --git a/docs/content/_index.md b/docs/content/_index.md index 5ec5eddf..d86d829e 100644 --- a/docs/content/_index.md +++ b/docs/content/_index.md @@ -136,7 +136,7 @@ devvm ships the `docker`, `nix` and `desktop` layers, which you check in the lis ### What does it run on? -`devvm` runs on macOS 13 or newer and on Linux, on arm64 or x86_64. It needs [Lima](https://lima-vm.io/) 2.0 or newer, which runs the VMs with Apple's Virtualization framework on macOS and QEMU on Linux ([backends](docs/backends/_index.md)). Homebrew installs Lima along with devvm, and on Linux, Lima also needs QEMU and access to `/dev/kvm`. [Installing](docs/getting-started/install.md) lists every requirement, and [known limits](docs/using/limits.md#linux-hosts) lists what Linux hosts lack, such as `.git` protection. +`devvm` runs on macOS and on Linux, on arm64 or x86_64. It needs [Lima](https://lima-vm.io/), which runs the VMs with Apple's Virtualization framework on macOS and QEMU on Linux ([backends](docs/backends/_index.md)). Homebrew installs Lima along with devvm, and on Linux, Lima also needs QEMU and access to `/dev/kvm`. [Installing](docs/getting-started/install.md) lists every requirement, and [known limits](docs/using/limits.md#linux-hosts) lists what Linux hosts lack, such as `.git` protection. ### Does the agent run on my machine? diff --git a/docs/content/docs/backends/_index.md b/docs/content/docs/backends/_index.md index e15ca46b..d003ae4c 100644 --- a/docs/content/docs/backends/_index.md +++ b/docs/content/docs/backends/_index.md @@ -10,8 +10,8 @@ A backend is the program that runs devvm's VMs and builds their images. devvm de | | Lima | | --- | --- | | Each project gets | a full VM with a kernel of its own | -| Hosts | macOS 13 or newer, or Linux, on arm64 or x86_64 | -| You need | Lima 2.0 or newer, and on Linux QEMU and access to `/dev/kvm` ([requirements](lima.md#requirements)) | +| Hosts | macOS or Linux, on arm64 or x86_64 | +| You need | Lima, and on Linux QEMU and access to `/dev/kvm` ([requirements](lima.md#requirements), with the versions) | | Confined network tiers | {{< yes >}} yes | | The docker layer | {{< yes >}} yes | | The nix layer | {{< yes >}} yes | diff --git a/docs/content/docs/contributing/_index.md b/docs/content/docs/contributing/_index.md index 96d209a5..33b57120 100644 --- a/docs/content/docs/contributing/_index.md +++ b/docs/content/docs/contributing/_index.md @@ -208,7 +208,7 @@ A new backend gets a design note and a threat check with the security-audit skil devvm's commands follow one set of rules, so that a user who knows a few of them can guess the rest. A bare verb acts on this folder's VM, anything else goes under its noun, and a bare noun shows or lists. A setting shows bare, changes with a value and takes `-g` for what new VMs get. The [cli skill](https://github.com/w3cj/devvm/blob/main/.agents/skills/cli/SKILL.md) holds every rule, with a checklist for adding a command and a review for changing one, and its [judgment.md](https://github.com/w3cj/devvm/blob/main/.agents/skills/cli/judgment.md) explains, with examples, the rules that only a reviewer can check. The reasoning behind most of them is in the [Command Line Interface Guidelines](https://clig.dev/), and Cobra's own mechanics are in [Cobra's docs](https://cobra.dev/docs/). -The tests check every rule that a machine can, as [The CLI rule tests](#the-cli-rule-tests) lists, and `mise run test` runs them. A reviewer checks the rest: where a command goes in the tree, whether it's rm or unX, which commands are settings, whether each argument is the thing acted on, whether a command that deletes asks first and deletes more only with a flag of its own, and the wording of its help and its usage errors. After changing a command's `Use`, `Short`, `Long`, `Example` or flags, run `mise run cli-docs` and commit the [CLI reference](#the-cli-reference) it writes. +The tests check every rule that a machine can, and `mise run test` runs them. The cli skill says which test checks each rule and which rules a reviewer checks by hand, and [The CLI rule tests](#the-cli-rule-tests) says what each test checks. After changing a command's `Use`, `Short`, `Long`, `Example` or flags, run `mise run cli-docs` and commit the [CLI reference](#the-cli-reference) it writes. Each command gets the run's services from one `app`, in `internal/cli/app.go`, which `NewRoot` makes for the run's UI and hands to every command's constructor. The app holds devvm's folders (`dirs`), a test build's overrides, the secrets store, the backends' registry, the shared tools, the environment of the commands on this folder's VM (`vmEnv`) and the image builder of the backend new VMs get (`builder`, the VM environment's `Builder`). It makes each one the first time a command asks for it and keeps that one, or its error, for the rest of the run, so the retention that runs before a command and the command itself share them. A command on this folder's VM runs in `a.env`, which returns the command's failure with its message for an error that isn't one. A new command takes its services from the app rather than making its own. diff --git a/docs/content/docs/getting-started/commands.md b/docs/content/docs/getting-started/commands.md index 0fff9761..3ac777fc 100644 --- a/docs/content/docs/getting-started/commands.md +++ b/docs/content/docs/getting-started/commands.md @@ -81,13 +81,7 @@ Options that take a value also work with an equals sign, such as `--cpus=N`. ### What a new VM gets -Before devvm makes a new VM, it shows a summary of what the VM gets: each toolchain, coding agent and layer with why it gets it, then its size, network tier and ports, and the folder's `devcontainer.json` when there is one. The toolchains are those your folder's files call for, each naming its file, such as `package.json`, and the coding agents and layers are those you chose in `devvm setup`. A layer goes into the VM's image, which devvm builds when it makes the VM. In a terminal, devvm then asks `Customize it? [y/N]`, and pressing Enter makes the VM as the summary shows it. - -When you type y, devvm lists what a new VM can get under three headings, with what the summary showed checked, and you check what you want with the arrow keys and space, then press enter. The toolchains are node, python, rust and go, the coding agents are claude, codex and opencode, and the layers are desktop, docker, nix and your own. A layer a project file calls for, such as nix for a `flake.nix`, names the file but stays unchecked unless you chose it in `devvm setup`. After the list, devvm asks for the VM's network tier and then its CPUs and memory, and pressing Enter keeps each value the summary showed. - -`--tools`, `--agents` and `--layers` choose the parts without the list. Each is the exact list of its part, such as `--tools node,go`, or `none` for none of it, and a part whose flag you leave out gets its default. A part, tier or size that a flag gives is taken as given, and the summary says so. devvm still asks whether to customize the VM while anything is left to choose, and then it greys out in the list each part that a flag gave and skips the questions that `--network`, `--cpus` and `--memory` answered, or a tier you saved. When the flags give everything, devvm asks nothing. Without a terminal, or with `--no-input`, devvm asks nothing and doesn't fail: the VM gets what the summary shows, and the summary ends with the flags that choose others. devvm checks each name before it does anything, and for a name it doesn't know, it suggests the closest one. [What a new VM gets](../using/images.md#what-a-new-vm-gets) has the details. - -If you don't give `--network`, the summary shows the tier you saved with `devvm network -g`, such as `devvm network -g internet`, or with `devvm setup`, and allowlist until you save one. When you customize the VM, devvm asks for the tier, and pressing Enter gives the one the summary showed. [Choosing a tier](../safety/network.md#choosing-a-tier) covers the VMs that can only be open. +Before devvm makes a new VM, it shows a summary of what the VM gets, and in a terminal it asks `Customize it? [y/N]`, so pressing Enter makes the VM as the summary shows it. When you type y, devvm lists the toolchains, node, python, rust and go, the coding agents, claude, codex and opencode, and the layers, desktop, docker, nix and your own, and then asks for the VM's network tier, its CPUs and its memory. A layer goes into the VM's image, which devvm builds when it makes the VM. `--tools`, `--agents`, `--layers`, `--network`, `--cpus` and `--memory` choose beforehand, such as `--tools node,go`. [What a new VM gets](../using/images.md#what-a-new-vm-gets) says what the summary holds, what each part's default is, which questions the flags skip and what happens without a terminal, and [choosing a tier](../safety/network.md#choosing-a-tier) covers the tier's question and the VMs that can only be open. A folder with a `.devcontainer/devcontainer.json` or `.devcontainer.json` gets the VM that file describes, as far as devvm supports it. That covers its image, ports, environment and commands, and the features devvm has layers for, as [`devcontainer.json`](../using/devcontainer.md) explains. The options you give take priority over the file. @@ -111,7 +105,7 @@ devvm deletes the VM made for an earlier folder at this path only after you conf ### A folder made again -A VM belongs to the folder it was made for, which devvm knows by its path and by the folder itself ([one VM per folder](../internals/security.md#one-vm-per-folder)). When that folder was deleted and a new one made at the same path, devvm, `devvm restart` and `devvm tools` refuse the VM. Two commands deal with it, and each acts only after you confirm in a terminal: +A VM belongs to the folder it was made for, which devvm knows by its path and by the folder itself ([one VM per folder](../internals/security.md#one-vm-per-folder)). When that folder was deleted and a new one made at the same path, every command that opens, stops or changes the VM refuses it, such as `devvm`, `devvm stop`, `devvm restart` and `devvm tools`. Two commands deal with it, and each acts only after you confirm in a terminal: - `devvm rm` deletes the VM and never exports its history, because its folder is gone. The VM may hold that project's work, so `--force` never answers this question. - `devvm adopt` gives the VM to this folder, with its files, secrets and allowlist. Its `.git` protection starts again, as if `.git` had just appeared. `devvm adopt --force` gives it without asking, which `devvm adopt` needs when there's no terminal. diff --git a/docs/content/docs/getting-started/install.md b/docs/content/docs/getting-started/install.md index bfbc04fe..66d0e71c 100644 --- a/docs/content/docs/getting-started/install.md +++ b/docs/content/docs/getting-started/install.md @@ -38,9 +38,9 @@ devvm runs its VMs on [Lima](../backends/lima.md#requirements), its default [bac | You need | To check | To get it | The install script | | --- | --- | --- | --- | -| macOS 13 or newer, on arm64 or x86_64 | `sw_vers` and `uname -m` | | {{< no >}} doesn't | +| macOS at [Lima's minimum](../backends/lima.md#requirements), on arm64 or x86_64 | `sw_vers` and `uname -m` | | {{< no >}} doesn't | | 8 GiB of memory and 4 CPUs, recommended | `sysctl hw.memsize hw.ncpu` | | {{< no >}} doesn't | -| Lima 2.0 or newer | `limactl --version` | `brew install lima`, or [Lima's install guide](https://lima-vm.io/docs/installation/) | {{< yes >}} offers it: Homebrew's when you have Homebrew, otherwise Lima's latest release into `~/.local` | +| Lima at [its minimum](../backends/lima.md#requirements) | `limactl --version` | `brew install lima`, or [Lima's install guide](https://lima-vm.io/docs/installation/) | {{< yes >}} offers it: Homebrew's when you have Homebrew, otherwise Lima's latest release into `~/.local` | | OpenSSH 8.7 or newer, for ssh and editors by name | `ssh -V` | macOS 13's has it | {{< no >}} doesn't | | Docker Desktop, only for `--from` with an image only Docker has | `docker version` | Docker Desktop | {{< no >}} doesn't | @@ -51,7 +51,7 @@ devvm runs its VMs on [Lima](../backends/lima.md#requirements), its default [bac | --- | --- | --- | --- | | Linux on arm64 or x86_64 | `uname -m` | | {{< no >}} doesn't | | 8 GiB of memory and 4 CPUs, recommended | `free -g` and `nproc` | | {{< no >}} doesn't | -| Lima 2.0 or newer | `limactl --version` | `brew install lima`, or [Lima's install guide](https://lima-vm.io/docs/installation/) | {{< yes >}} offers it: Homebrew's when you have Homebrew, otherwise Lima's latest release into `~/.local` | +| Lima at [its minimum](../backends/lima.md#requirements) | `limactl --version` | `brew install lima`, or [Lima's install guide](https://lima-vm.io/docs/installation/) | {{< yes >}} offers it: Homebrew's when you have Homebrew, otherwise Lima's latest release into `~/.local` | | QEMU | `qemu-img --version` | your package manager: apt, dnf, pacman or zypper | {{< yes >}} offers it, with sudo | | Access to `/dev/kvm` | `ls -l /dev/kvm` | `sudo usermod -aG kvm $USER`, then log out and back in | {{< yes >}} offers it, with sudo | | OpenSSH 8.7 or newer, for ssh and editors by name | `ssh -V` | Ubuntu 22.04's has it | {{< no >}} doesn't | @@ -62,7 +62,7 @@ devvm runs its VMs on [Lima](../backends/lima.md#requirements), its default [bac The Homebrew formula installs Lima along with devvm. ssh and editors reach VMs through devvm's ssh config, and OpenSSH versions older than 8.7 refuse its `PermitRemoteOpen` ([SSH access by name](../using/ssh.md#ssh-access-by-name)). Docker on this machine is optional, because only `--from` with an [image only Docker has](../using/from.md#images-only-docker-has) needs it. -devvm also runs on a smaller machine, because it fits base to the machine. Base asks for 4 CPUs and 8 GiB of memory. On a machine with fewer than 4 CPUs, base gets as many CPUs as the machine has, and when 8 GiB would leave the machine less than 2 GiB of its own, base gets half of the machine's memory, which is 4 GiB on an 8 GiB machine. The VMs made from base get the same unless you give them a size, as [size and ports](../using/ports-size.md#size-and-ports) explains. When devvm builds base on such a machine, it says how many CPUs and how much memory base gets. `devvm size -g` sets the size that new VMs get instead, and `devvm doctor` warns when this machine has less than 8 GiB of memory or fewer than 4 CPUs. +devvm also runs on a smaller machine, because it gives base fewer CPUs and less memory there, and the VMs made from base get the same unless you give them a size, as [size and ports](../using/ports-size.md#size-and-ports) explains. `devvm doctor` warns when this machine has less than 8 GiB of memory or fewer than 4 CPUs. Your first VM needs at least 8 GiB of free disk space, because devvm builds the base image first and then the VM's own image and shared tools. Each VM then grows its own disk as you work in it, and the disk never shrinks. devvm checks the free space before each build and each new VM, and refuses when it's low ([free space](../using/ports-size.md#free-space)). diff --git a/docs/content/docs/internals/design.md b/docs/content/docs/internals/design.md index 62c71926..fd039b1f 100644 --- a/docs/content/docs/internals/design.md +++ b/docs/content/docs/internals/design.md @@ -148,7 +148,7 @@ A new VM gets what the project's `devcontainer.json` says, as far as devvm does A VM's network is one of four tiers, `open`, `internet`, `allowlist` and `none`, from the lowest to the highest ([what each reaches](../safety/network.md#network-tiers)). The design keeps two things: every VM's requests go through its own proxy, whatever its tier, and only the open tier ever runs a VM unconfined. -**What it's built from:** `netpolicy.Tier`, in the VM's `net` section as `tier`. An unknown tier fails to read (`Tier.UnmarshalJSON`), and `TierOf` reads a section it can't read as `none`, never as `open`; a section without a tier reads as `allowlist`, with no migration of the old `on` field. `Tier.Net` maps the tier to the backend's confinement: `NetProxy` for every tier but open, and `NetDirect` with the proxy's port and password for open (`Confinement.GuestProxy`). `netpolicy.Policies` gives each tier its policies (`PolicySet`), and `Prepare` writes them into the proxy's config: `builtin_policies` and `policies` as before, `deny_policies` for the user's files on internet and none, whose allows the proxy drops as it reads them, and `open` for the open tier, which allows every host and address with no floor and takes no policy at all (`Config.check`). Every tier's proxy has the VM's CAs and its bindings file, an open VM's included, and every VM's setup sends the same placeholders and redacted copies (`stageSecrets`), so no VM holds a real secret and the tier decides only the confinement and the rules. A running VM keeps the confinement it started with: one made open while it runs confined stays on `NetProxy` until its next start, with an open proxy. Every `Prepare` reads the tier from the VM's state as it is then, so a command that read the state before a tier change never starts the proxy with the tier before. +**What it's built from:** `netpolicy.Tier`, in the VM's `net` section as `tier`. An unknown tier fails to read (`Tier.UnmarshalJSON`), and `TierOf` reads a section it can't read as `none`, never as `open`; a section without a tier reads as `allowlist`. `Tier.Net` maps the tier to the backend's confinement: `NetProxy` for every tier but open, and `NetDirect` with the proxy's port and password for open (`Confinement.GuestProxy`). `netpolicy.Policies` gives each tier its policies (`PolicySet`), and `Prepare` writes them into the proxy's config: `builtin_policies` for the built-in policies and `policies` for your files on the allowlist tier, `deny_policies` for the user's files on internet and none, whose allows the proxy drops as it reads them, and `open` for the open tier, which allows every host and address with no floor and takes no policy at all (`Config.check`). Every tier's proxy has the VM's CAs and its bindings file, an open VM's included, and every VM's setup sends the same placeholders and redacted copies (`stageSecrets`), so no VM holds a real secret and the tier decides only the confinement and the rules. A running VM keeps the confinement it started with: one made open while it runs confined stays on `NetProxy` until its next start, with an open proxy. Every `Prepare` reads the tier from the VM's state as it is then, so a command that read the state before a tier change never starts the proxy with the tier before. **Rules:** `**` covers addresses as well as names, and `:*` any port 1 to 65535. Neither lifts the floor, because only an address rule can (`policy.addrAllowed`), so the internet tier's `**:*` reaches every public host and address and no internal one. diff --git a/docs/content/docs/internals/images.md b/docs/content/docs/internals/images.md index f83fdfce..8e6dbe6a 100644 --- a/docs/content/docs/internals/images.md +++ b/docs/content/docs/internals/images.md @@ -16,7 +16,7 @@ devvm builds each image in a VM of its own, and that VM then is the image: While the VM is being built, it already has the image's final name, so devvm holds a lock for each image it builds, `~/.local/share/devvm/images/locks/`, from before it looks for the image until the record is written. Another devvm that builds the same image waits for that lock and says so (`image_build_waiting`) after 3 seconds, and once it gets the lock, it finds the image built. An image without a record is unfinished only when its lock is free, so devvm then deletes it and builds it again (`image_leftover`). While the lock is held, the image is `building`, and `devvm gc`, `devvm rebuild` and `devvm images rm` leave it alone (`image_building`). The lock is an OS lock on an open file, which the system releases when its devvm ends, however it ends, so a crash never leaves an image looking like it's still being built. devvm deletes the lock file together with the image's folder. -Nothing from the host is mounted into a build, because layer scripts run third-party installers, which mustn't see your files. Behind a company proxy, a build on Lima goes through a proxy of devvm's on this machine for that build alone, which goes through the company proxy. The scripts' commands get only that proxy's address, with a password devvm makes for the build, so neither the build nor its image ever has the company proxy's password ([a company proxy](design.md#a-company-proxy)). base gets its 4 CPUs, or as many as the host has when it has fewer. It gets its 8 GiB of memory, or half the host's memory when 8 GiB would leave the host less than 2 GiB. The images built on base, and their VMs, keep that size ([base's size](#bases-size)). +Nothing from the host is mounted into a build, because layer scripts run third-party installers, which mustn't see your files. Behind a company proxy, a build on Lima goes through a proxy of devvm's on this machine for that build alone, which goes through the company proxy. The scripts' commands get only that proxy's address, with a password devvm makes for the build, so neither the build nor its image ever has the company proxy's password ([a company proxy](design.md#a-company-proxy)). A build gets base's size fitted to the host, which the images built on base, and their VMs, keep ([base's size](#bases-size)). ## Keys and caching diff --git a/docs/content/docs/internals/install.md b/docs/content/docs/internals/install.md index 6afe2104..e1a35145 100644 --- a/docs/content/docs/internals/install.md +++ b/docs/content/docs/internals/install.md @@ -73,8 +73,8 @@ These are the keys: | Key | Missing | Fix | | --- | --- | --- | | `os`, `arch` | a host the backend runs on | none | -| `macos` | macOS 13 or newer | none | -| `lima` | Lima 2.0 or newer, working | `brew install lima` (`upgrade`, `reinstall`) with Homebrew, otherwise none | +| `macos` | macOS at the backend's [minimum](../backends/lima.md#requirements) | none | +| `lima` | Lima at its [minimum](../backends/lima.md#requirements), working | `brew install lima` (`upgrade`, `reinstall`) with Homebrew, otherwise none | | `qemu` | QEMU, on Linux | your package manager's install (apt, dnf, pacman or zypper), otherwise none | | `kvm` | `/dev/kvm`, on Linux | none: turn on virtualization | | `kvm-access` | access to `/dev/kvm` | `sudo usermod -aG kvm USER`, then log in again | diff --git a/docs/content/docs/internals/network.md b/docs/content/docs/internals/network.md index 79cc1613..8f5c603d 100644 --- a/docs/content/docs/internals/network.md +++ b/docs/content/docs/internals/network.md @@ -119,15 +119,15 @@ On the allowlist tier, a VM's proxy reads these policies, in this order, as one - **none:** the built-in policies of the VM's agents (`shared-tools/claude.policy`, `codex.policy`, `opencode.policy`) and no other built-in one, then `secrets.policy`, then your files as denies alone. The VM's links come before every rule, as on every tier. - **open:** no policy at all. The proxy's config has `"open": true`, which allows every host and address on every port, internal ones and this machine's included, and a config with `open` and any policy is refused. The floor doesn't apply, and a name that the host can't resolve goes to the company proxy unjudged, as it does for a build. -| Policy | Rules for | +| Policy | Read for | | --- | --- | -| `layers/base.policy` (built in) | every VM: OS packages, mise's version lists, GitHub | -| `shared-tools/.policy` (built in) | each shared tool in the VM's image (`node`, `claude`, …): its registries, downloads and APIs | -| `layers/.policy` (built in) | each built-in layer in the VM's image: `docker`'s has Docker's packages and the container registries Docker Hub and ghcr.io, and `nix`'s has Nix's binary cache, channels and flake registry | +| `layers/base.policy` (built in) | every VM | +| `shared-tools/.policy` (built in) | each shared tool in the VM's image | +| `layers/.policy` (built in) | each built-in layer in the VM's image | | `~/.config/devvm/layers/.policy` | each of your layers in the VM's image | -| `~/.config/devvm/policy` | every VM: your own rules (`devvm network allow`, `deny` and `rm` with `-g`) | -| `~/.local/share/devvm/vms//policy` | that VM only (`devvm network allow`, `deny` and `rm`) | -| `~/.local/share/devvm/vms//run/secrets.policy` | the hosts of the VM's secrets and logins, and of its agents' [token endpoints](#logins-made-in-a-vm), on port 443 (devvm writes it) | +| `~/.config/devvm/policy` | every VM | +| `~/.local/share/devvm/vms//policy` | that VM only | +| `~/.local/share/devvm/vms//run/secrets.policy` | every VM, which devvm writes with the hosts of the VM's secrets and logins and of its agents' [token endpoints](#logins-made-in-a-vm) | The built-in policies are paths in devvm's own files, `assets/` in the repo, which are [built into the binary](install.md#devvms-own-files), and no copy of them is ever on disk. `netpolicy.Policies` lists both kinds for a VM: the built-in ones go in the proxy's config as names in `builtin_policies`, and your files as paths in `policies`. The proxy reads the built-in ones from the binary once, as it starts, ahead of your files in the list, and never again, so only an upgrade of devvm changes them, and an upgrade starts every VM's proxy again because the binary changed. A built-in policy that's missing, or that holds a line that isn't a rule, is a bug in devvm, so the proxy refuses to start rather than run with fewer rules than devvm meant, and devvm stops the VM as for any proxy that doesn't start. A missing file of yours, on the other hand, has no rules. `devvm network` reads the built-in policies from the binary too, and it labels each with its name (`# devvm: layers/base.policy`, and `"builtin"` with `--json`) where it shows your files' paths. Both lists are in the config that a proxy started with, so a change to either starts the proxy again. diff --git a/docs/content/docs/internals/overview.md b/docs/content/docs/internals/overview.md index 2e59b960..46d3fc75 100644 --- a/docs/content/docs/internals/overview.md +++ b/docs/content/docs/internals/overview.md @@ -25,7 +25,7 @@ flowchart TD before -. "interrupted" .-> undo["deletes the VM and what
devvm made for it,
and unlocks .git"] ``` -1. devvm checks everything the new VM needs before it builds anything, because a build can take minutes. That covers the folder, its toolchains, agents and layers, which it shows in a list in a terminal when you give none of `--tools`, `--agents` and `--layers` ([what a new VM gets](../using/images.md#what-a-new-vm-gets)), the size, the ports, the network tier, which it asks for when you give no `--network` and new VMs' tier is `ask`, the SSH agent, the backend's [features](backends.md#features) and what the folder's `devcontainer.json` says. Last, when the VM gets an agent and devvm saved an export of agents' history for this folder before, devvm offers the newest one, asking in a terminal with no as the default (`history_import_ask`) and naming `devvm history import` without one (`history_import_later`). Before any of it, devvm takes the folder's [creation lock](#locks), which it holds until it has recorded that it made the VM in step 5. +1. devvm checks everything the new VM needs before it builds anything, because a build can take minutes. That covers the folder, its toolchains, agents and layers, which it shows in a list in a terminal when you give none of `--tools`, `--agents` and `--layers` ([what a new VM gets](../using/images.md#what-a-new-vm-gets)), the size, the ports, the network tier ([choosing a tier](../safety/network.md#choosing-a-tier)), the SSH agent, the backend's [features](backends.md#features) and what the folder's `devcontainer.json` says. Last, when the VM gets an agent and devvm saved an export of agents' history for this folder before, devvm offers the newest one, asking in a terminal with no as the default (`history_import_ask`) and naming `devvm history import` without one (`history_import_later`). Before any of it, devvm takes the folder's [creation lock](#locks), which it holds until it has recorded that it made the VM in step 5. 2. When the VM gets shared tools and the [daily check](../using/images.md#shared-tools) is due, devvm checks for newer versions of them. 3. devvm builds the image if it isn't built yet ([building](images.md#building)), then the VM's [shared tools](../using/images.md#shared-tools) that the share lacks. 4. devvm writes the VM's state, with the network choice in it, before it makes the VM. If a later step fails, the VM never starts without its network choice. devvm also clears what an earlier VM of this folder that was deleted some other way left behind: it stops that VM's proxy and link session and deletes the VM's folder in its data folder, with its own rules, its run files and its logs. @@ -112,10 +112,10 @@ The local branches are named `saved//`, after the remote, and de ## A folder made again -A VM's state records its project folder's path (`dir`) and the folder's identity (`folder`), which [one VM per folder](security.md#one-vm-per-folder) describes. When either differs from the folder you're in, the folder was deleted and made again, or another repo was cloned where the old one was. devvm then refuses the VM in every command that opens, stops or changes it (`vm_other_folder`), and only `devvm rm` and `devvm adopt` act on it. Each of them asks first, so without a terminal each one refuses (`vm_other_folder_rm`, `vm_other_folder_adopt`), unless `devvm adopt --force`: +A VM's state records its project folder's path (`dir`) and the folder's identity (`folder`), which [one VM per folder](security.md#one-vm-per-folder) describes. When either differs from the folder you're in, the folder was deleted and made again, or another repo was cloned where the old one was. devvm then refuses the VM in every command that opens, stops or changes it (`vm_other_folder`), and only `devvm rm` and `devvm adopt` act on it. Each of them asks first, so without a terminal each one refuses (`vm_other_folder_rm`, `vm_other_folder_adopt`), unless `devvm adopt --force`. [A folder made again](../getting-started/commands.md#a-folder-made-again) says what each one does, and devvm does it as follows: -- `devvm rm` asks whether to delete the VM, which may hold that project's work (`delete_other_folder_vm`), and `--force` never answers it. It then deletes the VM without exporting history or checking a clone, because the VM's folder is gone. -- `devvm adopt` asks whether to give this folder the VM's files, secrets and allowlist (`adopt_vm`). It then records this folder's path and identity in the VM's state and clears the inode of `.git` it recorded, so the next launch locks `.git` as if it had just appeared (`vm_adopted`). In a folder the VM already belongs to, it changes nothing (`vm_already_here`). +- `devvm rm` asks with `delete_other_folder_vm`, then deletes the VM without checking a clone, because the VM's folder is gone. +- `devvm adopt` asks with `adopt_vm`, then records this folder's path and identity in the VM's state and clears the inode of `.git` it recorded, so the next launch locks `.git` as if it had just appeared (`vm_adopted`). In a folder the VM already belongs to, it changes nothing (`vm_already_here`). ## A moved folder @@ -143,7 +143,7 @@ devvm finds a folder's VM by the state that records the folder's physical path ( The lookup stops before the home folder, compared by its physical path, and before the filesystem root. Those folders are refused as project folders anyway, but a VM made for one with `--unsafe-folder` would otherwise open in every folder below it. Using a parent's VM changes nothing about what it mounts, because the current folder is already inside its project folder at the same path. -Every command that acts on the folder's VM, `devvm` included, decides in one place which VM the folder uses, from what it found and the command's `--here` or `--parent`, so they all decide the same way, with or without a terminal. By default, the folder's own VM wins when it has a state file or its backend has the VM. Otherwise the parent's VM is used, unless a repo of its own is in between, and otherwise the folder has none. `--here` takes the folder's own VM and never looks at the parents. `--parent` looks at the parents even when the folder has a VM of its own, takes the parent's VM across a repo of its own, and fails when no parent has a VM (`no_parent_vm`). A command that uses a parent's VM first names the VM and its folder (`using_parent_vm`) and asks nothing more, except `devvm rm` and the commands that give the VM more access. `devvm rm` then asks before deleting a parent's VM (`delete_parent_vm`), with or without `-f`, and without a terminal it refuses (`rm_parent_vm`). The commands that give a parent's VM more access do the same. They are `devvm secret use`, `devvm ssh-agent` with `on` or `devvm`, `devvm network` with a lower tier, such as `devvm network open`, `devvm network allow`, `devvm network rm` of a deny and `devvm git-protect off`, which ask before changing the VM (`widen_parent_vm`, `[y/N]`) and refuse without a terminal (`widen_parent_vm_refused`). They ask because the parent folder's project chose its VM's access, and a subfolder can be a project of its own that only happens to sit inside it. `devvm adopt` looks only for the VM of this folder's own path, and `devvm --clone` skips the lookup, as `--here` does, so it makes the folder's own VM. devvm passes the current folder to the backend as the shell's working folder, and `devvm host` and `devvm code` use it as the folder to open. For a `--clone` VM, devvm first checks in the VM that the clone has the folder, and uses the clone's top folder when it doesn't. +Every command that acts on the folder's VM, `devvm` included, decides in one place which VM the folder uses, from what it found and the command's `--here` or `--parent`, so they all decide the same way, with or without a terminal. By default, the folder's own VM wins when it has a state file or its backend has the VM. Otherwise the parent's VM is used, unless a repo of its own is in between, and otherwise the folder has none. `--here` takes the folder's own VM and never looks at the parents. `--parent` looks at the parents even when the folder has a VM of its own, takes the parent's VM across a repo of its own, and fails when no parent has a VM (`no_parent_vm`). A command that uses a parent's VM first names the VM and its folder (`using_parent_vm`) and asks nothing more, except `devvm rm` and the commands that give the VM more access. `devvm rm` then asks before deleting a parent's VM (`delete_parent_vm`), with or without `-f`, and without a terminal it refuses (`rm_parent_vm`). The commands that give a parent's VM more access, which [a subfolder](../getting-started/commands.md#a-subfolder) lists, ask before changing the VM (`widen_parent_vm`, `[y/N]`) and refuse without a terminal (`widen_parent_vm_refused`). They ask because the parent folder's project chose its VM's access, and a subfolder can be a project of its own that only happens to sit inside it. `devvm adopt` looks only for the VM of this folder's own path, and `devvm --clone` skips the lookup, as `--here` does, so it makes the folder's own VM. devvm passes the current folder to the backend as the shell's working folder, and `devvm host` and `devvm code` use it as the folder to open. For a `--clone` VM, devvm first checks in the VM that the clone has the folder, and uses the clone's top folder when it doesn't. On the way up, devvm also notes the nearest folder below the parent's that has a `.git` of its own, a folder or a file, starting with the current folder. When there is one, the current folder belongs to a separate repo, so without `--parent` the parent's VM is passed over. `devvm` then makes the folder's own VM without asking, and every other command fails with `no_vm`. diff --git a/docs/content/docs/safety/_index.md b/docs/content/docs/safety/_index.md index a66f4dd1..b2befd37 100644 --- a/docs/content/docs/safety/_index.md +++ b/docs/content/docs/safety/_index.md @@ -60,7 +60,7 @@ flowchart TB | Your agents' settings and logins (skills, settings, logins) | The VM mounts the folders of devvm's agent store read-only and gets copies of its files, but never your agents' history, and never the agents' own files in your home folder ([details](../using/coding-agents.md#devvms-agent-store)). | | The rest of your home folder, other projects | The VM doesn't mount them. | | Your SSH keys | Only with `devvm ssh-agent on`, and only while you're connected. With `devvm ssh-agent devvm`, the VM can use only the keys you added to devvm's own agent ([details](../using/ssh.md#agent-forwarding)). | -| The network | On every tier but open, the VM reaches only its proxy on this machine, which lets it reach what its tier allows: every public host on the internet tier, the allowlisted hosts on the allowlist tier, and only its agents' and secrets' hosts and its links on the none tier. On the open tier it reaches everything this machine reaches, including this machine's own services on `localhost` ([details](network.md#network-tiers)). | +| The network | On every tier but open, the VM reaches only its proxy on this machine, which lets it reach what [its tier](network.md#network-tiers) allows. On the open tier it reaches everything this machine reaches, including this machine's own services on `localhost` ([details](network.md#network-tiers)). | | Your secrets | Your GitHub token, Claude Code's token, Codex and opencode logins and Claude Code's MCP secrets stay on this machine on every network tier, and the proxy puts them into requests ([details](network.md#secrets)). | > [!NOTE] diff --git a/docs/content/docs/using/ports-size.md b/docs/content/docs/using/ports-size.md index 24f5dd32..63a9aa27 100644 --- a/docs/content/docs/using/ports-size.md +++ b/docs/content/docs/using/ports-size.md @@ -7,7 +7,7 @@ This page covers the ports a VM forwards to this machine and the CPUs, memory an ## Size and ports -A new VM gets its image's size unless you set one with `--cpus`, `--memory` and `--disk`, as in `devvm --cpus 6`. For `base` that's 4 CPUs, 8 GiB of memory and a 100 GiB disk. On a machine with fewer than 4 CPUs, base gets as many CPUs as the machine has, and when 8 GiB would leave the machine less than 2 GiB of its own, base gets half of the machine's memory. When devvm builds base on such a machine, it says how many CPUs and how much memory base gets, and `devvm size -g` sets the size that new VMs get instead. +A new VM gets its image's size unless you set one with `--cpus`, `--memory` and `--disk`, as in `devvm --cpus 6`. For `base` that's 4 CPUs, 8 GiB of memory and a 100 GiB disk. On a machine with fewer than 4 CPUs, base gets as many CPUs as the machine has, and when 8 GiB would leave the machine less than 2 GiB of its own, base gets half of the machine's memory, which is 4 GiB on an 8 GiB machine. When devvm builds base on such a machine, it says how many CPUs and how much memory base gets, and `devvm size -g` sets the size that new VMs get instead. - `--cpus` takes a whole number. `--memory` and `--disk` take a size in GiB, written `16`, `16G` or `16GiB`, and decimals are allowed. - What the flags leave unset comes from the `[size]` table of [`config.toml`](settings.md#configtoml) when it sets it, else from what `devvm size -g` and `devvm setup` saved ([choosing new VMs' size](#choosing-new-vms-size)).