Files

2248 lines
952 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>devvm – How it works</title><link>https://next.devvm.dev/docs/internals/</link><description>Recent content in How it works on devvm</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://next.devvm.dev/docs/internals/index.xml" rel="self" type="application/rss+xml"/><item><title>Overview</title><link>https://next.devvm.dev/docs/internals/overview/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/overview/</guid><description>
&lt;p&gt;This page explains what devvm does, step by step, when it makes, opens, changes, stops and deletes a VM, and how it keeps each VM&amp;rsquo;s state. &lt;a href="https://next.devvm.dev/docs/getting-started/commands/"&gt;Everyday commands&lt;/a&gt; and &lt;a href="https://next.devvm.dev/docs/using/vms/"&gt;Managing VMs&lt;/a&gt; cover the same commands from your side, and &lt;a href="https://next.devvm.dev/docs/using/settings/"&gt;Settings and files&lt;/a&gt; lists your settings.&lt;/p&gt;
&lt;h2 data-hextra-search-id="a-new-vm"&gt;A new VM&lt;span class="hx:absolute hx:-mt-20" id="a-new-vm"&gt;&lt;/span&gt;
&lt;a href="#a-new-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When you run &lt;code&gt;devvm&lt;/code&gt; in a folder that has no VM, devvm makes one in these steps:&lt;/p&gt;
&lt;div class="devvm-diagram" style="contain-intrinsic-block-size: auto 1173px; --devvm-diagram-width: 472px"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" class="pele pele-flowchart" viewBox="0 0 472 1173" width="472" height="1173" style="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,&amp;quot;Departure Mono&amp;quot;, monospace);font:14px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,&amp;quot;Departure Mono&amp;quot;, monospace)" fill="var(--_fg)" role="graphics-document document" aria-roledescription="flowchart" aria-labelledby="d37cef242ba8b3b82--title" aria-describedby="d37cef242ba8b3b82--desc"&gt;&lt;title id="d37cef242ba8b3b82--title"&gt;How devvm makes a VM&lt;/title&gt;&lt;desc id="d37cef242ba8b3b82--desc"&gt;Until the first shell opens, devvm checks everything first, checks the shared tools for newer versions if due, builds the image if it isn't built, writes the VM's state, makes the VM from its image, locks .git unless --clone, starts its proxy and then the VM, runs the self-check, and sets the VM up, then the clone and devcontainer.json's commands. Then it opens the shell. If it's interrupted before then, devvm deletes the VM and what it made for it, and unlocks .git.&lt;/desc&gt;&lt;g class="pele-clusters"&gt;&lt;g class="pele-cluster" data-id="before"&gt;&lt;rect x="37.41" y="8" width="361.09" height="998" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-cluster-label" fill="var(--_m)" x="171.68" y="31.4" text-anchor="middle"&gt;until the first shell opens&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round"&gt;&lt;g class="pele-edge" data-id="L_check_tools_0"&gt;&lt;path d="M217.95,141L217.95,179"/&gt;&lt;path class="pele-marker" d="M217.95,186L214.59,178L221.31,178Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_tools_build_0"&gt;&lt;path d="M217.95,246L217.95,284"/&gt;&lt;path class="pele-marker" d="M217.95,291L214.59,283L221.31,283Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_build_state_0"&gt;&lt;path d="M217.95,351L217.95,389"/&gt;&lt;path class="pele-marker" d="M217.95,396L214.59,388L221.31,388Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_state_make_0"&gt;&lt;path d="M217.95,456L217.95,494"/&gt;&lt;path class="pele-marker" d="M217.95,501L214.59,493L221.31,493Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_make_lock_0"&gt;&lt;path d="M217.95,561L217.95,599"/&gt;&lt;path class="pele-marker" d="M217.95,606L214.59,598L221.31,598Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_lock_start_0"&gt;&lt;path d="M217.95,666L217.95,704"/&gt;&lt;path class="pele-marker" d="M217.95,711L214.59,703L221.31,703Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_start_self_0"&gt;&lt;path d="M217.95,771L217.95,809"/&gt;&lt;path class="pele-marker" d="M217.95,816L214.59,808L221.31,808Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_self_setup_0"&gt;&lt;path d="M217.95,861L217.95,899"/&gt;&lt;path class="pele-marker" d="M217.95,906L214.59,898L221.31,898Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_setup_shell_0"&gt;&lt;path d="M217.95,966L217.95,1012Q217.95,1024 205.95,1024L104.82,1024Q92.82,1024 92.82,1036L92.82,1079.5"/&gt;&lt;path class="pele-marker" d="M92.82,1086.5L89.46,1078.5L96.18,1078.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_before_undo_0"&gt;&lt;path d="M233.95,1006L233.95,1012Q233.95,1024 245.95,1024L331.09,1024Q343.09,1024 343.09,1036L343.09,1079.5" stroke-dasharray="3 4"/&gt;&lt;path class="pele-marker" d="M343.09,1086.5L339.73,1078.5L346.45,1078.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edge-labels" font-size="14"&gt;&lt;g class="pele-edge-label" data-id="L_before_undo_0"&gt;&lt;rect x="290.09" y="1044" width="106" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="343.09" y="1057.2" text-anchor="middle"&gt;interrupted&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-nodes"&gt;&lt;g class="pele-node pele-shape-rect" data-id="check" transform="translate(217.95,93)"&gt;&lt;rect x="-138.27" y="-48" width="276.55" height="96" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-22.1"&gt;checks everything first:&lt;/tspan&gt;&lt;tspan x="0" y="-4.1"&gt;image, size, ports,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;network tier, SSH agent,&lt;/tspan&gt;&lt;tspan x="0" y="31.9"&gt;features, devcontainer.json&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="tools" transform="translate(217.95,216)"&gt;&lt;rect x="-133.82" y="-30" width="267.64" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;checks the shared tools&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;for newer versions, if due&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="build" transform="translate(217.95,321)"&gt;&lt;rect x="-93.73" y="-30" width="187.45" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;builds the image,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;if it isn't built&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="state" transform="translate(217.95,426)"&gt;&lt;rect x="-120.45" y="-30" width="240.91" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;writes the VM's state,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;with its network choice&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="make" transform="translate(217.95,531)"&gt;&lt;rect x="-80.36" y="-30" width="160.73" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;makes the VM&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;from its image&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="lock" transform="translate(217.95,636)"&gt;&lt;rect x="-80.36" y="-30" width="160.73" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;locks .git,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;unless --clone&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="start" transform="translate(217.95,741)"&gt;&lt;rect x="-93.73" y="-30" width="187.45" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;starts its proxy,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;then the VM&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="self" transform="translate(217.95,838.5)"&gt;&lt;rect x="-80.36" y="-22.5" width="160.73" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;the self-check&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="setup" transform="translate(217.95,936)"&gt;&lt;rect x="-160.55" y="-30" width="321.09" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;sets the VM up, then the clone&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;and devcontainer.json's commands&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="shell" transform="translate(92.82,1109)"&gt;&lt;rect x="-84.82" y="-22.5" width="169.64" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;opens the shell&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="undo" transform="translate(343.09,1125.5)"&gt;&lt;rect x="-120.45" y="-39" width="240.91" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;deletes the VM and what&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;devvm made for it,&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;and unlocks .git&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/div&gt;&lt;ol&gt;
&lt;li&gt;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 &lt;code&gt;--tools&lt;/code&gt;, &lt;code&gt;--agents&lt;/code&gt; and &lt;code&gt;--layers&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/using/images/#what-a-new-vm-gets"&gt;what a new VM gets&lt;/a&gt;), the size, the ports, the network tier (&lt;a href="https://next.devvm.dev/docs/safety/network/#choosing-a-tier"&gt;choosing a tier&lt;/a&gt;), the SSH agent, the backend&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/backends/#features"&gt;features&lt;/a&gt; and what the folder&amp;rsquo;s &lt;code&gt;devcontainer.json&lt;/code&gt; says. Last, when the VM gets an agent and devvm saved an export of agents&amp;rsquo; history for this folder before, devvm offers the newest one, asking in a terminal with no as the default (&lt;code&gt;history_import_ask&lt;/code&gt;) and naming &lt;code&gt;devvm history import&lt;/code&gt; without one (&lt;code&gt;history_import_later&lt;/code&gt;). Before any of it, devvm takes the folder&amp;rsquo;s &lt;a href="#locks"&gt;creation lock&lt;/a&gt;, which it holds until it has recorded that it made the VM in step 5.&lt;/li&gt;
&lt;li&gt;When the VM gets shared tools and the &lt;a href="https://next.devvm.dev/docs/using/images/#shared-tools"&gt;daily check&lt;/a&gt; is due, devvm checks for newer versions of them.&lt;/li&gt;
&lt;li&gt;devvm builds the image if it isn&amp;rsquo;t built yet (&lt;a href="https://next.devvm.dev/docs/internals/images/#building"&gt;building&lt;/a&gt;), then the VM&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/using/images/#shared-tools"&gt;shared tools&lt;/a&gt; that the share lacks.&lt;/li&gt;
&lt;li&gt;devvm writes the VM&amp;rsquo;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&amp;rsquo;s proxy and link session and deletes the VM&amp;rsquo;s folder in its data folder, with its own rules, its run files and its logs.&lt;/li&gt;
&lt;li&gt;devvm makes the VM from its image. The VM mounts only the project folder, read-write, and the shared tools and its agents&amp;rsquo; settings folders from &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#devvms-agent-store"&gt;devvm&amp;rsquo;s agent store&lt;/a&gt;, read-only. With &lt;code&gt;--clone&lt;/code&gt;, devvm doesn&amp;rsquo;t mount the folder, and the VM gets its own clone of the repo instead (&lt;a href="https://next.devvm.dev/docs/using/clone/"&gt;working on a clone&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Unless the VM is a &lt;code&gt;--clone&lt;/code&gt; VM, devvm locks the folder&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt; hooks and config (&lt;a href="https://next.devvm.dev/docs/internals/git-protection/"&gt;&lt;code&gt;.git&lt;/code&gt; protection&lt;/a&gt;). It warns when the repo&amp;rsquo;s origin is an SSH remote and the VM has no SSH agent (&lt;code&gt;ssh_remote_hint&lt;/code&gt;), and on Linux hosts it names the set-id files in the folder, including those an earlier VM of this folder made. When the VM forwards your SSH agent, devvm checks that the agent has keys.&lt;/li&gt;
&lt;li&gt;devvm starts the VM&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/network/#the-proxy"&gt;proxy&lt;/a&gt;, then the VM, confined to the proxy on every tier but open.&lt;/li&gt;
&lt;li&gt;The &lt;a href="https://next.devvm.dev/docs/internals/network/#the-self-check"&gt;self-check&lt;/a&gt; runs, before the setup and the shell. Then, when you said yes to the export devvm offered, devvm warns when the tier that its &lt;code&gt;.folder&lt;/code&gt; file records is less strict than the VM&amp;rsquo;s, or when it records none (&lt;code&gt;history_import_less_strict&lt;/code&gt;, &lt;code&gt;history_import_tier_unknown&lt;/code&gt;), and streams it into the VM, whose own &lt;code&gt;tar&lt;/code&gt; checks its paths and unpacks it as the VM&amp;rsquo;s user (&lt;a href="https://next.devvm.dev/docs/using/coding-agents/#importing-history"&gt;importing history&lt;/a&gt;), and a failed import only warns.&lt;/li&gt;
&lt;li&gt;devvm sets the VM up (&lt;a href="https://next.devvm.dev/docs/using/coding-agents/#the-vms-setup"&gt;the VM&amp;rsquo;s setup&lt;/a&gt;) and makes it reachable &lt;a href="https://next.devvm.dev/docs/using/ssh/"&gt;by name over SSH&lt;/a&gt;. It makes a &lt;code&gt;--clone&lt;/code&gt; VM&amp;rsquo;s clone, or a workspace clone&amp;rsquo;s repos, all in one command in the VM, then copies each repo&amp;rsquo;s branches into it (&lt;a href="https://next.devvm.dev/docs/internals/git-protection/#the-copy-into-a-clone-vm"&gt;the copy into a clone VM&lt;/a&gt;) and copies the folder&amp;rsquo;s own files, and then runs the commands of the folder&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/using/devcontainer/#commands"&gt;&lt;code&gt;devcontainer.json&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;devvm opens a shell in the VM in its own place, so devvm ends when the shell does. Without a terminal, the shell reads its commands from devvm&amp;rsquo;s input.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Until the first shell opens, nothing of yours is in the VM yet. If you interrupt devvm before then, it deletes the VM, stops its proxy, deletes its pinned host keys and its folder, with its state, its own rules and its run files, takes the locks off &lt;code&gt;.git&lt;/code&gt;, and for a &lt;code&gt;--clone&lt;/code&gt; VM removes the repo&amp;rsquo;s remote for it.&lt;/p&gt;
&lt;h2 data-hextra-search-id="adding-to-a-vm"&gt;Adding to a VM&lt;span class="hx:absolute hx:-mt-20" id="adding-to-a-vm"&gt;&lt;/span&gt;
&lt;a href="#adding-to-a-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When &lt;code&gt;devvm tools add&lt;/code&gt;, or &lt;code&gt;devvm tools&lt;/code&gt; in a terminal, adds shared tools to an existing VM (&lt;a href="https://next.devvm.dev/docs/using/toolchains/#adding-and-removing-tools"&gt;adding to a VM&lt;/a&gt;), the tools it builds join the VM&amp;rsquo;s state and are mounted as devvm then launches the VM, and nothing is installed on the VM&amp;rsquo;s disk. A new agent&amp;rsquo;s config folders are mounted as the launch matches the VM&amp;rsquo;s agent folder mounts, which restarts a running VM after asking. &lt;code&gt;devvm tools&lt;/code&gt; shows an existing VM&amp;rsquo;s layers but can&amp;rsquo;t change them, and &lt;code&gt;--tools&lt;/code&gt;, &lt;code&gt;--agents&lt;/code&gt; and &lt;code&gt;--layers&lt;/code&gt; change nothing on an existing VM, because a layer goes onto the VM&amp;rsquo;s disk, which only &lt;a href="#making-a-vm-again"&gt;making the VM again&lt;/a&gt; changes.&lt;/p&gt;
&lt;h2 data-hextra-search-id="making-a-vm-again"&gt;Making a VM again&lt;span class="hx:absolute hx:-mt-20" id="making-a-vm-again"&gt;&lt;/span&gt;
&lt;a href="#making-a-vm-again" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm layer add LAYER...&lt;/code&gt; makes the folder&amp;rsquo;s VM again from a new image, its own layers with the new ones on top, and keeps devvm&amp;rsquo;s settings for it and its home folder (&lt;a href="https://next.devvm.dev/docs/using/images/#adding-layers-to-a-vm"&gt;adding layers to a VM&lt;/a&gt;). &lt;code&gt;devvm layer rm LAYER...&lt;/code&gt; makes it again from an image of its other layers, in their order (&lt;a href="https://next.devvm.dev/docs/using/images/#taking-layers-out-of-a-vm"&gt;taking layers out of a VM&lt;/a&gt;). &lt;code&gt;devvm update&lt;/code&gt; first moves the VM to the newest shared tools, the step &lt;code&gt;devvm tools update&lt;/code&gt; takes, which needs no remake because the tools are mounted. Then it makes the VM again from the image it has, when that image or one below it has a new key, so the VM gets the image&amp;rsquo;s new build (&lt;a href="https://next.devvm.dev/docs/using/images/#outdated-vms"&gt;outdated VMs&lt;/a&gt;), and when the folder&amp;rsquo;s &lt;code&gt;devcontainer.json&lt;/code&gt; isn&amp;rsquo;t the one the VM was made from, as &lt;a href="#reading-the-devcontainerjson-again"&gt;reading the devcontainer.json again&lt;/a&gt; describes. An outdated VM without &lt;code&gt;--force&lt;/code&gt; or a terminal is refused before the tools step, so a refusal changes nothing. The remake is one path in the VM&amp;rsquo;s lifecycle, which takes the image to make the VM from, so each command only works out that image and its own refusals: &lt;code&gt;devvm layer add&lt;/code&gt; names the layers the VM has already, &lt;code&gt;devvm layer rm&lt;/code&gt; names those it lacks (&lt;code&gt;lacks_layers&lt;/code&gt;) and refuses a name that&amp;rsquo;s no layer&amp;rsquo;s, though it takes out one of the user&amp;rsquo;s whose script is gone, and &lt;code&gt;devvm update&lt;/code&gt; says the VM is current (&lt;code&gt;vm_current&lt;/code&gt;) when it had the newest tools and nothing in its chain changed, or names what changed (&lt;code&gt;vm_changed&lt;/code&gt;) before it asks.&lt;/p&gt;
&lt;p&gt;Before anything changes, devvm refuses a name that isn&amp;rsquo;t a layer, a VM made for another folder, one whose creation didn&amp;rsquo;t finish and, except for &lt;code&gt;devvm clone&lt;/code&gt;, a &lt;code&gt;--clone&lt;/code&gt; VM, and it checks that the VM&amp;rsquo;s backend has every feature the VM needs with the new image (&lt;a href="https://next.devvm.dev/docs/internals/backends/#missing-and-unreviewed-features"&gt;missing and unreviewed features&lt;/a&gt;) and that the disk has room for a VM. Then it asks (&lt;code&gt;remake_confirm&lt;/code&gt;, or &lt;code&gt;remake_confirm_clean_home&lt;/code&gt; with &lt;code&gt;--clean-home&lt;/code&gt;), and a parent folder&amp;rsquo;s VM only in a terminal (&lt;code&gt;remake_parent_vm_ask&lt;/code&gt;). Then it checks what the remake would lose, as &lt;code&gt;devvm rm&lt;/code&gt; does: the clone for &lt;code&gt;devvm clone off&lt;/code&gt;, unless &lt;code&gt;--no-clone-check&lt;/code&gt;, and with &lt;code&gt;--clean-home&lt;/code&gt; opencode&amp;rsquo;s worktrees, unless &lt;code&gt;--no-worktree-check&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/agents/#opencodes-worktrees"&gt;opencode&amp;rsquo;s worktrees&lt;/a&gt;). It asks once more when either finds work (&lt;code&gt;remake_anyway&lt;/code&gt;). The remake then goes in this order:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;devvm builds the new image, as for a new VM.&lt;/li&gt;
&lt;li&gt;It exports the agents&amp;rsquo; history as &lt;code&gt;devvm rm&lt;/code&gt; does, unless &lt;code&gt;--no-export&lt;/code&gt;, and saves the VM&amp;rsquo;s home folder, unless &lt;code&gt;--clean-home&lt;/code&gt;. The VM runs &lt;code&gt;tar --one-file-system --ignore-failed-read&lt;/code&gt; in its home as its user, and devvm reads that stream on this machine and writes only what it keeps to &lt;code&gt;home.tar.gz&lt;/code&gt; in the VM&amp;rsquo;s folder (&lt;a href="https://next.devvm.dev/docs/contributing/design/#the-home-folders-copy"&gt;the home folder&amp;rsquo;s copy&lt;/a&gt;). A failure in either keeps the VM as it was (&lt;code&gt;export_failed_kept&lt;/code&gt;, &lt;code&gt;remake_home_failed&lt;/code&gt;), but an export over 2 GiB only warns (&lt;code&gt;history_too_large&lt;/code&gt;), and the remake goes on without one.&lt;/li&gt;
&lt;li&gt;devvm records the remake in the VM&amp;rsquo;s state (&lt;code&gt;remake&lt;/code&gt;), stops the VM, its proxy and its link session, and has the backend rename the VM&amp;rsquo;s machine to its aside name, &lt;code&gt;devvm-&amp;lt;hash&amp;gt;-old&lt;/code&gt;, which is no project VM&amp;rsquo;s name, so nothing else takes it for one. On Lima that&amp;rsquo;s &lt;code&gt;limactl rename&lt;/code&gt;, which keeps the old disk whole.&lt;/li&gt;
&lt;li&gt;devvm makes the new machine by the VM&amp;rsquo;s name from the new image, with what the state records: its project folder, its agents&amp;rsquo; folders, the tools share, its SSH agent, its size, its ports and its ssh port. It records that the new machine was made, and it keeps in the remake&amp;rsquo;s section what the VM had of its base&amp;rsquo;s &lt;code&gt;from&lt;/code&gt;, its shared tools, its ports and its &lt;code&gt;devcontainer&lt;/code&gt; section (&lt;code&gt;remake.was&lt;/code&gt;), so an undo can give them back. It clears which of its &lt;code&gt;devcontainer.json&lt;/code&gt;&amp;rsquo;s commands ran, so those that run once run again. Then it starts the VM as every start does (&lt;a href="#an-existing-vm"&gt;an existing VM&lt;/a&gt;, steps 4 to 8), which pins its new host keys.&lt;/li&gt;
&lt;li&gt;devvm puts the saved home folder in, with &lt;code&gt;tar --skip-old-files&lt;/code&gt; as the VM&amp;rsquo;s user, so what the new image has stays the image&amp;rsquo;s. The new machine is the VM from then on, so devvm records the new &lt;code&gt;image&lt;/code&gt; and &lt;code&gt;chain&lt;/code&gt;, and that the new machine is done.&lt;/li&gt;
&lt;li&gt;devvm deletes the old machine and ends the remake, which removes the section, then deletes &lt;code&gt;home.tar.gz&lt;/code&gt; and opens the VM as an existing VM, setting it up first. The proxy reads the VM&amp;rsquo;s layers from its image, so the new layers&amp;rsquo; allowlists apply from then, and those of layers taken out no longer do, as what the proxy started with has changed (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-proxy"&gt;the proxy&lt;/a&gt;). The VM&amp;rsquo;s &lt;code&gt;id&lt;/code&gt;, its alias and every other field stay as they were (&lt;a href="https://next.devvm.dev/docs/contributing/design/#a-vm-made-again"&gt;a VM made again&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Until the new machine has the home folder in step 5, a failure or an interrupt runs the remake&amp;rsquo;s cleanup (&lt;code&gt;remake_undone&lt;/code&gt;). It deletes the new machine, renames the old one back, whose next start makes it what the state asks for, as every start does, records that the machine by the VM&amp;rsquo;s name is the old one, gives the VM back the &lt;code&gt;from&lt;/code&gt;, shared tools, ports and &lt;code&gt;devcontainer&lt;/code&gt; section that step 4 kept, and ends the remake. When it can&amp;rsquo;t, it warns (&lt;code&gt;remake_undo_failed&lt;/code&gt;) and leaves the remake recorded. The section goes before &lt;code&gt;home.tar.gz&lt;/code&gt; does, so the saved home folder is there for as long as the remake is recorded. After step 5, nothing deletes the new machine, and a failure to delete the old one leaves the remake recorded as done.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm clone on&lt;/code&gt; and &lt;code&gt;devvm clone off&lt;/code&gt; make the VM again from the image it has, in the other clone mode, which the remake records (&lt;code&gt;remake.clone&lt;/code&gt;), so a remake that didn&amp;rsquo;t finish is finished in that mode (&lt;a href="https://next.devvm.dev/docs/using/clone/#switching-a-vm-that-exists"&gt;switching a VM that exists&lt;/a&gt;). Before anything changes, &lt;code&gt;devvm clone on&lt;/code&gt; checks the folder as &lt;code&gt;--clone&lt;/code&gt; does, and after the question &lt;code&gt;devvm clone off&lt;/code&gt; checks the clone as &lt;code&gt;devvm rm&lt;/code&gt; does, unless &lt;code&gt;--no-clone-check&lt;/code&gt;. In step 4 the new machine mounts the project folder, or mounts none of it and keeps the clone at the folder&amp;rsquo;s path, and devvm records its mode when it records that the new machine was made. For the folder mounted, the mode comes with the &lt;code&gt;.git&lt;/code&gt; protection a new VM gets. Before the new machine starts, devvm removes the repo&amp;rsquo;s remote for the clone, keeping the work fetched from it as &lt;a href="#saved-branches"&gt;saved branches&lt;/a&gt;, and then locks &lt;code&gt;.git&lt;/code&gt;, because git can&amp;rsquo;t change a locked &lt;code&gt;.git/config&lt;/code&gt;. After &lt;code&gt;devvm clone on&lt;/code&gt;, devvm takes the &lt;code&gt;.git&lt;/code&gt; locks off in step 6, once the old machine is deleted and it has checked &lt;code&gt;.git&lt;/code&gt; as a launch that finds the VM stopped does. Undoing the remake sets the old mode back, takes off the locks the new machine got, and adds the remote back.&lt;/p&gt;
&lt;p&gt;A devvm holds the VM&amp;rsquo;s remake lock, &lt;code&gt;run/remake.lock&lt;/code&gt; in the VM&amp;rsquo;s folder, from when it finds the VM until the remake ends, and reads the VM&amp;rsquo;s state again once it has the lock. A second devvm that would make the VM again or finish its remake meanwhile refuses (&lt;code&gt;remake_running&lt;/code&gt;), so it never takes a remake that&amp;rsquo;s still running for one that stopped.&lt;/p&gt;
&lt;p&gt;A remake that&amp;rsquo;s recorded while no devvm holds the lock didn&amp;rsquo;t finish, because devvm was killed or its cleanup failed. The next &lt;code&gt;devvm&lt;/code&gt;, &lt;code&gt;devvm layer add&lt;/code&gt;, &lt;code&gt;devvm layer rm&lt;/code&gt;, &lt;code&gt;devvm update&lt;/code&gt;, &lt;code&gt;devvm clone on&lt;/code&gt; or &lt;code&gt;devvm clone off&lt;/code&gt; in the folder finishes it without asking (&lt;code&gt;remake_resuming&lt;/code&gt;). When the new machine is done, devvm deletes the old one and ends the remake. When the old machine is still aside, or the new one was never made, so the machine by the VM&amp;rsquo;s name is the old one, devvm puts the old machine back and makes the VM again from step 1. Otherwise the old machine is gone, and the new one, made or not, never ran a shell, so devvm checks the remake again as before step 1, deletes the new machine and makes it again from step 4 with the saved home folder, or without one, warning, when the file is gone (&lt;code&gt;remake_home_lost&lt;/code&gt;). Meanwhile every other command that acts on the VM refuses (&lt;code&gt;remake_pending&lt;/code&gt;), &lt;code&gt;devvm gc --orphans&lt;/code&gt; never takes the VM for an orphan, though the backend may have no machine by its name, and &lt;code&gt;devvm rm&lt;/code&gt; deletes the VM and its old machine too.&lt;/p&gt;
&lt;h3 data-hextra-search-id="reading-the-devcontainerjson-again"&gt;Reading the devcontainer.json again&lt;span class="hx:absolute hx:-mt-20" id="reading-the-devcontainerjson-again"&gt;&lt;/span&gt;
&lt;a href="#reading-the-devcontainerjson-again" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A VM&amp;rsquo;s &lt;code&gt;devcontainer&lt;/code&gt; section records more than the file&amp;rsquo;s SHA-256 and what it maps to of the VM&amp;rsquo;s own. It records which of the VM&amp;rsquo;s parts came from the file and which from you, so that &lt;code&gt;devvm update&lt;/code&gt; can replace only the file&amp;rsquo;s. &lt;code&gt;parts&lt;/code&gt; lists the toolchains and layers the file&amp;rsquo;s features mapped to when devvm last read it, and &lt;code&gt;gave&lt;/code&gt; lists those of them the VM got from the file alone. A part isn&amp;rsquo;t the file&amp;rsquo;s when &lt;code&gt;--tools&lt;/code&gt; or &lt;code&gt;--layers&lt;/code&gt; chose that part&amp;rsquo;s list, when &lt;code&gt;devvm setup&lt;/code&gt;&amp;rsquo;s layers have it, when the folder&amp;rsquo;s other files call for it, or when you unchecked it in the list. &lt;code&gt;ports&lt;/code&gt; lists the file&amp;rsquo;s &lt;code&gt;forwardPorts&lt;/code&gt;, and &lt;code&gt;ports_gave&lt;/code&gt; lists those of them that devvm added to the VM&amp;rsquo;s ports, as &lt;code&gt;devvm ports add&lt;/code&gt; adds them, because your ports didn&amp;rsquo;t forward them already and you didn&amp;rsquo;t give &lt;code&gt;--ports&lt;/code&gt;. &lt;code&gt;image&lt;/code&gt; is the container image the file names, recorded only when the VM&amp;rsquo;s base starts from it, and &lt;code&gt;from_flag&lt;/code&gt; records that you gave &lt;code&gt;--from&lt;/code&gt;, which wins over the file&amp;rsquo;s image for as long as the VM exists.&lt;/p&gt;
&lt;p&gt;When the folder&amp;rsquo;s file isn&amp;rsquo;t the one the VM was made from, because it changed, it&amp;rsquo;s gone or it appeared, &lt;code&gt;devvm update&lt;/code&gt; reads it again as a new VM&amp;rsquo;s file is read and refuses what a new VM refuses (&lt;code&gt;devcontainer_reread&lt;/code&gt;, or &lt;code&gt;devcontainer_gone&lt;/code&gt; for a file that&amp;rsquo;s gone). Then it works out what the VM is made again with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Its parts.&lt;/strong&gt; devvm drops the parts in &lt;code&gt;gave&lt;/code&gt; that the file no longer calls for, and adds the ones the file now calls for that weren&amp;rsquo;t in &lt;code&gt;parts&lt;/code&gt; and that the VM lacks. A part you took out stays out, and your own parts stay. Layers go into the new image&amp;rsquo;s name, after the layers the VM keeps, and toolchains go into its shared tools.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Its base.&lt;/strong&gt; With &lt;code&gt;from_flag&lt;/code&gt;, the base stays as it is, and devvm says the file&amp;rsquo;s image is ignored. When the file names another image, devvm pins it to the digest its registry gives anyone, as for a new VM. When the file no longer names one, the base starts from &lt;code&gt;$DEVVM_FROM&lt;/code&gt;, or else from Ubuntu&amp;rsquo;s cloud image.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Its ports.&lt;/strong&gt; In the same way, devvm takes out the ports in &lt;code&gt;ports_gave&lt;/code&gt; that the file no longer lists, with the rule &lt;code&gt;devvm ports rm&lt;/code&gt; follows, and adds the ones it lists anew that the VM&amp;rsquo;s ports don&amp;rsquo;t already forward, with the rule &lt;code&gt;devvm ports add&lt;/code&gt; follows. A port you took out with &lt;code&gt;devvm ports rm&lt;/code&gt; stays out, your own ports stay, and with every port forwarded nothing changes. A port of the file&amp;rsquo;s that&amp;rsquo;s part of one of your ranges counts as yours.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Its variables and commands.&lt;/strong&gt; The file&amp;rsquo;s new ones replace the old ones, and the commands that run once run on the new disk.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The remake records all of this in its section (&lt;code&gt;remake.reread&lt;/code&gt;): the new base&amp;rsquo;s &lt;code&gt;from&lt;/code&gt;, the shared tools, the ports and the new &lt;code&gt;devcontainer&lt;/code&gt; section. After step 1 builds the new image from the new base, devvm builds the shared tools for that base, as for a new VM, and records their files there too, holding the lock that new VMs hold so that &lt;code&gt;devvm gc&lt;/code&gt; keeps the tool images. In step 4 the VM gets all four, so the port forwarder starts with the new ports when the VM starts, and an undo gives back what it had. A remake that didn&amp;rsquo;t finish keeps them, so it&amp;rsquo;s finished with what the file said when &lt;code&gt;devvm update&lt;/code&gt; read it.&lt;/p&gt;
&lt;h2 data-hextra-search-id="an-existing-vm"&gt;An existing VM&lt;span class="hx:absolute hx:-mt-20" id="an-existing-vm"&gt;&lt;/span&gt;
&lt;a href="#an-existing-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When you run &lt;code&gt;devvm&lt;/code&gt; in a folder whose VM exists, devvm opens the VM as it is and starts it if it&amp;rsquo;s stopped. Each time, it does these steps in this order:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;devvm warns when an image the VM was made from has changed since, or when there are newer shared tools than the VM&amp;rsquo;s, and both warnings name &lt;code&gt;devvm update&lt;/code&gt;, which moves the VM to the newer tools and, after asking, makes it again from the changed image (&lt;a href="https://next.devvm.dev/docs/using/images/#outdated-vms"&gt;outdated VMs&lt;/a&gt;). It also checks for newer tools once a day.&lt;/li&gt;
&lt;li&gt;devvm ignores the options for new VMs, with a warning for each. The VM keeps its shared tools, which &lt;code&gt;devvm tools&lt;/code&gt; changes, and its layers, which &lt;code&gt;devvm layer add&lt;/code&gt; and &lt;code&gt;devvm layer rm&lt;/code&gt; change. It keeps its network tier, which &lt;code&gt;devvm network&lt;/code&gt; changes, and its &lt;code&gt;.git&lt;/code&gt; protection, which &lt;code&gt;devvm git-protect&lt;/code&gt; changes. It keeps its size, which &lt;code&gt;devvm size&lt;/code&gt; changes, its ports, which &lt;code&gt;devvm ports&lt;/code&gt; changes, and its SSH agent forwarding, which &lt;code&gt;devvm ssh-agent&lt;/code&gt; changes. It also keeps its backend, and ignores &lt;code&gt;--from&lt;/code&gt; and &lt;code&gt;--no-devcontainer&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;devvm warns when the folder&amp;rsquo;s &lt;code&gt;devcontainer.json&lt;/code&gt; isn&amp;rsquo;t the one the VM was made from, and the warning names &lt;code&gt;devvm update&lt;/code&gt;, which makes the VM again as the file says now (&lt;a href="https://next.devvm.dev/docs/using/devcontainer/#when-its-read"&gt;details&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;devvm asks the backend for the VM&amp;rsquo;s status and config, once for the whole start. It compares the VM&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#mounts"&gt;agent folder mounts&lt;/a&gt; with the folders in devvm&amp;rsquo;s agent store and names the folders that changed. A running VM gets the new mounts when it next starts. When a running VM has changes waiting for its next start, such as these mounts, a new size, a change to its agent forwarding or the open tier given to it while it ran confined, devvm names them in at most two lines, one for each change (&lt;code&gt;next_start_size&lt;/code&gt;, &lt;code&gt;next_start_agent&lt;/code&gt;, &lt;code&gt;next_start_mounts&lt;/code&gt;, &lt;code&gt;next_start_net_off&lt;/code&gt;), or past two the first change and how many more (&lt;code&gt;next_start_more&lt;/code&gt;). Then it asks once, in a terminal, whether to restart it now (&lt;code&gt;restart_now&lt;/code&gt;), yes by default (&lt;code&gt;[Y/n]&lt;/code&gt;) when the mounts are among the changes and no by default (&lt;code&gt;[y/N]&lt;/code&gt;) otherwise. A yes stops the VM here, so the steps below start it with the changes, and a no leaves it running.&lt;/li&gt;
&lt;li&gt;devvm checks &lt;code&gt;.git&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/git-protection/#on-each-launch"&gt;on each launch&lt;/a&gt;) and, on Linux hosts when it finds the VM stopped, names the set-id files in the folder. It skips both for a &lt;code&gt;--clone&lt;/code&gt; VM, which mounts neither.&lt;/li&gt;
&lt;li&gt;devvm checks that the backend can still give the VM what its state asks for: its tier&amp;rsquo;s confinement, its ports and its &lt;a href="https://next.devvm.dev/docs/using/ssh/#agent-forwarding"&gt;SSH agent forwarding&lt;/a&gt;, and turning that forwarding on or off when the VM has it the other way. A backend that can&amp;rsquo;t is refused before anything starts. When the VM forwards your agent, devvm checks that the agent has keys.&lt;/li&gt;
&lt;li&gt;devvm starts the VM if it&amp;rsquo;s stopped. The backend&amp;rsquo;s start gives the VM what its state asks for: its size, the agent folders in devvm&amp;rsquo;s agent store, its agent forwarding and its ports. It changes only what differs from the VM&amp;rsquo;s config, together with what the VM&amp;rsquo;s confinement needs, and it changes nothing on a running VM (&lt;a href="https://next.devvm.dev/docs/internals/lima/#what-devvm-sets-on-a-vm"&gt;on Lima&lt;/a&gt;). When the VM uses devvm&amp;rsquo;s own agent, devvm loads the keys that the agent lacks, whether the VM starts or runs already. A running VM keeps its proxy, unless what the proxy was started with has changed (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-proxy"&gt;the proxy&lt;/a&gt;), and a VM made open after it started confined stays confined to its proxy, which applies the open tier&amp;rsquo;s rules, until it next starts. For a VM that runs on, devvm then says in one place what the VM gets only when it next starts, where that differs from what its state asks for: its size, its agent forwarding, its agent folder mounts and the open tier&amp;rsquo;s direct network. It warns of each with the line that names it in step 4, then once that &lt;code&gt;devvm restart&lt;/code&gt; applies them (&lt;code&gt;next_start&lt;/code&gt;), which is also what &lt;code&gt;devvm size&lt;/code&gt;, &lt;code&gt;devvm network&lt;/code&gt; and &lt;code&gt;devvm ssh-agent&lt;/code&gt; say for a running VM you don&amp;rsquo;t restart.&lt;/li&gt;
&lt;li&gt;The &lt;a href="https://next.devvm.dev/docs/internals/network/#the-self-check"&gt;self-check&lt;/a&gt; runs, and devvm stops a VM whose confined tier isn&amp;rsquo;t enforced.&lt;/li&gt;
&lt;li&gt;devvm sets the VM up and opens the shell, as for a new VM. A &lt;code&gt;--clone&lt;/code&gt; VM whose clone wasn&amp;rsquo;t made yet gets it first. On the first launch after the VM started, the &lt;code&gt;postStartCommand&lt;/code&gt; of the &lt;code&gt;devcontainer.json&lt;/code&gt; that the VM was made from runs before the shell opens (&lt;a href="https://next.devvm.dev/docs/using/devcontainer/#commands"&gt;commands&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Steps 4 to 8 are the one way devvm starts a VM, whatever the command, and only a launch matches the agent folder mounts in step 4. So &lt;code&gt;devvm host&lt;/code&gt; and &lt;code&gt;devvm code&lt;/code&gt;, an export, &lt;code&gt;devvm rm&lt;/code&gt;&amp;rsquo;s check of a &lt;code&gt;--clone&lt;/code&gt; VM and a remake&amp;rsquo;s new machine check &lt;code&gt;.git&lt;/code&gt;, check what the backend can give, start the VM with the size, agent folders, agent forwarding and ports its state asks for, and run the self-check in the same way. A new VM goes through steps 5 to 8 once it&amp;rsquo;s made, and in step 5 devvm locks its &lt;code&gt;.git&lt;/code&gt; and checks its folder as step 6 of &lt;a href="#a-new-vm"&gt;a new VM&lt;/a&gt; says.&lt;/p&gt;
&lt;p&gt;devvm never starts a VM whose creation didn&amp;rsquo;t finish, because the VM would start without its tier (&lt;code&gt;vm_unfinished&lt;/code&gt;). That happens when devvm was stopped after it made the VM but before it recorded the VM&amp;rsquo;s tier. In a terminal and without &lt;code&gt;--no-input&lt;/code&gt;, devvm asks whether to delete such a VM and make it again (&lt;code&gt;remake_unfinished&lt;/code&gt;, &lt;code&gt;[y/N]&lt;/code&gt;), and yes deletes it as &lt;code&gt;devvm rm&lt;/code&gt; does, then makes the VM as for a folder without one. Otherwise, and for a parent folder&amp;rsquo;s VM, devvm refuses, and &lt;code&gt;devvm rm&lt;/code&gt; deletes such a VM.&lt;/p&gt;
&lt;p&gt;devvm also never starts a VM on a project folder that was replaced after the finder found the VM. A parent folder&amp;rsquo;s VM mounts a nested project folder too, so code in it can move the folder aside and put a link or another folder at its path. On Linux, Lima passes the path to QEMU as it is, and its 9p share follows a link when it opens the folder at the VM&amp;rsquo;s start. On macOS, the Lima backend mounts the folder by the device and inode in the state&amp;rsquo;s &lt;code&gt;folder&lt;/code&gt; instead (&lt;a href="https://next.devvm.dev/docs/internals/lima/#what-devvm-sets-on-a-vm"&gt;what devvm sets on a VM&lt;/a&gt;), so Virtualization.framework&amp;rsquo;s virtiofs share opens the folder devvm made the VM for, wherever it is then, and never what replaced it. devvm checks the folder three times in a start of a stopped VM: before step 5&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt; checks, which would otherwise act on what the link points to, just before the backend&amp;rsquo;s start, and once the backend&amp;rsquo;s start returns. Each check resolves the path&amp;rsquo;s links, which must give the same path, and compares the folder&amp;rsquo;s identity, its device, inode and birth time, with the state&amp;rsquo;s &lt;code&gt;folder&lt;/code&gt;. macOS numbers its disks&amp;rsquo; devices in the order they appear at boot, so after a restart the same folder can be on a device with another number. So when only the folder&amp;rsquo;s device differs and the folder is still the VM&amp;rsquo;s, the start records the folder&amp;rsquo;s identity as it is now in the state&amp;rsquo;s &lt;code&gt;folder&lt;/code&gt;, under the VM&amp;rsquo;s &lt;code&gt;lock&lt;/code&gt;, before the first check. The folder is still the VM&amp;rsquo;s when its identity has its birth time and its file system never gives a new folder a deleted one&amp;rsquo;s inode number (as for &lt;a href="#a-moved-folder"&gt;a moved folder&lt;/a&gt;). devvm reads that identity from the folder opened at its path with no link followed, so a link swapped in for a moment can&amp;rsquo;t pass a copy&amp;rsquo;s identity off as the folder&amp;rsquo;s. The finder takes such a folder as the VM&amp;rsquo;s in the same way. The backend then mounts the folder by the device it&amp;rsquo;s on now, never by the old number, which may be another disk&amp;rsquo;s after the boot, and each of the three checks compares the identity with the recorded one exactly. A failed check before the start refuses it (&lt;code&gt;project_folder_changed&lt;/code&gt;), and one after it stops the VM and its proxy and refuses (&lt;code&gt;project_folder_changed_stopped&lt;/code&gt;). The backend&amp;rsquo;s start returns once the VM has booted, so a VM stopped by the last check ran with what it mounted for as long as its boot took, on its own tier&amp;rsquo;s network. A running VM&amp;rsquo;s share never follows a link put in the folder&amp;rsquo;s place later: QEMU&amp;rsquo;s 9p share holds the folder it opened at the start, and Virtualization.framework&amp;rsquo;s virtiofs share answers &amp;ldquo;Operation not permitted&amp;rdquo; for it, which the project section of the end-to-end tests checks on both. So a launch into a running VM checks nothing more than the finder did. On Linux, code that replaces the folder only for the moment QEMU opens it, and puts it back before the last check, stays unseen, and the VM keeps what the link pointed to until its next start. On macOS, the same swap leaves the VM with the project folder where it was moved to at the start, and once the folder is back, virtiofs answers &amp;ldquo;Operation not permitted&amp;rdquo; for it until the VM&amp;rsquo;s next start, which the project section of the end-to-end tests checks.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm&lt;/code&gt; warns about the setup that allows this before it makes or opens a VM that mounts its folder (&lt;code&gt;project_in_vm_folder&lt;/code&gt;). The finder walks the folders the VM&amp;rsquo;s folder is inside, as it does for &lt;a href="#a-subfolders-vm"&gt;a subfolder&amp;rsquo;s VM&lt;/a&gt;, and names the nearest one with a state of its own that was made for that folder and isn&amp;rsquo;t a &lt;code&gt;--clone&lt;/code&gt; VM. It reads only the states and asks no backend, so a stopped parent folder&amp;rsquo;s VM counts too, because it writes to the folder whenever it runs. The warning comes once per run of &lt;code&gt;devvm&lt;/code&gt;, and no other command gives it.&lt;/p&gt;
&lt;h2 data-hextra-search-id="stopping-a-vm"&gt;Stopping a VM&lt;span class="hx:absolute hx:-mt-20" id="stopping-a-vm"&gt;&lt;/span&gt;
&lt;a href="#stopping-a-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm stop&lt;/code&gt; stops this folder&amp;rsquo;s VM, then its &lt;a href="https://next.devvm.dev/docs/internals/network/#the-proxy"&gt;proxy&lt;/a&gt;, its &lt;a href="https://next.devvm.dev/docs/internals/ports/#its-process-and-files"&gt;port forwarder&lt;/a&gt; and its link session. Once the VM is stopped, devvm applies the &lt;code&gt;.git&lt;/code&gt; protection chosen with &lt;code&gt;devvm git-protect&lt;/code&gt; while the VM ran, checks &lt;code&gt;.git&lt;/code&gt; as a launch that finds the VM stopped does, and sets the locks that were waiting for the VM to stop (&lt;a href="https://next.devvm.dev/docs/internals/git-protection/#on-each-launch"&gt;on each launch&lt;/a&gt;). On Linux hosts it also names the set-id files in the folder. It skips both for a &lt;code&gt;--clone&lt;/code&gt; VM. Then devvm removes the VM&amp;rsquo;s entry from the &lt;a href="https://next.devvm.dev/docs/using/ssh/"&gt;ssh config&lt;/a&gt;. A VM that&amp;rsquo;s already stopped gets the same checks.&lt;/p&gt;
&lt;h2 data-hextra-search-id="deleting-a-vm"&gt;Deleting a VM&lt;span class="hx:absolute hx:-mt-20" id="deleting-a-vm"&gt;&lt;/span&gt;
&lt;a href="#deleting-a-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm rm&lt;/code&gt; deletes this folder&amp;rsquo;s VM and what devvm keeps for it: its state, its own allowlist and secret files, its network log, its &lt;code&gt;.git&lt;/code&gt; locks, its pinned host keys and its ssh config entry. Other VMs, images and the project folder stay.&lt;/p&gt;
&lt;p&gt;After the backend deletes the VM, devvm tears down the rest in one order, which &lt;code&gt;devvm gc --orphans&lt;/code&gt; follows too. It stops the VM&amp;rsquo;s proxy, port forwarder and link session first. Then it deletes what devvm keeps for the VM outside its folder: a clone&amp;rsquo;s remote and the &lt;code&gt;.git&lt;/code&gt; locks, other VMs&amp;rsquo; links to it and the links its group made, its pinned host keys, for &lt;code&gt;devvm gc --orphans&lt;/code&gt; the backend&amp;rsquo;s own leftovers, and the old machine of a &lt;a href="#making-a-vm-again"&gt;remake&lt;/a&gt; that didn&amp;rsquo;t finish. Then it deletes the VM&amp;rsquo;s folder, with every file devvm keeps for it there, and last its ssh config entry.&lt;/p&gt;
&lt;p&gt;For a &lt;code&gt;--clone&lt;/code&gt; VM, devvm first checks the clone for commits that this repo hasn&amp;rsquo;t fetched and for uncommitted changes, in the clone and in the worktrees inside it (&lt;a href="https://next.devvm.dev/docs/using/clone/#deleting-the-vm"&gt;deleting the VM&lt;/a&gt;). It reads every repo of the clone in one command in the VM, a script sent with it that prints each repo&amp;rsquo;s branches, its status and each linked worktree below the project folder with that worktree&amp;rsquo;s status, as length-prefixed records. devvm reads at most 8 MiB of the answer and stops the command once it sends more, and it waits at most 2 minutes for the answer, so a VM that answers without end, or never, can&amp;rsquo;t keep &lt;code&gt;devvm rm&lt;/code&gt; waiting. It takes only whole records of the repos it asked for, each worktree&amp;rsquo;s path clean, relative and below the folder, and any other answer fails the check, which keeps the VM. The repo&amp;rsquo;s remote for the VM goes with the VM, and devvm keeps the work fetched from it as local branches, which &lt;a href="#saved-branches"&gt;saved branches&lt;/a&gt; names. When the VM&amp;rsquo;s image has an agent, devvm then exports the agents&amp;rsquo; history from the VM, starting it if it&amp;rsquo;s stopped (&lt;a href="https://next.devvm.dev/docs/using/coding-agents/#history"&gt;history&lt;/a&gt;), and it keeps the VM if the export fails. devvm reads the VM&amp;rsquo;s export through a writer that stops at 2 GiB (&lt;code&gt;bounded&lt;/code&gt;): past that, it stops the VM&amp;rsquo;s command, deletes what it wrote and warns (&lt;code&gt;history_too_large&lt;/code&gt;), and the delete goes on, as it does for a remake. &lt;code&gt;devvm rm&lt;/code&gt; asks first in a terminal (&lt;code&gt;rm_confirm&lt;/code&gt;), and where devvm can&amp;rsquo;t ask it refuses unless &lt;code&gt;--force&lt;/code&gt;, the question&amp;rsquo;s refusal naming &lt;code&gt;--force&lt;/code&gt; (&lt;code&gt;no_input&lt;/code&gt;). &lt;code&gt;devvm rm --no-export&lt;/code&gt; deletes the VM without the export, the clone&amp;rsquo;s checks still run and ask only in a terminal, and a VM whose creation didn&amp;rsquo;t finish gets neither, because it never ran.&lt;/p&gt;
&lt;h3 data-hextra-search-id="saved-branches"&gt;Saved branches&lt;span class="hx:absolute hx:-mt-20" id="saved-branches"&gt;&lt;/span&gt;
&lt;a href="#saved-branches" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The local branches are named &lt;code&gt;saved/&amp;lt;remote&amp;gt;/&amp;lt;branch&amp;gt;&lt;/code&gt;, after the remote, and devvm never overwrites a branch. If a branch named &lt;code&gt;saved/&amp;lt;remote&amp;gt;&lt;/code&gt; exists, or one under it, or one it would sit under, devvm uses &lt;code&gt;saved/&amp;lt;remote&amp;gt;-2&lt;/code&gt; instead, then &lt;code&gt;-3&lt;/code&gt;, and so on up to &lt;code&gt;-99&lt;/code&gt;. If none of those names is free, for example because a branch is named &lt;code&gt;saved&lt;/code&gt;, &lt;code&gt;devvm rm&lt;/code&gt; refuses before it fetches anything and keeps the VM. When that happens as devvm is about to remove the remote, it leaves the remote and its branches in place. Branch names come from the VM, so devvm quotes them when it shows them, and it skips any name that git refuses as a branch name.&lt;/p&gt;
&lt;h2 data-hextra-search-id="a-folder-made-again"&gt;A folder made again&lt;span class="hx:absolute hx:-mt-20" id="a-folder-made-again"&gt;&lt;/span&gt;
&lt;a href="#a-folder-made-again" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A VM&amp;rsquo;s state records its project folder&amp;rsquo;s path (&lt;code&gt;dir&lt;/code&gt;) and the folder&amp;rsquo;s identity (&lt;code&gt;folder&lt;/code&gt;), which &lt;a href="https://next.devvm.dev/docs/internals/security/#one-vm-per-folder"&gt;one VM per folder&lt;/a&gt; describes. When either differs from the folder you&amp;rsquo;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 (&lt;code&gt;vm_other_folder&lt;/code&gt;), and only &lt;code&gt;devvm rm&lt;/code&gt; and &lt;code&gt;devvm adopt&lt;/code&gt; act on it. Each of them asks first, so without a terminal each one refuses (&lt;code&gt;vm_other_folder_rm&lt;/code&gt;, &lt;code&gt;vm_other_folder_adopt&lt;/code&gt;), unless &lt;code&gt;devvm adopt --force&lt;/code&gt;. &lt;a href="https://next.devvm.dev/docs/using/vms/#a-folder-made-again"&gt;A folder made again&lt;/a&gt; says what each one does, and devvm does it as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;devvm rm&lt;/code&gt; asks with &lt;code&gt;delete_other_folder_vm&lt;/code&gt;, then deletes the VM without checking a clone, because the VM&amp;rsquo;s folder is gone.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;devvm adopt&lt;/code&gt; asks with &lt;code&gt;adopt_vm&lt;/code&gt;, then records this folder&amp;rsquo;s path and identity in the VM&amp;rsquo;s state and clears the inode of &lt;code&gt;.git&lt;/code&gt; it recorded, so the next launch locks &lt;code&gt;.git&lt;/code&gt; as if it had just appeared (&lt;code&gt;vm_adopted&lt;/code&gt;). In a folder the VM already belongs to, it changes nothing (&lt;code&gt;vm_already_here&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="a-moved-folder"&gt;A moved folder&lt;span class="hx:absolute hx:-mt-20" id="a-moved-folder"&gt;&lt;/span&gt;
&lt;a href="#a-moved-folder" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A VM&amp;rsquo;s folder in the data folder, &lt;code&gt;vms/&amp;lt;hash&amp;gt;/&lt;/code&gt;, is named by the hash at the end of the VM&amp;rsquo;s name, which the backend&amp;rsquo;s machine has too, so neither changes when the project folder moves. What changes is the state&amp;rsquo;s &lt;code&gt;dir&lt;/code&gt;, and devvm finds a folder&amp;rsquo;s VM by the state that records its path (&lt;a href="#a-vms-folder"&gt;a VM&amp;rsquo;s folder&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;When the folder devvm runs in has no VM, devvm looks through every VM&amp;rsquo;s state for one made for this folder at another path (&lt;a href="#listing-vms"&gt;listing VMs&lt;/a&gt;). A state matches when its &lt;code&gt;folder&lt;/code&gt; identity is this folder&amp;rsquo;s, its &lt;code&gt;dir&lt;/code&gt; is another path, nothing is at that path any more on the folder&amp;rsquo;s device (&lt;code&gt;gone&lt;/code&gt;, &lt;a href="#a-vm-whose-folder-is-gone"&gt;a VM whose folder is gone&lt;/a&gt;) or only a symlink that resolves to this folder is, its creation finished, and it isn&amp;rsquo;t a &lt;code&gt;--clone&lt;/code&gt; VM. The folder must be this user&amp;rsquo;s, and its identity must be one that no other folder can have had. It must have the folder&amp;rsquo;s birth time, which tells a folder apart from a deleted one with the same inode number, and from a folder with the same inode number on another volume that a later mount gave the same device number, and on macOS the folder must be on APFS or HFS+, which never give a new folder a deleted one&amp;rsquo;s inode number. On Linux it must be on ext4, XFS, Btrfs, tmpfs, ZFS, F2FS or bcachefs, local file systems that keep a file&amp;rsquo;s inode number for its life and report its birth time, which devvm reads by the file system&amp;rsquo;s type from &lt;code&gt;statfs&lt;/code&gt;. FUSE, network shares, 9p, overlayfs and FAT may make inode numbers up, so a folder on one never matches. A copy has a new inode, so it never matches, and a folder made again at the old path doesn&amp;rsquo;t either. At another path, the identity must also match the device in the state&amp;rsquo;s &lt;code&gt;folder&lt;/code&gt;. So a folder that moved after a boot numbered its disk anew, before its VM started again, isn&amp;rsquo;t offered the VM, and you move the VM to it with &lt;code&gt;devvm adopt VM&lt;/code&gt;. When more than one state matches, devvm moves none (&lt;code&gt;vms_moved_here&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;For one match, devvm asks in a terminal (&lt;code&gt;move_vm&lt;/code&gt;), with no as the default, and refuses without one (&lt;code&gt;vm_moved_here&lt;/code&gt;). &lt;code&gt;devvm adopt --force&lt;/code&gt; moves it without asking. A no leaves the folder without a VM, so &lt;code&gt;devvm&lt;/code&gt; makes a new one. A yes first checks the folder as a new VM&amp;rsquo;s folder is checked (&lt;a href="https://next.devvm.dev/docs/using/settings/#project-folders-devvm-refuses"&gt;project folders devvm refuses&lt;/a&gt;). Then devvm takes the &lt;a href="#locks"&gt;creation locks&lt;/a&gt; of the VM and of the new VM the folder would get, so no other devvm deletes the VM or makes one for the folder meanwhile, and checks again that no state records the folder, and that the folder at the path is still the one it asked about (&lt;code&gt;move_folder_changed&lt;/code&gt;). A running VM still mounts the old path, so devvm stops it as &lt;code&gt;devvm stop&lt;/code&gt; does, with its proxy, port forwarder and link session (&lt;code&gt;stopped&lt;/code&gt;). Last, it records the folder&amp;rsquo;s path and identity under the VM&amp;rsquo;s &lt;code&gt;lock&lt;/code&gt;, refusing a state whose &lt;code&gt;dir&lt;/code&gt; or &lt;code&gt;folder&lt;/code&gt; changed since it was read (&lt;code&gt;create_running&lt;/code&gt;), and says so (&lt;code&gt;vm_adopted&lt;/code&gt;). In the same write, it records the old path in the state&amp;rsquo;s &lt;code&gt;moved&lt;/code&gt; section as &lt;code&gt;from&lt;/code&gt;, the path that the agents in the VM keep the folder&amp;rsquo;s history under. A second move before the VM&amp;rsquo;s next start keeps the first move&amp;rsquo;s old path there, because the history is still under it, and a move back to that path clears the section. The &lt;code&gt;.git&lt;/code&gt; protection&amp;rsquo;s record stays as it was, because a folder that moved keeps its &lt;code&gt;.git&lt;/code&gt;, whose identity and locks move with it, so the next check compares &lt;code&gt;.git&lt;/code&gt; with what it locked.&lt;/p&gt;
&lt;p&gt;The backend gets the new path at the VM&amp;rsquo;s next start, because a start makes a stopped VM what its state asks for, its project folder&amp;rsquo;s mount included, and Lima does it in the same &lt;code&gt;limactl edit&lt;/code&gt; as the rest (&lt;a href="https://next.devvm.dev/docs/internals/lima/#what-devvm-sets-on-a-vm"&gt;what devvm sets on a VM&lt;/a&gt;). A VM that runs with its project folder at another path all the same, such as one started outside devvm, mounts that path until it starts again, so devvm asks whether to restart it as it opens the VM (&lt;code&gt;restart_now&lt;/code&gt;), with yes as the default, as for agent folders, and otherwise warns that it mounts the folder at the new path only when it next starts (&lt;code&gt;next_start_folder&lt;/code&gt;, then &lt;code&gt;next_start&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;The VM&amp;rsquo;s setup, which runs on every launch, moves Claude Code&amp;rsquo;s history for the folder. Claude Code keeps a folder&amp;rsquo;s sessions in &lt;code&gt;~/.claude/projects/SLUG&lt;/code&gt;, where SLUG is the folder&amp;rsquo;s path with each character other than an ASCII letter or digit replaced by a dash, counted in UTF-16 units as JavaScript counts them. A SLUG longer than 200 characters is cut at 200 and gets a dash and the path&amp;rsquo;s hash in base 36, the 32-bit hash that multiplies by 31 and adds each UTF-16 unit. That rule is Claude Code&amp;rsquo;s own, read from its 2.1 release. Claude Code also keeps the folder&amp;rsquo;s trust and MCP servers under the path itself in &lt;code&gt;~/.claude.json&lt;/code&gt;&amp;rsquo;s &lt;code&gt;projects&lt;/code&gt;. When the state has a &lt;code&gt;moved&lt;/code&gt; section, devvm sends the setup a &lt;code&gt;moved&lt;/code&gt; file with both paths and both slugs, and the setup&amp;rsquo;s &lt;code&gt;claude.sh&lt;/code&gt; renames the old slug&amp;rsquo;s folder to the new slug. When the new slug&amp;rsquo;s folder exists already, the setup moves each of the old folder&amp;rsquo;s entries that the new one doesn&amp;rsquo;t have into it, and leaves the rest. It moves the &lt;code&gt;projects&lt;/code&gt; entry of the old path to the new path, unless the new path has one of its own, and leaves a &lt;code&gt;~/.claude.json&lt;/code&gt; that isn&amp;rsquo;t JSON as it is, with a warning in the run log. A folder or file that is a symlink stays as it is. All of this runs in the VM, as the VM&amp;rsquo;s user, on the VM&amp;rsquo;s own files, and never on the host&amp;rsquo;s. Running it again changes nothing, so a setup that fails after it moved the history does no harm when it runs again. Once the setup succeeds, devvm clears the &lt;code&gt;moved&lt;/code&gt; section under the VM&amp;rsquo;s &lt;code&gt;lock&lt;/code&gt;, unless another move recorded a different path meanwhile. devvm moves nothing of Codex&amp;rsquo;s or opencode&amp;rsquo;s. Codex records each session&amp;rsquo;s folder in the session, and opencode keeps a git repo&amp;rsquo;s sessions by the repo&amp;rsquo;s first commit and other folders&amp;rsquo; sessions by their path (&lt;a href="https://next.devvm.dev/docs/using/vms/#a-moved-or-renamed-folder"&gt;a moved or renamed folder&lt;/a&gt;). Links and groups go by the VM&amp;rsquo;s name, so they stay as they were, and a link&amp;rsquo;s TARGET given as a path finds the VM whose &lt;code&gt;dir&lt;/code&gt; is that path. A new VM made at the old path can&amp;rsquo;t use the folder the moved VM keeps, so its name ends with the next hash of that path that names a free folder.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm adopt VM&lt;/code&gt; moves the VM it names, found as &lt;code&gt;devvm rm VM&lt;/code&gt; finds one, to the folder devvm runs in, for a copy of the folder, such as one on another disk. It refuses a &lt;code&gt;--clone&lt;/code&gt; VM (&lt;code&gt;adopt_clone&lt;/code&gt;), a VM its backend no longer has (&lt;code&gt;rm_vm_lost&lt;/code&gt;), a VM whose creation didn&amp;rsquo;t finish, a VM whose folder is there (&lt;code&gt;adopt_folder_there&lt;/code&gt;), and a folder with a VM of its own (&lt;code&gt;adopt_has_vm&lt;/code&gt;). It asks in a terminal (&lt;code&gt;adopt_move_vm&lt;/code&gt;), which &lt;code&gt;--force&lt;/code&gt; answers, and refuses without either (&lt;code&gt;adopt_move_refused&lt;/code&gt;). It moves the VM as a match does, and also clears the &lt;code&gt;.git&lt;/code&gt; protection&amp;rsquo;s record, as &lt;code&gt;devvm adopt&lt;/code&gt; does, because the copy&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt; is another folder. A VM whose &lt;code&gt;dir&lt;/code&gt; is this folder goes through &lt;code&gt;devvm adopt&lt;/code&gt;.&lt;/p&gt;
&lt;h2 data-hextra-search-id="a-vm-whose-folder-is-gone"&gt;A VM whose folder is gone&lt;span class="hx:absolute hx:-mt-20" id="a-vm-whose-folder-is-gone"&gt;&lt;/span&gt;
&lt;a href="#a-vm-whose-folder-is-gone" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A VM&amp;rsquo;s folder is there, gone or not connected, which &lt;code&gt;devvm ls --json&lt;/code&gt; gives as &lt;code&gt;folder_state&lt;/code&gt;. It&amp;rsquo;s there when something is at the path its state records as &lt;code&gt;dir&lt;/code&gt; (&lt;a href="#a-vms-state"&gt;a VM&amp;rsquo;s state&lt;/a&gt;), so a folder made again at that path is there too, and &lt;a href="#a-folder-made-again"&gt;a folder made again&lt;/a&gt; covers it, and so is a path devvm can&amp;rsquo;t read for another reason, such as its permissions. When nothing is at the path, devvm walks up to the nearest folder above it that exists and compares that folder&amp;rsquo;s device with the device in the &lt;code&gt;folder&lt;/code&gt; identity the state records, or, for a state that records the folder&amp;rsquo;s volume (&lt;code&gt;folder_volume&lt;/code&gt;), that folder&amp;rsquo;s volume with it, so a disk that a restart numbered anew isn&amp;rsquo;t taken for another (&lt;a href="https://next.devvm.dev/docs/internals/security/#one-vm-per-folder"&gt;one VM per folder&lt;/a&gt;). The same device means the folder was deleted or moved from that filesystem, so it&amp;rsquo;s gone. Another device means it was on a disk or share that isn&amp;rsquo;t mounted, so it&amp;rsquo;s not connected, and a folder moved to another disk and then deleted counts as not connected too, which is the safe mistake. A state with no &lt;code&gt;folder&lt;/code&gt; identity, or a device devvm can&amp;rsquo;t read, counts as gone. &lt;code&gt;devvm ls&lt;/code&gt; and &lt;code&gt;devvm space&lt;/code&gt; check every VM&amp;rsquo;s path when they list it, and neither &lt;code&gt;devvm gc&lt;/code&gt; nor retention treats such a VM as leftover state, because its backend still has it.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm rm VM&lt;/code&gt; finds the VM by the &lt;code&gt;name&lt;/code&gt; or &lt;code&gt;alias&lt;/code&gt; in each state file, and nothing else, so a folder&amp;rsquo;s name never matches (&lt;code&gt;rm_unknown_vm&lt;/code&gt;). A VM whose &lt;code&gt;dir&lt;/code&gt; is the folder devvm runs in goes through &lt;code&gt;devvm rm&lt;/code&gt; when it&amp;rsquo;s that folder&amp;rsquo;s own VM, the one the folder&amp;rsquo;s lookup finds (&lt;a href="#a-vms-folder"&gt;a VM&amp;rsquo;s folder&lt;/a&gt;). A VM whose &lt;code&gt;dir&lt;/code&gt; names a folder with another VM of its own, which only a state changed by hand can, is a VM whose folder is there, so &lt;code&gt;devvm rm VM&lt;/code&gt; never sends the command to that folder&amp;rsquo;s own VM. Otherwise devvm refuses a VM whose folder is there (&lt;code&gt;rm_vm_folder_there&lt;/code&gt;), and one that its backend no longer has (&lt;code&gt;rm_vm_lost&lt;/code&gt;). It then refuses a &lt;code&gt;--clone&lt;/code&gt; VM unless &lt;code&gt;--no-clone-check&lt;/code&gt; (&lt;code&gt;rm_gone_clone&lt;/code&gt;), because there&amp;rsquo;s no repo to fetch the clone&amp;rsquo;s work into. When the VM has an agent and &lt;code&gt;--no-export&lt;/code&gt; isn&amp;rsquo;t given, it refuses a stopped VM that mounts its folder (&lt;code&gt;rm_gone_stopped&lt;/code&gt;), because Lima makes a missing folder that a VM mounts as the VM starts, and the export would make the project folder again. It asks next (&lt;code&gt;delete_gone_folder_vm&lt;/code&gt;), which &lt;code&gt;--force&lt;/code&gt; answers, and where devvm can&amp;rsquo;t ask it refuses unless &lt;code&gt;--force&lt;/code&gt; (&lt;code&gt;no_input&lt;/code&gt;). For a folder that isn&amp;rsquo;t connected, it refuses where devvm can&amp;rsquo;t ask, even with &lt;code&gt;--force&lt;/code&gt; (&lt;code&gt;rm_vm_not_connected&lt;/code&gt;), and otherwise it asks (&lt;code&gt;delete_not_connected_folder_vm&lt;/code&gt;), which &lt;code&gt;--force&lt;/code&gt; never answers. Once you answer, it reads the VM&amp;rsquo;s state again and checks that the folder is still in the state it found, and the VM&amp;rsquo;s status when it&amp;rsquo;s to be exported, once more, because the folder may have come back while it asked, another devvm may have made the VM again, or stopped it: each of those keeps the VM, with the same refusals. Last, it exports the history from the running VM, or from a &lt;code&gt;--clone&lt;/code&gt; VM it starts, and deletes the VM as &lt;code&gt;devvm rm&lt;/code&gt; does (&lt;a href="#deleting-a-vm"&gt;deleting a VM&lt;/a&gt;). A failed export keeps the VM (&lt;code&gt;export_failed_kept&lt;/code&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="a-subfolders-vm"&gt;A subfolder&amp;rsquo;s VM&lt;span class="hx:absolute hx:-mt-20" id="a-subfolders-vm"&gt;&lt;/span&gt;
&lt;a href="#a-subfolders-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm finds a folder&amp;rsquo;s VM by the state that records the folder&amp;rsquo;s physical path (&lt;a href="#a-vms-folder"&gt;a VM&amp;rsquo;s folder&lt;/a&gt;), so devvm in a subfolder finds no state file and names a new VM that doesn&amp;rsquo;t exist. When the backend has no VM by that name and devvm has no state file for the folder, and no VM whose folder moved there (&lt;a href="#a-moved-folder"&gt;a moved folder&lt;/a&gt;), devvm checks the folders the current folder is inside, nearest first (&lt;a href="https://next.devvm.dev/docs/using/vms/#a-subfolder"&gt;a subfolder&lt;/a&gt;). It finds each parent&amp;rsquo;s state file by that parent&amp;rsquo;s path in the same way, and it passes over only the parents that have no state file. The search stops at the first parent with a state file. devvm uses that parent&amp;rsquo;s VM when its backend has the VM and the state&amp;rsquo;s &lt;code&gt;dir&lt;/code&gt; and &lt;code&gt;folder&lt;/code&gt; match that folder. Otherwise the current folder has no VM, so a command that needs one says there&amp;rsquo;s no VM for it, and &lt;code&gt;devvm&lt;/code&gt; makes a new one. A parent that was deleted and made again since its VM was made fails the folder check, and so does a nested project folder that a VM replaced through its mount, because a folder made again gets a new device and inode. Stopping there keeps devvm from skipping the nested folder&amp;rsquo;s VM for the VM of a folder further out, such as the VM that replaced it. A folder with a state file of its own uses a parent&amp;rsquo;s VM only with &lt;code&gt;--parent&lt;/code&gt;, even when its backend has lost its own, so &lt;code&gt;devvm rm&lt;/code&gt; there never reaches past it to a parent&amp;rsquo;s unless you ask for that. The current folder&amp;rsquo;s path is physical, with its links resolved, so a subfolder that is a link to a folder elsewhere is looked up from where it points, never from the folder that holds the link. devvm reads the current folder only for a command that acts on a folder&amp;rsquo;s VM, so &lt;code&gt;devvm build&lt;/code&gt;, &lt;code&gt;devvm rebuild&lt;/code&gt;, &lt;code&gt;devvm images&lt;/code&gt;, &lt;code&gt;devvm space&lt;/code&gt; and &lt;code&gt;devvm gc&lt;/code&gt; also run in a folder that has been deleted.&lt;/p&gt;
&lt;p&gt;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 &lt;code&gt;--unsafe-folder&lt;/code&gt; would otherwise open in every folder below it. Using a parent&amp;rsquo;s VM changes nothing about what it mounts, because the current folder is already inside its project folder at the same path.&lt;/p&gt;
&lt;p&gt;Every command that acts on the folder&amp;rsquo;s VM, &lt;code&gt;devvm&lt;/code&gt; included, decides in one place which VM the folder uses, from what it found and the command&amp;rsquo;s &lt;code&gt;--here&lt;/code&gt; or &lt;code&gt;--parent&lt;/code&gt;, so they all decide the same way, with or without a terminal. By default, the folder&amp;rsquo;s own VM wins when it has a state file or its backend has the VM. Otherwise the parent&amp;rsquo;s VM is used, unless a repo of its own is in between, and otherwise the folder has none. A repo in between doesn&amp;rsquo;t count when the parent&amp;rsquo;s VM is a &lt;a href="https://next.devvm.dev/docs/using/clone/#folders-of-repos"&gt;workspace clone&lt;/a&gt; whose state records that repo, by its path relative to the parent&amp;rsquo;s folder (&lt;code&gt;clone.repos&lt;/code&gt;), because that VM has the repo&amp;rsquo;s clone at the same path and mounts nothing of this machine, so its folders are the VM&amp;rsquo;s as the parent&amp;rsquo;s own are. &lt;code&gt;--here&lt;/code&gt; takes the folder&amp;rsquo;s own VM and never looks at the parents. &lt;code&gt;--parent&lt;/code&gt; looks at the parents even when the folder has a VM of its own, takes the parent&amp;rsquo;s VM across a repo of its own, and fails when no parent has a VM (&lt;code&gt;no_parent_vm&lt;/code&gt;). A command that uses a parent&amp;rsquo;s VM first names the VM and its folder (&lt;code&gt;using_parent_vm&lt;/code&gt;) and asks nothing more, except &lt;code&gt;devvm rm&lt;/code&gt; and the commands that give the VM more access. &lt;code&gt;devvm rm&lt;/code&gt; then asks before deleting a parent&amp;rsquo;s VM (&lt;code&gt;delete_parent_vm&lt;/code&gt;), with or without &lt;code&gt;-f&lt;/code&gt;, and without a terminal it refuses (&lt;code&gt;rm_parent_vm&lt;/code&gt;). The commands that give a parent&amp;rsquo;s VM more access, which &lt;a href="https://next.devvm.dev/docs/using/vms/#a-subfolder"&gt;a subfolder&lt;/a&gt; lists, ask before changing the VM (&lt;code&gt;widen_parent_vm&lt;/code&gt;, &lt;code&gt;[y/N]&lt;/code&gt;) and refuse without a terminal (&lt;code&gt;widen_parent_vm_refused&lt;/code&gt;). They ask because the parent folder&amp;rsquo;s project chose its VM&amp;rsquo;s access, and a subfolder can be a project of its own that only happens to sit inside it. &lt;code&gt;devvm adopt&lt;/code&gt; looks only for the VM of this folder&amp;rsquo;s own path, and &lt;code&gt;devvm --clone&lt;/code&gt; skips the lookup, as &lt;code&gt;--here&lt;/code&gt; does, so it makes the folder&amp;rsquo;s own VM. devvm passes the current folder to the backend as the shell&amp;rsquo;s working folder, and &lt;code&gt;devvm host&lt;/code&gt; and &lt;code&gt;devvm code&lt;/code&gt; use it as the folder to open. For a &lt;code&gt;--clone&lt;/code&gt; VM, devvm first checks in the VM that the clone has the folder, and uses the clone&amp;rsquo;s top folder when it doesn&amp;rsquo;t.&lt;/p&gt;
&lt;p&gt;On the way up, devvm also notes the nearest folder below the parent&amp;rsquo;s that has a &lt;code&gt;.git&lt;/code&gt; 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 &lt;code&gt;--parent&lt;/code&gt; the parent&amp;rsquo;s VM is passed over. &lt;code&gt;devvm&lt;/code&gt; then makes the folder&amp;rsquo;s own VM without asking, and every other command fails with &lt;code&gt;no_vm&lt;/code&gt;.&lt;/p&gt;
&lt;h2 data-hextra-search-id="listing-vms"&gt;Listing VMs&lt;span class="hx:absolute hx:-mt-20" id="listing-vms"&gt;&lt;/span&gt;
&lt;a href="#listing-vms" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Every command that reads all the VMs, such as &lt;code&gt;devvm ls&lt;/code&gt;, &lt;code&gt;devvm space&lt;/code&gt;, &lt;code&gt;devvm gc&lt;/code&gt; and the writing of the ssh config, reads them in one place. It reads each VM&amp;rsquo;s state file on its own, then asks the backends for their VMs, each within 30 seconds, so one that hangs makes only its own VMs unknown. &lt;code&gt;devvm ls&lt;/code&gt; and &lt;code&gt;devvm space&lt;/code&gt; ask every backend, so they see a VM whose state is gone too. The ssh config and &lt;code&gt;devvm gc --orphans&lt;/code&gt; ask only the backends that some VM&amp;rsquo;s state names, so a backend you don&amp;rsquo;t use, such as one that isn&amp;rsquo;t installed, never slows them down. The commands that need only what the states say read the states alone and ask no backend. They are &lt;code&gt;devvm secret&lt;/code&gt;&amp;rsquo;s list, &lt;code&gt;devvm rm VM&lt;/code&gt;, &lt;code&gt;devvm adopt VM&lt;/code&gt; and &lt;code&gt;devvm link add&lt;/code&gt; finding a VM by its name, finding a folder&amp;rsquo;s VM by the folder its state records and a VM whose folder moved there (&lt;a href="#a-moved-folder"&gt;a moved folder&lt;/a&gt;), the links&amp;rsquo; checks, and the check of whether a key for devvm&amp;rsquo;s SSH agent is in a folder that a VM mounts, so that check counts the folders of stopped VMs too.&lt;/p&gt;
&lt;p&gt;All of them fail in the same cases. A backend that can&amp;rsquo;t list its VMs, for example because Lima isn&amp;rsquo;t installed, fails &lt;code&gt;devvm ls&lt;/code&gt; and the writing of the ssh config only when a VM&amp;rsquo;s state names that backend, and the ssh config then stays as it was rather than lose the entries of that backend&amp;rsquo;s VMs. &lt;code&gt;devvm space&lt;/code&gt; and &lt;code&gt;devvm gc --orphans&lt;/code&gt; name such a backend and leave its VMs alone instead. A state file that can&amp;rsquo;t be read never stops the others being read. Its VM never starts, so the commands that only read or show VMs leave it out, and &lt;code&gt;devvm ls&lt;/code&gt; lists it with its name and status alone, when its backend has it. The commands that delete by what the states say, such as &lt;code&gt;devvm gc&lt;/code&gt; with the shared tools that VMs use, and devvm&amp;rsquo;s SSH agent with the folders that VMs mount, fail and name the file, because that VM may use any shared tool or mount any folder (&lt;a href="https://next.devvm.dev/docs/using/troubleshooting/#a-file-devvm-cant-read"&gt;a file devvm can&amp;rsquo;t read&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;devvm waits 5 seconds at most to find out whether a VM&amp;rsquo;s project folder is there, for &lt;code&gt;devvm ls&lt;/code&gt;, &lt;code&gt;devvm space&lt;/code&gt;, &lt;code&gt;devvm rm VM&lt;/code&gt;, &lt;code&gt;devvm adopt VM&lt;/code&gt; and a moved folder&amp;rsquo;s match, so a folder on a network share that hangs counts as there, never as gone. Every cell of its table, and of devvm&amp;rsquo;s other tables, is shown on one line without control characters, so a folder or a status with an escape sequence or a newline in it can&amp;rsquo;t change what the terminal shows.&lt;/p&gt;
&lt;h2 data-hextra-search-id="state-files"&gt;State files&lt;span class="hx:absolute hx:-mt-20" id="state-files"&gt;&lt;/span&gt;
&lt;a href="#state-files" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm writes nothing into the project folder. It keeps its files in two folders, and the folder a file is in says who writes it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;~/.config/devvm&lt;/code&gt; (&lt;code&gt;$XDG_CONFIG_HOME/devvm&lt;/code&gt;) holds what you write: &lt;code&gt;config.toml&lt;/code&gt;, your rules for every VM in &lt;code&gt;policy&lt;/code&gt;, and your own layers and CAs. devvm never rewrites a file of yours there. It changes single lines of &lt;code&gt;policy&lt;/code&gt; when &lt;code&gt;devvm network&lt;/code&gt; adds or removes a rule for every VM, it writes a new layer&amp;rsquo;s files when you run &lt;code&gt;devvm layer new&lt;/code&gt;, and it writes the folder&amp;rsquo;s &lt;code&gt;version&lt;/code&gt; (&lt;a href="#the-layout-version"&gt;the layout version&lt;/a&gt;). &lt;a href="https://next.devvm.dev/docs/using/settings/#your-settings"&gt;Your settings&lt;/a&gt; lists the folder file by file.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;~/.local/share/devvm&lt;/code&gt; (&lt;code&gt;$XDG_DATA_HOME/devvm&lt;/code&gt;) holds everything devvm writes itself, and you never edit it. &lt;a href="https://next.devvm.dev/docs/using/space/#devvms-data-folder"&gt;devvm&amp;rsquo;s data folder&lt;/a&gt; lists it file by file, with how each one is cleaned up, and &lt;a href="https://next.devvm.dev/docs/using/space/"&gt;what devvm keeps on this machine&lt;/a&gt; also lists what Lima keeps outside it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The two folders use two formats. &lt;code&gt;config.toml&lt;/code&gt; is TOML, which devvm reads strictly, so a key it doesn&amp;rsquo;t know or a value that a key can&amp;rsquo;t take stops the command, and devvm names the file and the line (&lt;a href="https://next.devvm.dev/docs/using/settings/#when-devvm-cant-read-it"&gt;when devvm can&amp;rsquo;t read it&lt;/a&gt;). devvm&amp;rsquo;s own records are JSON: &lt;code&gt;settings.json&lt;/code&gt;, each VM&amp;rsquo;s &lt;code&gt;vm.json&lt;/code&gt;, each image&amp;rsquo;s record and each shared tool image&amp;rsquo;s record. devvm ignores a field it doesn&amp;rsquo;t know in them, so a field that a newer devvm adds doesn&amp;rsquo;t stop an older one, and a change that an older devvm would read wrongly goes through the &lt;a href="#the-layout-version"&gt;layout version&lt;/a&gt;. devvm&amp;rsquo;s other files are small ones of its own, such as pid files, the ssh config and the pinned host keys.&lt;/p&gt;
&lt;p&gt;In the data folder, each VM has a folder of its own, &lt;code&gt;vms/&amp;lt;hash&amp;gt;/&lt;/code&gt; (&lt;a href="#a-vms-folder"&gt;a VM&amp;rsquo;s folder&lt;/a&gt;), and the rest is shared by every VM:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;settings.json&lt;/code&gt; holds the defaults devvm&amp;rsquo;s commands save, below &lt;code&gt;config.toml&lt;/code&gt;&amp;rsquo;s (&lt;a href="https://next.devvm.dev/docs/using/settings/#where-a-default-comes-from"&gt;where a default comes from&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ssh_config&lt;/code&gt; is the &lt;a href="https://next.devvm.dev/docs/internals/security/#ssh-into-vms"&gt;ssh config&lt;/a&gt; for running VMs, and each entry checks its VM against the host keys in the VM&amp;rsquo;s own folder.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;agent-keys.json&lt;/code&gt; lists the keys added to &lt;a href="https://next.devvm.dev/docs/using/ssh/#devvms-own-agent"&gt;devvm&amp;rsquo;s own SSH agent&lt;/a&gt;, with each one&amp;rsquo;s file, fingerprint, &lt;code&gt;confirm&lt;/code&gt; and &lt;code&gt;lifetime&lt;/code&gt;, and &lt;code&gt;agent.sock&lt;/code&gt; is that agent&amp;rsquo;s socket.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;secrets/&lt;/code&gt; holds each &lt;a href="https://next.devvm.dev/docs/internals/network/#where-secrets-are-saved"&gt;secret&lt;/a&gt; in a file of its own, on hosts without a Keychain.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;custom-secrets.json&lt;/code&gt; holds the definitions of &lt;a href="https://next.devvm.dev/docs/internals/network/#where-secrets-are-saved"&gt;your own secrets&lt;/a&gt;, their hosts, headers, variables and prefixes, never their values.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;images/&amp;lt;key&amp;gt;/record.json&lt;/code&gt; is each image&amp;rsquo;s record, and &lt;code&gt;images/rebuilds.json&lt;/code&gt; holds the &lt;a href="https://next.devvm.dev/docs/internals/images/#rebuilding"&gt;rebuild counters&lt;/a&gt;, by backend, &lt;code&gt;--from&lt;/code&gt; and image. &lt;code&gt;images/ubuntu.json&lt;/code&gt; is the &lt;a href="https://next.devvm.dev/docs/internals/images/#ubuntus-cloud-image"&gt;Ubuntu cloud image&lt;/a&gt; that base starts from on this machine, and &lt;code&gt;images/ubuntu/&lt;/code&gt; holds the cloud images themselves, each &lt;code&gt;&amp;lt;sha256&amp;gt;.img&lt;/code&gt;, with a download that stopped as &lt;code&gt;.img.part&lt;/code&gt; and a copy from Lima&amp;rsquo;s cache that stopped as &lt;code&gt;.img.import&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tools/&lt;/code&gt; holds the &lt;a href="https://next.devvm.dev/docs/internals/images/#the-share"&gt;shared tools&lt;/a&gt;, each image with its record. Beside it are the tools lock, &lt;code&gt;mise.lock&lt;/code&gt;, the &lt;code&gt;mise.toml&lt;/code&gt; it was resolved from, &lt;code&gt;mise.lock.toml&lt;/code&gt;, and &lt;code&gt;mise.lock.checked&lt;/code&gt;, which says when devvm last &lt;a href="https://next.devvm.dev/docs/internals/images/#versions"&gt;checked&lt;/a&gt; for newer versions.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;logs/runs/&lt;/code&gt; holds the &lt;a href="https://next.devvm.dev/docs/using/troubleshooting/#a-command-fails"&gt;run logs&lt;/a&gt;, and &lt;code&gt;logs/tools-check.log&lt;/code&gt; the daily tools check&amp;rsquo;s output.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;exports/&lt;/code&gt; holds the agents&amp;rsquo; history that &lt;code&gt;devvm history export&lt;/code&gt; and &lt;code&gt;devvm rm&lt;/code&gt; save.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;lima/&lt;/code&gt; is devvm&amp;rsquo;s own &lt;a href="https://next.devvm.dev/docs/internals/lima/#a-lima-home-of-its-own"&gt;Lima home&lt;/a&gt;, unless &lt;code&gt;DEVVM_LIMA_HOME&lt;/code&gt; moves it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;cache/&lt;/code&gt; holds only what devvm makes again whenever it needs it, so it may be deleted at any time. That&amp;rsquo;s devvm&amp;rsquo;s own mise (&lt;code&gt;cache/mise/&lt;/code&gt;), the &lt;a href="https://next.devvm.dev/docs/internals/network/#the-shared-nix-cache"&gt;shared Nix cache&lt;/a&gt; (&lt;code&gt;cache/nix-cache/&lt;/code&gt;) and the &lt;a href="https://next.devvm.dev/docs/internals/images/#digests"&gt;digests&lt;/a&gt; of the container images that &lt;code&gt;--from&lt;/code&gt; bases start from (&lt;code&gt;cache/from-digests.json&lt;/code&gt;). &lt;code&gt;run/&lt;/code&gt; holds what running VMs need that isn&amp;rsquo;t one VM&amp;rsquo;s, or whose path must be short: the QEMU wrapper on Linux hosts, the claims lock and, while devvm makes a folder&amp;rsquo;s VM, the folder&amp;rsquo;s creation lock (&lt;a href="#locks"&gt;locks&lt;/a&gt;), the sockets of port forwarders and link sessions, named by hashes, in &lt;code&gt;build-ports/&lt;/code&gt; the ssh port of each build VM that&amp;rsquo;s starting (&lt;a href="#locks"&gt;locks&lt;/a&gt;), and in &lt;code&gt;builds/&amp;lt;name&amp;gt;/&lt;/code&gt; each build VM&amp;rsquo;s folder, laid out as a VM&amp;rsquo;s folder is. devvm deletes a build VM&amp;rsquo;s folder once its image is built, because an image&amp;rsquo;s VM never starts again, and otherwise when it deletes the build VM.&lt;/p&gt;
&lt;p&gt;Each write replaces a file whole, so a file is never left half written. devvm makes its files readable only by you (mode 600), and the programs it keeps to run, such as its mise and QEMU wrapper, are mode 700, as are its folders. Before every command, devvm makes the data folder and &lt;code&gt;~/.config/devvm&lt;/code&gt; when they&amp;rsquo;re missing and sets both to mode 700, whatever mode they had. A wider mode on anything beneath them then opens nothing to others, and when devvm can&amp;rsquo;t set a folder&amp;rsquo;s mode, it warns and goes on. The folders that hold history, logs, keys or secrets (&lt;code&gt;exports/&lt;/code&gt;, &lt;code&gt;logs/&lt;/code&gt;, &lt;code&gt;logs/runs/&lt;/code&gt;, &lt;code&gt;run/&lt;/code&gt;, &lt;code&gt;secrets/&lt;/code&gt;, and the &lt;code&gt;run/&lt;/code&gt;, &lt;code&gt;run/ca/&lt;/code&gt; and &lt;code&gt;logs/&lt;/code&gt; folders in each VM&amp;rsquo;s folder) are set to mode 700 again whenever devvm writes an export, a log, a key or a secret into them, whatever mode they had before. devvm refuses to use one of those folders when it&amp;rsquo;s a symbolic link or not a folder at all, so it never sets the mode of whatever a link points to. The data folder and &lt;code&gt;~/.config/devvm&lt;/code&gt; may be symbolic links, such as into a dotfiles repo, and devvm follows them. When a file can&amp;rsquo;t be read, devvm names the file and the line, and you fix the line or delete the file.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-run-log"&gt;The run log&lt;span class="hx:absolute hx:-mt-20" id="the-run-log"&gt;&lt;/span&gt;
&lt;a href="#the-run-log" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Each run that runs a command has one log, &lt;code&gt;~/.local/share/devvm/logs/runs/&amp;lt;date&amp;gt;-&amp;lt;time&amp;gt;-&amp;lt;pid&amp;gt;.log&lt;/code&gt;, which only you can read. devvm keeps the newest 20, or as many as &lt;code&gt;logs.runs&lt;/code&gt; sets, and deletes older ones once the logs take more than 256 MiB together. It never deletes the newest log, or the log of a run whose process still runs, which it tells from the pid in the log&amp;rsquo;s name, so a background process or another devvm never loses the log it&amp;rsquo;s writing (&lt;a href="https://next.devvm.dev/docs/using/troubleshooting/#a-command-fails"&gt;a command fails&lt;/a&gt;). In the log, each command appears as a &lt;code&gt;+&lt;/code&gt; line with its arguments, followed by its output, and a numbered step adds a &lt;code&gt;# [2/5] &amp;lt;step&amp;gt;&lt;/code&gt; line first. A command that devvm runs in a VM adds at most 4 MiB of output to the log, because a VM could otherwise fill this machine&amp;rsquo;s disk with it, and a &lt;code&gt;devvm: truncated&lt;/code&gt; line marks where devvm left out the rest. A run writes at most 128 MiB to its log in all, because a run that lasts, such as &lt;code&gt;devvm desktop&lt;/code&gt;&amp;rsquo;s, could otherwise log without end, and a &lt;code&gt;devvm: truncated&lt;/code&gt; line also marks where that limit cut the log.&lt;/p&gt;
&lt;p&gt;A VM&amp;rsquo;s proxy key and the build proxy&amp;rsquo;s password are written as &lt;code&gt;devvm:&amp;lt;key&amp;gt;@&lt;/code&gt;. Any other password in a URL, in a command&amp;rsquo;s arguments or its output, is written as &lt;code&gt;user:&amp;lt;password&amp;gt;@&lt;/code&gt;, and so is the password in a proxy&amp;rsquo;s address without a scheme, such as &lt;code&gt;user:[email protected]:8080&lt;/code&gt;, when the address has a port. So a company proxy&amp;rsquo;s password from your shell&amp;rsquo;s &lt;code&gt;HTTPS_PROXY&lt;/code&gt;, which Lima can print as it starts a VM, stays out of the log, even when a command writes it in pieces. This covers the output of the commands devvm runs in a VM too, such as a VM&amp;rsquo;s setup or a &lt;code&gt;devcontainer.json&lt;/code&gt;&amp;rsquo;s commands.&lt;/p&gt;
&lt;p&gt;With &lt;code&gt;-v&lt;/code&gt;, the lines devvm shows are the log&amp;rsquo;s own, so a VM&amp;rsquo;s proxy key is hidden in them as it is in the log, and devvm drops the control characters a command prints, so its output can&amp;rsquo;t move the cursor or change your terminal.&lt;/p&gt;
&lt;p&gt;Lima keeps a log of its own for each VM, &lt;code&gt;ha.stderr.log&lt;/code&gt; in the VM&amp;rsquo;s folder in devvm&amp;rsquo;s Lima home, and it writes a proxy password into that log as it starts the VM. Lima also keeps a log of each of the VM&amp;rsquo;s serial consoles there, &lt;code&gt;serial.log&lt;/code&gt;, &lt;code&gt;serialp.log&lt;/code&gt; or &lt;code&gt;serialv.log&lt;/code&gt;, and its boot scripts write the VM&amp;rsquo;s proxy URL, with the VM&amp;rsquo;s proxy password, to the console as they set up the VM&amp;rsquo;s environment. Once Lima has started the VM, devvm replaces each password in those logs with as many &lt;code&gt;*&lt;/code&gt;, so the log keeps its length and Lima goes on writing to it. If devvm can&amp;rsquo;t change the file, it warns you and names it, and you can delete the file, which Lima makes again at the VM&amp;rsquo;s next start. While the VM runs, its proxy also replaces each password that these logs gain, within a second of its line ending, so a reboot inside the VM, which on Linux hosts QEMU carries out in place and which runs the boot scripts again, can&amp;rsquo;t leave the password in the console&amp;rsquo;s log. The proxy also holds the disk space that each of these logs takes to 10 MiB, with a &lt;code&gt;.1&lt;/code&gt; file of as much, on a file system with holes (&lt;a href="https://next.devvm.dev/docs/internals/processes/#limas-hostagent"&gt;Lima&amp;rsquo;s hostagent&lt;/a&gt;). A rotation&amp;rsquo;s copy, such as &lt;code&gt;ha.stderr.log.1&lt;/code&gt;, has each password replaced, whether the start had ended or not.&lt;/p&gt;
&lt;h3 data-hextra-search-id="a-vms-folder"&gt;A VM&amp;rsquo;s folder&lt;span class="hx:absolute hx:-mt-20" id="a-vms-folder"&gt;&lt;/span&gt;
&lt;a href="#a-vms-folder" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Each VM&amp;rsquo;s folder, &lt;code&gt;vms/&amp;lt;hash&amp;gt;/&lt;/code&gt;, is named by the hash at the end of the VM&amp;rsquo;s name, which is the hash of its project folder&amp;rsquo;s physical path when devvm made the VM, and it holds every file that devvm keeps for the VM in the data folder:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Path in &lt;code&gt;vms/&amp;lt;hash&amp;gt;/&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;Holds&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;vm.json&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s state (&lt;a href="#a-vms-state"&gt;a VM&amp;rsquo;s state&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the lock that each change to &lt;code&gt;vm.json&lt;/code&gt; holds (&lt;a href="#locks"&gt;locks&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;policy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s own &lt;a href="https://next.devvm.dev/docs/internals/network/#policy-files"&gt;network rules&lt;/a&gt;, which &lt;code&gt;devvm network allow&lt;/code&gt;, &lt;code&gt;deny&lt;/code&gt; and &lt;code&gt;rm&lt;/code&gt; change&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;run/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;what the VM&amp;rsquo;s runs leave: its &lt;a href="https://next.devvm.dev/docs/internals/security/#ssh-into-vms"&gt;host keys&lt;/a&gt; for its current start (&lt;code&gt;known_hosts&lt;/code&gt;), which every ssh of devvm&amp;rsquo;s to the VM checks, its &lt;a href="https://next.devvm.dev/docs/internals/ports/#its-process-and-files"&gt;port forwarder&lt;/a&gt;&amp;rsquo;s &lt;code&gt;ports.pid&lt;/code&gt;, &lt;code&gt;ports.status&lt;/code&gt; and &lt;code&gt;ports.lock&lt;/code&gt;, its &lt;a href="https://next.devvm.dev/docs/internals/network/#the-proxy"&gt;proxy&lt;/a&gt;&amp;rsquo;s config, &lt;code&gt;proxy.json&lt;/code&gt;, which holds everything the proxy started with, its password and the &lt;a href="https://next.devvm.dev/docs/internals/network/#through-a-company-proxy"&gt;company proxy&lt;/a&gt;&amp;rsquo;s from the environment among it (&lt;a href="https://next.devvm.dev/docs/internals/network/#devvm-_proxy"&gt;devvm _proxy&lt;/a&gt;), and its &lt;code&gt;proxy.pid&lt;/code&gt; and &lt;code&gt;proxy.status&lt;/code&gt;, its broker&amp;rsquo;s child&amp;rsquo;s &lt;code&gt;proxy-child.pid&lt;/code&gt; and how the child is confined, &lt;code&gt;proxy.confined&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/processes/#a-vms-proxy"&gt;processes&lt;/a&gt;), the VM&amp;rsquo;s own &lt;a href="https://next.devvm.dev/docs/internals/network/#the-vms-ca"&gt;CA&lt;/a&gt; and the next one in &lt;code&gt;ca/&lt;/code&gt; (&lt;code&gt;ca.pem&lt;/code&gt; and &lt;code&gt;ca.key&lt;/code&gt;, &lt;code&gt;next.pem&lt;/code&gt; and &lt;code&gt;next.key&lt;/code&gt;, and their &lt;code&gt;lock&lt;/code&gt;), whose keys never leave this machine, its &lt;a href="https://next.devvm.dev/docs/internals/network/#how-the-proxy-puts-them-in"&gt;secrets&lt;/a&gt;&amp;rsquo; bindings (&lt;code&gt;secrets.json&lt;/code&gt;, &lt;code&gt;secrets.policy&lt;/code&gt;), its &lt;a href="https://next.devvm.dev/docs/internals/ports/#the-link-session"&gt;link session&lt;/a&gt;&amp;rsquo;s &lt;code&gt;links.pid&lt;/code&gt; and &lt;code&gt;links.json&lt;/code&gt;, the &lt;a href="#making-a-vm-again"&gt;remake lock&lt;/a&gt; (&lt;code&gt;remake.lock&lt;/code&gt;), the hostagent it was started on (&lt;code&gt;started&lt;/code&gt;), the &lt;a href="https://next.devvm.dev/docs/internals/lima/#what-devvm-sets-on-a-vm"&gt;ssh port&lt;/a&gt; its last start held for a minute (&lt;code&gt;ports.ssh-hold&lt;/code&gt;), and on macOS the hostagent&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;sandbox profile&lt;/a&gt; (&lt;code&gt;sandbox.sb&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;logs/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;its proxy&amp;rsquo;s decisions (&lt;code&gt;network.jsonl&lt;/code&gt;) and its proxy&amp;rsquo;s broker&amp;rsquo;s and child&amp;rsquo;s own output (&lt;code&gt;proxy.log&lt;/code&gt;), which the &lt;a href="https://next.devvm.dev/docs/internals/network/#log-files"&gt;log files&lt;/a&gt; describe, its link session&amp;rsquo;s output (&lt;code&gt;links.log&lt;/code&gt;) and its port forwarder&amp;rsquo;s (&lt;code&gt;ports.log&lt;/code&gt;), each held to 1 MiB with one &lt;code&gt;.1&lt;/code&gt; file. The proxy&amp;rsquo;s child writes this folder, so devvm never opens the files in it through a link&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;home.tar.gz&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s home folder, only while devvm &lt;a href="#making-a-vm-again"&gt;makes the VM again&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;devvm finds a folder&amp;rsquo;s VM by the state that records the folder&amp;rsquo;s path as its &lt;code&gt;dir&lt;/code&gt;, first in the VM folder that the hash of that path names and then in every other VM&amp;rsquo;s (&lt;a href="#a-moved-folder"&gt;a moved folder&lt;/a&gt;), so an existing VM has the name and the backend its state records, whichever backend you ask for. Only a new VM gets a name, which fits its backend&amp;rsquo;s limit, and when the VM folder that the path&amp;rsquo;s hash names holds another VM&amp;rsquo;s state, the new VM&amp;rsquo;s name ends with the hash of the path and a number instead, the first whose folder is free. The VM&amp;rsquo;s folder lasts as long as the VM, because &lt;code&gt;devvm rm&lt;/code&gt; and &lt;code&gt;devvm gc --orphans&lt;/code&gt; stop what runs for the VM, delete what devvm keeps for it outside the folder, and then delete the folder whole (&lt;a href="#deleting-a-vm"&gt;deleting a VM&lt;/a&gt;), so the next devvm in that folder starts fresh.&lt;/p&gt;
&lt;p&gt;No VM&amp;rsquo;s folder holds a socket, because a unix socket&amp;rsquo;s path has fewer than 104 characters and ssh adds 17 to a control socket&amp;rsquo;s while it makes it. The sockets that VMs need are in &lt;code&gt;run/&lt;/code&gt;, named by hashes: each port forwarder&amp;rsquo;s control socket, &lt;code&gt;run/port-&amp;lt;hash&amp;gt;.ctl&lt;/code&gt;, and each link session&amp;rsquo;s &lt;code&gt;run/link-&amp;lt;hash&amp;gt;.sock&lt;/code&gt; and &lt;code&gt;run/link-&amp;lt;hash&amp;gt;.ctl&lt;/code&gt;. With the default data folder, every socket fits for a home folder of up to 37 characters, and the ssh control sockets are the longest.&lt;/p&gt;
&lt;h3 data-hextra-search-id="a-vms-state"&gt;A VM&amp;rsquo;s state&lt;span class="hx:absolute hx:-mt-20" id="a-vms-state"&gt;&lt;/span&gt;
&lt;a href="#a-vms-state" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A VM&amp;rsquo;s state is &lt;code&gt;vm.json&lt;/code&gt;, a JSON file that only devvm writes. It starts with the fields every VM has: the file&amp;rsquo;s &lt;code&gt;version&lt;/code&gt;, the VM&amp;rsquo;s random &lt;code&gt;id&lt;/code&gt;, its &lt;code&gt;name&lt;/code&gt; and its ssh &lt;code&gt;alias&lt;/code&gt;, the &lt;code&gt;image&lt;/code&gt; the VM came from with its build &lt;code&gt;chain&lt;/code&gt; and the &lt;code&gt;from&lt;/code&gt; image its base started from, its project folder (&lt;code&gt;dir&lt;/code&gt;) and that folder&amp;rsquo;s identity (&lt;code&gt;folder&lt;/code&gt;), the volume it&amp;rsquo;s on (&lt;code&gt;folder_volume&lt;/code&gt;, bound to the folder&amp;rsquo;s inode and birth time, where devvm can tell it), &lt;code&gt;folder_unchecked&lt;/code&gt; while that volume is still to check after a renumbering (&lt;a href="https://next.devvm.dev/docs/internals/security/#one-vm-per-folder"&gt;one VM per folder&lt;/a&gt;), its &lt;code&gt;backend&lt;/code&gt; and where that backend kept it (&lt;code&gt;backend_at&lt;/code&gt;), &lt;code&gt;created&lt;/code&gt;, the time its backend finished making it, and &lt;code&gt;made_by&lt;/code&gt;, the version of the devvm that made it, which later changes keep. A VM without &lt;code&gt;created&lt;/code&gt; never starts, because its creation didn&amp;rsquo;t finish. devvm takes the &lt;code&gt;alias&lt;/code&gt; only when it&amp;rsquo;s one devvm could have chosen for the VM, which is &lt;code&gt;devvm-&amp;lt;folder&amp;gt;&lt;/code&gt; with the folder part of the VM&amp;rsquo;s own name, or the full name. An alias edited to anything else never reaches the ssh config and names no VM, so the VM is reached by its full name. After those fields comes one section for each part of devvm that keeps something of the VM&amp;rsquo;s:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Section&lt;/th&gt;
&lt;th&gt;Kept by&lt;/th&gt;
&lt;th&gt;Holds&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;net&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;network tier&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s &lt;code&gt;tier&lt;/code&gt;, and what devvm made for it: the proxy&amp;rsquo;s password, the salt that ends its placeholders and the last &lt;a href="https://next.devvm.dev/docs/internals/network/#the-self-check"&gt;self-check&lt;/a&gt;&amp;rsquo;s result&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://next.devvm.dev/docs/internals/git-protection/"&gt;.git protection&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;the mode, the mode chosen while the VM ran, and what locking found: &lt;code&gt;.git&lt;/code&gt;&amp;rsquo;s identity, the git folders it locked besides &lt;code&gt;.git&lt;/code&gt;, and a hash of what the locked files hand over to the project folder&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ports&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the port allocator&lt;/td&gt;
&lt;td&gt;which ports the VM forwards, and the host ports devvm chose for its ssh, its proxy and its desktop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agent&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;SSH agent forwarding&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s choice, the start devvm last started it with, and whether that start forwarded its proxy&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/processes/#the-ssh-agents"&gt;relay&lt;/a&gt; of the agent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tools&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the shared tools&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s shared tools by name, and their images and C library&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;secrets&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;secrets&lt;/td&gt;
&lt;td&gt;the secrets bound to the VM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;size&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;devvm size&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the CPUs, memory and disk asked for&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;clone&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--clone&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;whether the VM has its own clone, the repo&amp;rsquo;s remote for it, and whether its branches were copied in; a folder of repos&amp;rsquo; repos, each with the same; and each repo&amp;rsquo;s submodules the VM has a clone of (&lt;code&gt;submodules&lt;/code&gt;), nested ones too, each with its path in its repo&amp;rsquo;s folder, its remote and whether it was copied, so &lt;code&gt;devvm clone fetch&lt;/code&gt; and &lt;code&gt;devvm rm&lt;/code&gt;&amp;rsquo;s check go over each one the VM has, even when this machine&amp;rsquo;s repo no longer has it. An older devvm ignores &lt;code&gt;submodules&lt;/code&gt;, so its &lt;code&gt;devvm rm&lt;/code&gt; wouldn&amp;rsquo;t check them, which matters only after a downgrade&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;devcontainer&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a devcontainer.json&lt;/td&gt;
&lt;td&gt;the file the VM was made from, its variables and commands, which of them ran, and what of the VM came from the file and what from you (&lt;a href="#reading-the-devcontainerjson-again"&gt;reading it again&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;desktop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;devvm desktop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the desktop&amp;rsquo;s password&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;links&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;links and groups&lt;/td&gt;
&lt;td&gt;the ports the VM publishes, its links and its group&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;remake&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;devvm layer add&lt;/code&gt;, &lt;code&gt;devvm layer rm&lt;/code&gt;, &lt;code&gt;devvm update&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;while devvm &lt;a href="#making-a-vm-again"&gt;makes the VM again&lt;/a&gt;: the new image, the command, whether the home folder is kept and the history exported, what &lt;code&gt;devvm update&lt;/code&gt; read again of the &lt;code&gt;devcontainer.json&lt;/code&gt;, whether the new machine was made and what the VM had before it, and whether it&amp;rsquo;s done&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;moved&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="#a-moved-folder"&gt;a moved folder&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;the path the folder had before it moved, until the VM&amp;rsquo;s next setup moves Claude Code&amp;rsquo;s history from it&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Each section keeps what you asked for apart from what devvm made, which sits under the section&amp;rsquo;s &lt;code&gt;made&lt;/code&gt;. devvm reads fields it doesn&amp;rsquo;t know without complaint and keeps them when it writes the file. A file that isn&amp;rsquo;t JSON, lacks one of &lt;code&gt;version&lt;/code&gt;, &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;image&lt;/code&gt;, &lt;code&gt;dir&lt;/code&gt; or &lt;code&gt;backend&lt;/code&gt;, or holds a section devvm can&amp;rsquo;t read is refused, and devvm names the file.&lt;/p&gt;
&lt;p&gt;A new VM&amp;rsquo;s whole state is written once, with everything you asked for, before its backend makes the VM.&lt;/p&gt;
&lt;h3 data-hextra-search-id="locks"&gt;Locks&lt;span class="hx:absolute hx:-mt-20" id="locks"&gt;&lt;/span&gt;
&lt;a href="#locks" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Reading a VM&amp;rsquo;s state takes no lock, because each write replaces the file whole. Each change takes the VM&amp;rsquo;s &lt;code&gt;lock&lt;/code&gt;, reads the file again, makes the change and writes the file once, so a command&amp;rsquo;s changes land together or not at all, and two devvms changing one VM at once lose neither&amp;rsquo;s change. Deleting a VM&amp;rsquo;s folder takes the VM&amp;rsquo;s &lt;code&gt;lock&lt;/code&gt; too, so a change that another devvm is making to the VM&amp;rsquo;s state lands before the folder goes and never after it, and a VM made again in the project folder keeps its own state. A command holds one VM&amp;rsquo;s lock at a time. A change to other VMs, such as removing every link to a VM that &lt;code&gt;devvm rm&lt;/code&gt; deletes, lets go of the first VM&amp;rsquo;s lock and then takes each other VM&amp;rsquo;s lock in turn, reading each one&amp;rsquo;s state again before it changes it. What no two VMs may have, a new VM&amp;rsquo;s ssh alias and the host ports devvm chooses, is chosen under the claims lock, &lt;code&gt;run/claims.lock&lt;/code&gt;, which devvm takes after the VM&amp;rsquo;s own lock and holds until the VM&amp;rsquo;s state is written. A build VM has no state, so devvm chooses its ssh port under the claims lock alone and records it in &lt;code&gt;run/build-ports/&amp;lt;name&amp;gt;&lt;/code&gt; while the VM starts, which keeps any other VM from getting that port until Lima has bound it. Each project VM&amp;rsquo;s start records the ssh port it holds in the VM&amp;rsquo;s own folder, as &lt;code&gt;run/ports.ssh-hold&lt;/code&gt;. Each choice of a port reads that file for a minute while Lima binds the port, so no other start or build takes it, whether the start kept the VM&amp;rsquo;s port or chose a new one (&lt;a href="https://next.devvm.dev/docs/internals/lima/#what-devvm-sets-on-a-vm"&gt;the ssh port&lt;/a&gt;). The port is never the one that the build VM&amp;rsquo;s config kept from the image it&amp;rsquo;s a clone of, so its start always sets the new port and a build&amp;rsquo;s numbered steps are the same each time. The devvm that starts the build holds a file lock on the record while it&amp;rsquo;s there, so a record whose lock no process holds was left by a devvm that was killed. Once such a record is 15 minutes old, longer than Lima waits for a VM&amp;rsquo;s ssh, devvm deletes it the next time it chooses a port.&lt;/p&gt;
&lt;p&gt;A folder&amp;rsquo;s creation lock, &lt;code&gt;run/create-&amp;lt;hash&amp;gt;.lock&lt;/code&gt;, keeps two devvms from making one folder&amp;rsquo;s VM at once. It lives outside the VM&amp;rsquo;s folder because a new VM&amp;rsquo;s creation deletes that folder and makes it again. When &lt;code&gt;devvm&lt;/code&gt; finds that the folder has no VM, or has its own VM whose creation didn&amp;rsquo;t finish, it takes the lock before the new VM&amp;rsquo;s questions and reads the VM&amp;rsquo;s state again under it. If another devvm made the VM meanwhile, devvm opens that VM as it is. devvm holds the lock until it has recorded that it made the VM, and lets go of it before the VM&amp;rsquo;s first start, so another devvm in the folder then opens the VM. After an interrupt, devvm lets go of the lock only once it has deleted what it made. A second devvm that finds the lock held refuses at once (&lt;code&gt;create_running&lt;/code&gt;) and never waits on the first one&amp;rsquo;s questions. &lt;code&gt;devvm rm&lt;/code&gt; takes the lock too before it deletes a VM, because a VM whose creation didn&amp;rsquo;t finish may be one another devvm is making, and one whose machine the backend lost may be being made again. It refuses while another devvm holds the lock, and refuses as well when it finds the VM&amp;rsquo;s state changed once it has the lock. &lt;code&gt;devvm gc --orphans&lt;/code&gt; and retention&amp;rsquo;s &lt;code&gt;orphans.age&lt;/code&gt; take the lock too before they forget a VM, because a VM that a devvm is making again has its state before its backend has it, however old that state is, and they refuse while another devvm holds the lock.&lt;/p&gt;
&lt;p&gt;Every lock devvm takes is an OS file lock on an open file, which the system lets go of when the devvm holding it ends, however it ends. So a lock file is empty, it stays when its lock is let go of, and a devvm that was killed never leaves a lock held. The creation lock is the one exception that doesn&amp;rsquo;t stay: the devvm holding it deletes the file as it lets go, so no file named by the VM stays outside its folder, and a VM&amp;rsquo;s teardown deletes one that a killed devvm left. Besides each VM&amp;rsquo;s &lt;code&gt;lock&lt;/code&gt; and the claims lock, the data folder has these:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Lock&lt;/th&gt;
&lt;th&gt;Held by&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;version.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;each devvm checking the &lt;a href="#the-layout-version"&gt;layout version&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;vms/&amp;lt;hash&amp;gt;/run/ports.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;whatever stops a VM&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/ports/#its-process-and-files"&gt;port forwarder&lt;/a&gt; and starts the next one&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;vms/&amp;lt;hash&amp;gt;/run/ca/lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;each launch readying the VM&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/network/#the-vms-ca"&gt;CAs&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;vms/&amp;lt;hash&amp;gt;/run/remake.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the devvm &lt;a href="#making-a-vm-again"&gt;making a VM again&lt;/a&gt; or finishing its remake, which a second devvm finds held and refuses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;run/create-&amp;lt;hash&amp;gt;.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the devvm making a project folder&amp;rsquo;s &lt;a href="#a-new-vm"&gt;new VM&lt;/a&gt;, from before its questions until it has recorded that it made the VM, and &lt;code&gt;devvm rm&lt;/code&gt; deleting a VM, which a second devvm finds held and refuses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;images/locks/&amp;lt;key&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the devvm &lt;a href="https://next.devvm.dev/docs/internals/images/#building"&gt;building an image&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;images/locks/rebuilds&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a devvm &lt;a href="https://next.devvm.dev/docs/internals/images/#rebuilding"&gt;changing a rebuild counter&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;images/locks/ubuntu&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the devvm &lt;a href="https://next.devvm.dev/docs/internals/images/#ubuntus-cloud-image"&gt;pinning Ubuntu&amp;rsquo;s cloud image&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;images/locks/ubuntu-image&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the devvm &lt;a href="https://next.devvm.dev/docs/internals/images/#ubuntus-cloud-image"&gt;downloading Ubuntu&amp;rsquo;s cloud image&lt;/a&gt; or taking it from Lima&amp;rsquo;s cache&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;cache/mise/download.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the devvm &lt;a href="https://next.devvm.dev/docs/internals/images/#versions"&gt;downloading its own mise&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;oci-build.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a Lima build of a base &lt;a href="https://next.devvm.dev/docs/internals/images/#how-its-converted"&gt;from a container image&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tools.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a devvm &lt;a href="https://next.devvm.dev/docs/internals/images/#building-tools"&gt;writing to the share&lt;/a&gt; or swapping the tools lock&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;making.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;each devvm making a VM or giving one new shared tools, shared, and &lt;code&gt;devvm gc --tool-images --force&lt;/code&gt;, alone (&lt;a href="https://next.devvm.dev/docs/internals/images/#listing-and-cleaning-up"&gt;cleaning up&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;groups.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a devvm &lt;a href="https://next.devvm.dev/docs/contributing/design/#groups"&gt;joining or leaving a group&lt;/a&gt;, or working its links out again&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agents.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a devvm writing the agent store: &lt;a href="https://next.devvm.dev/docs/internals/agents/#importing"&gt;an import, a save, or a start cleaning Claude Code&amp;rsquo;s plugins&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;custom-secrets.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a devvm &lt;a href="https://next.devvm.dev/docs/internals/network/#where-secrets-are-saved"&gt;saving or deleting a secret of yours, or binding a VM to one&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;retention.lock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the devvm applying the &lt;a href="https://next.devvm.dev/docs/using/settings/#retention"&gt;retention settings&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 data-hextra-search-id="the-layout-version"&gt;The layout version&lt;span class="hx:absolute hx:-mt-20" id="the-layout-version"&gt;&lt;/span&gt;
&lt;a href="#the-layout-version" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The layout version says which folders and files devvm keeps in its two folders, and in which formats. This devvm&amp;rsquo;s is 1. The data folder and &lt;code&gt;~/.config/devvm&lt;/code&gt; each record theirs in a file named &lt;code&gt;version&lt;/code&gt;, which holds the number alone. Before every command, after it makes both folders private, devvm takes &lt;code&gt;version.lock&lt;/code&gt; in the data folder with an OS file lock and reads both files:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When both have this devvm&amp;rsquo;s version, the command runs.&lt;/li&gt;
&lt;li&gt;When a folder has no &lt;code&gt;version&lt;/code&gt; file, as a new folder doesn&amp;rsquo;t, devvm writes its own version there.&lt;/li&gt;
&lt;li&gt;When either one is older, devvm changes the folders to its own layout, one version at a time, and then writes its version into both files. A change that fails stops the command and leaves the versions as they were, so the next command tries again.&lt;/li&gt;
&lt;li&gt;When either one is newer, a newer devvm changed the folders, so this one would misread them. The command stops before it does anything, with a message that names the file and both versions (&lt;a href="https://next.devvm.dev/docs/using/troubleshooting/#a-newer-devvm-changed-devvms-folders"&gt;a newer devvm changed devvm&amp;rsquo;s folders&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;version&lt;/code&gt; file that doesn&amp;rsquo;t hold a whole number from 1 up stops the command too, naming the file.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Help, completion, &lt;code&gt;devvm --version&lt;/code&gt; and the commands that devvm runs itself, such as the proxy, skip the check. Each VM&amp;rsquo;s &lt;code&gt;vm.json&lt;/code&gt;, each image&amp;rsquo;s record and each shared tool image&amp;rsquo;s record also hold &lt;code&gt;made_by&lt;/code&gt;, the version of the devvm that made it, so a file from another devvm can be told apart.&lt;/p&gt;</description></item><item><title>Installing and updating</title><link>https://next.devvm.dev/docs/internals/install/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/install/</guid><description>
&lt;p&gt;This page explains what devvm&amp;rsquo;s install script downloads and checks, what &lt;code&gt;devvm doctor&lt;/code&gt; checks and what &lt;code&gt;devvm doctor --json&lt;/code&gt; reports, where devvm keeps its own files, what happens to older versions when you upgrade, and how &lt;code&gt;devvm upgrade&lt;/code&gt; checks and installs a release. &lt;a href="https://next.devvm.dev/docs/getting-started/install/"&gt;Installing&lt;/a&gt; and &lt;a href="https://next.devvm.dev/docs/using/upgrading/"&gt;Upgrading and uninstalling&lt;/a&gt; cover the commands you run.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-install-script"&gt;The install script&lt;span class="hx:absolute hx:-mt-20" id="the-install-script"&gt;&lt;/span&gt;
&lt;a href="#the-install-script" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The script installs the release it comes with, or the one that &lt;code&gt;--version&lt;/code&gt; names, which may be a prerelease, such as &lt;code&gt;0.2.0-rc.1&lt;/code&gt;. Without either, it installs the latest release, never a prerelease. Before it downloads anything, it checks whether Homebrew installed devvm, which it does when &lt;code&gt;brew&lt;/code&gt; is on &lt;code&gt;PATH&lt;/code&gt;. The check never runs &lt;code&gt;brew&lt;/code&gt;, because Homebrew can download its own Ruby when it runs. Instead, the script looks for a version folder in &lt;code&gt;Cellar/devvm&lt;/code&gt; or &lt;code&gt;Cellar/devvm-rc&lt;/code&gt;, the kegs of Homebrew&amp;rsquo;s two formulas, in each place Homebrew keeps its Cellar: the folder next to the &lt;code&gt;brew&lt;/code&gt; it found on &lt;code&gt;PATH&lt;/code&gt; (&lt;code&gt;&amp;lt;brew's folder&amp;gt;/../Cellar&lt;/code&gt;), &lt;code&gt;HOMEBREW_CELLAR&lt;/code&gt; and &lt;code&gt;HOMEBREW_PREFIX/Cellar&lt;/code&gt; when they&amp;rsquo;re set, and the Cellar in &lt;code&gt;/opt/homebrew&lt;/code&gt;, &lt;code&gt;/usr/local&lt;/code&gt; and &lt;code&gt;/home/linuxbrew/.linuxbrew&lt;/code&gt;. When Homebrew has devvm, the script stops with an error that says to run &lt;code&gt;brew upgrade devvm&lt;/code&gt;, or &lt;code&gt;brew uninstall devvm&lt;/code&gt; first, each naming &lt;code&gt;devvm-rc&lt;/code&gt; for its keg, and exits with status 1, in a terminal or without one. &lt;code&gt;--force&lt;/code&gt; skips this check. Then it installs in four steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It downloads the archive for this machine and the release&amp;rsquo;s &lt;code&gt;SHA256SUMS&lt;/code&gt;, over HTTPS only. The archive is &lt;code&gt;devvm-&amp;lt;version&amp;gt;-&amp;lt;os&amp;gt;-&amp;lt;arch&amp;gt;.tar.gz&lt;/code&gt;, where the OS is &lt;code&gt;darwin&lt;/code&gt; or &lt;code&gt;linux&lt;/code&gt; and the processor is &lt;code&gt;arm64&lt;/code&gt; or &lt;code&gt;amd64&lt;/code&gt;. On Apple silicon, the script picks &lt;code&gt;arm64&lt;/code&gt; even when it runs under Rosetta.&lt;/li&gt;
&lt;li&gt;It checks the signatures of &lt;code&gt;SHA256SUMS&lt;/code&gt;, then the archive&amp;rsquo;s checksum, as &lt;a href="#the-signature-and-what-it-trusts"&gt;the signature&lt;/a&gt; describes. When either check fails, it installs nothing.&lt;/li&gt;
&lt;li&gt;It puts devvm, which is one binary with its README, changelog and license, in &lt;code&gt;~/.local/lib/devvm/&amp;lt;version&amp;gt;&lt;/code&gt;, and links &lt;code&gt;~/.local/bin/devvm&lt;/code&gt; to it. When &lt;code&gt;~/.local/bin&lt;/code&gt; isn&amp;rsquo;t on &lt;code&gt;PATH&lt;/code&gt;, the script says how to add it.&lt;/li&gt;
&lt;li&gt;Unless you pass &lt;code&gt;--no-deps&lt;/code&gt;, it runs &lt;code&gt;devvm doctor --json&lt;/code&gt; and offers the &lt;a href="#devvm-doctor---json"&gt;fixes&lt;/a&gt; that devvm reports, asking before each one. Then it runs &lt;code&gt;devvm doctor&lt;/code&gt;, which shows doctor&amp;rsquo;s warnings too, even when nothing is missing.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;At the end, when &lt;code&gt;~/.local/bin&lt;/code&gt; is on &lt;code&gt;PATH&lt;/code&gt;, the script looks up which devvm &lt;code&gt;PATH&lt;/code&gt; finds first with &lt;code&gt;command -v devvm&lt;/code&gt;. It resolves that path&amp;rsquo;s links and those of &lt;code&gt;~/.local/bin/devvm&lt;/code&gt; with &lt;code&gt;readlink -f&lt;/code&gt;, and when they differ it warns, naming the other copy&amp;rsquo;s path and saying to remove it or to put &lt;code&gt;~/.local/bin&lt;/code&gt; first. It only looks the other copy up and never runs it. When &lt;code&gt;~/.local/bin&lt;/code&gt; isn&amp;rsquo;t on &lt;code&gt;PATH&lt;/code&gt;, the script prints only how to add it, so you don&amp;rsquo;t get both.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm doctor&lt;/code&gt; makes the same check. It looks up &lt;code&gt;devvm&lt;/code&gt; on &lt;code&gt;PATH&lt;/code&gt;, resolves its links and those of the running binary, and when they differ it prints a warning naming both. It skips the check when no devvm is on &lt;code&gt;PATH&lt;/code&gt;. The warning doesn&amp;rsquo;t change its exit status, and &lt;code&gt;--json&lt;/code&gt; lists it among the warnings rather than the problems, so the install script doesn&amp;rsquo;t offer it as a fix.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-signature-and-what-it-trusts"&gt;The signature and what it trusts&lt;span class="hx:absolute hx:-mt-20" id="the-signature-and-what-it-trusts"&gt;&lt;/span&gt;
&lt;a href="#the-signature-and-what-it-trusts" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;curl … | bash&lt;/code&gt; trusts everything in the release, and Homebrew checks the same archive against a checksum kept outside it. Both install the release&amp;rsquo;s own binary, the one &lt;code&gt;SHA256SUMS&lt;/code&gt; lists and its signature covers, and Homebrew installs only the binary from it:&lt;/p&gt;
&lt;div class="devvm-diagram" style="contain-intrinsic-block-size: auto 534px; --devvm-diagram-width: 397px"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" class="pele pele-flowchart" viewBox="0 0 397 534" width="397" height="534" style="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,&amp;quot;Departure Mono&amp;quot;, monospace);font:14px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,&amp;quot;Departure Mono&amp;quot;, monospace)" fill="var(--_fg)" role="graphics-document document" aria-roledescription="flowchart" aria-labelledby="dacd40653b3642272--title" aria-describedby="dacd40653b3642272--desc"&gt;&lt;title id="dacd40653b3642272--title"&gt;How each install checks the release&lt;/title&gt;&lt;desc id="dacd40653b3642272--desc"&gt;In the GitHub release, install.sh, with the public key, checks the signature on SHA256SUMS, signed in .minisig, and SHA256SUMS checks the archive for this machine. Homebrew's formula, in a repository of its own, checks the same archive against its own checksum.&lt;/desc&gt;&lt;g class="pele-clusters"&gt;&lt;g class="pele-cluster" data-id="release"&gt;&lt;rect x="96.89" y="135" width="291.8" height="391" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-cluster-label" fill="var(--_m)" x="242.78" y="158.4" text-anchor="middle"&gt;the GitHub release&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round"&gt;&lt;g class="pele-edge" data-id="L_script_sums_0"&gt;&lt;path d="M270.5,252L270.5,312"/&gt;&lt;path class="pele-marker" d="M270.5,319L267.14,311L273.86,311Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_sums_archive_0"&gt;&lt;path d="M270.5,379L270.5,439"/&gt;&lt;path class="pele-marker" d="M270.5,446L267.14,438L273.86,438Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_formula_archive_0"&gt;&lt;path d="M141.82,68L141.82,439"/&gt;&lt;path class="pele-marker" d="M141.82,446L138.46,438L145.18,438Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edge-labels" font-size="14"&gt;&lt;g class="pele-edge-label" data-id="L_script_sums_0"&gt;&lt;rect x="177.41" y="276.5" width="186.18" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="270.5" y="289.7" text-anchor="middle"&gt;checks the signature&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_sums_archive_0"&gt;&lt;rect x="181.86" y="403.5" width="177.27" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="270.5" y="416.7" text-anchor="middle"&gt;checks the checksum&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_formula_archive_0"&gt;&lt;rect x="53.18" y="92.5" width="177.27" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="141.82" y="105.7" text-anchor="middle"&gt;checks its checksum&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-nodes"&gt;&lt;g class="pele-node pele-shape-rect" data-id="script" transform="translate(270.5,222)"&gt;&lt;rect x="-89.27" y="-30" width="178.55" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;install.sh, with&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;the public key&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="sums" transform="translate(270.5,349)"&gt;&lt;rect x="-98.18" y="-30" width="196.36" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;SHA256SUMS,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;signed in .minisig&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="archive" transform="translate(206.16,476)"&gt;&lt;rect x="-89.27" y="-30" width="178.55" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;the archive&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;for this machine&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="formula" transform="translate(141.82,38)"&gt;&lt;rect x="-133.82" y="-30" width="267.64" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;Homebrew's formula,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;in a repository of its own&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/div&gt;&lt;p&gt;The release&amp;rsquo;s &lt;code&gt;SHA256SUMS&lt;/code&gt; lists the checksums of its archives and of its &lt;code&gt;install.sh&lt;/code&gt;, and minisign signatures beside it say who made it. devvm has room for three release keys, CI&amp;rsquo;s, the co-signer&amp;rsquo;s and a recovery key, and a script that holds them accepts &lt;code&gt;SHA256SUMS&lt;/code&gt; when any two of them signed it, each in its own file, &lt;code&gt;SHA256SUMS.ci.minisig&lt;/code&gt;, &lt;code&gt;SHA256SUMS.cosign.minisig&lt;/code&gt; or &lt;code&gt;SHA256SUMS.recovery.minisig&lt;/code&gt;. Each signature must check out with its own file&amp;rsquo;s key, two different keys must have made them, and each one&amp;rsquo;s trusted comment, which minisign&amp;rsquo;s global signature covers, must be &lt;code&gt;devvm-release &amp;lt;version&amp;gt;&lt;/code&gt; for the version being installed, so a &lt;code&gt;SHA256SUMS&lt;/code&gt; signed for another release is refused. The script also accepts the signature of the old release key, the maintainer&amp;rsquo;s minisign key, which has signed every release so far, in &lt;code&gt;SHA256SUMS.minisig&lt;/code&gt;, with the trusted comment &lt;code&gt;devvm &amp;lt;version&amp;gt;&lt;/code&gt;. While releases bridge from that key to the three, that signature alone is enough, so the script can install a release from before the three keys, and the devvm upgrade of a devvm from before them can check a release from after, because each release is signed by the old key too.&lt;/p&gt;
&lt;p&gt;The release keys aren&amp;rsquo;t made yet, so the script holds none, and it checks the old key&amp;rsquo;s signature alone, never downloading the release keys&amp;rsquo; signatures. Once they&amp;rsquo;re made, their public halves are in the script, and the old key&amp;rsquo;s is in the script that comes with a release. Without &lt;a href="https://jedisct1.github.io/minisign/" target="_blank" rel="noopener"&gt;minisign&lt;/a&gt; (&lt;code&gt;brew install minisign&lt;/code&gt;), the script says that only the checksum is checked, which can&amp;rsquo;t tell who made the release, prints the commands to check the signatures by hand, and checks only the checksum. A script that isn&amp;rsquo;t from a release has no old key, so for a release without the release keys&amp;rsquo; signatures it also checks only the checksum, and until the release keys are made it has none of those either, so it checks only the checksum of every release.&lt;/p&gt;
&lt;p&gt;The signature catches an archive or a &lt;code&gt;SHA256SUMS&lt;/code&gt; that someone replaced, which the checksum alone can&amp;rsquo;t. It can&amp;rsquo;t catch a release that was replaced whole, because &lt;code&gt;curl … | bash&lt;/code&gt; runs the &lt;code&gt;install.sh&lt;/code&gt; from that same release, key included, so the one-liner trusts GitHub&amp;rsquo;s release files. Homebrew doesn&amp;rsquo;t trust them, because the formula&amp;rsquo;s checksum lives in a repository of its own, and a replaced GitHub release wouldn&amp;rsquo;t match it. You can also download &lt;code&gt;install.sh&lt;/code&gt;, read it and &lt;a href="#checking-the-install-script"&gt;check it&lt;/a&gt; with the key from these docs before you run it, which catches a replaced release too, because that key doesn&amp;rsquo;t come from the release.&lt;/p&gt;
&lt;h3 data-hextra-search-id="checking-the-install-script"&gt;Checking the install script&lt;span class="hx:absolute hx:-mt-20" id="checking-the-install-script"&gt;&lt;/span&gt;
&lt;a href="#checking-the-install-script" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The release key&amp;rsquo;s public half is:&lt;/p&gt;
&lt;div class="hextra-code-block hx:relative hx:mt-6 hx:first:mt-0 hx:group/code"&gt;
&lt;div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;RWSjzFsn7ETaijKJ2y7F4DtZobXmyv+LmdclJwZP/KmAkLUwOCzWF/2b&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="hextra-code-copy-btn-container hx:opacity-0 hx:transition hx:group-hover/code:opacity-100 hx:flex hx:gap-1 hx:absolute hx:m-[11px] hx:right-0 hx:top-0"&gt;
&lt;button
class="hextra-code-copy-btn hx:group/copybtn hx:cursor-pointer hx:transition-all hx:active:opacity-50 hx:bg-primary-700/5 hx:border hx:border-black/5 hx:text-gray-600 hx:hover:text-gray-900 hx:rounded-md hx:p-1.5 hx:dark:bg-primary-300/10 hx:dark:border-white/10 hx:dark:text-gray-400 hx:dark:hover:text-gray-50"
title="Copy code"
aria-label="Copy code"
data-copied-label="Copied!"
&gt;
&lt;div class="hextra-copy-icon hx:group-[.copied]/copybtn:hidden hx:pointer-events-none hx:h-4 hx:w-4"&gt;&lt;/div&gt;
&lt;div class="hextra-success-icon hx:hidden hx:group-[.copied]/copybtn:block hx:pointer-events-none hx:h-4 hx:w-4"&gt;&lt;/div&gt;
&lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;devvm&amp;rsquo;s README and security policy show the same key. To check the install script with it, you need &lt;a href="https://jedisct1.github.io/minisign/" target="_blank" rel="noopener"&gt;minisign&lt;/a&gt; (&lt;code&gt;brew install minisign&lt;/code&gt;). Download the script, &lt;code&gt;SHA256SUMS&lt;/code&gt; and its signature from the release:&lt;/p&gt;
&lt;div class="hextra-code-block hx:relative hx:mt-6 hx:first:mt-0 hx:group/code"&gt;
&lt;div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;base&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://github.com/devvmhq/devvm/releases/latest/download
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl -fsSL -O &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$base&lt;/span&gt;&lt;span class="s2"&gt;/install.sh&amp;#34;&lt;/span&gt; -O &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$base&lt;/span&gt;&lt;span class="s2"&gt;/SHA256SUMS&amp;#34;&lt;/span&gt; -O &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="nv"&gt;$base&lt;/span&gt;&lt;span class="s2"&gt;/SHA256SUMS.minisig&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="hextra-code-copy-btn-container hx:opacity-0 hx:transition hx:group-hover/code:opacity-100 hx:flex hx:gap-1 hx:absolute hx:m-[11px] hx:right-0 hx:top-0"&gt;
&lt;button
class="hextra-code-copy-btn hx:group/copybtn hx:cursor-pointer hx:transition-all hx:active:opacity-50 hx:bg-primary-700/5 hx:border hx:border-black/5 hx:text-gray-600 hx:hover:text-gray-900 hx:rounded-md hx:p-1.5 hx:dark:bg-primary-300/10 hx:dark:border-white/10 hx:dark:text-gray-400 hx:dark:hover:text-gray-50"
title="Copy code"
aria-label="Copy code"
data-copied-label="Copied!"
&gt;
&lt;div class="hextra-copy-icon hx:group-[.copied]/copybtn:hidden hx:pointer-events-none hx:h-4 hx:w-4"&gt;&lt;/div&gt;
&lt;div class="hextra-success-icon hx:hidden hx:group-[.copied]/copybtn:block hx:pointer-events-none hx:h-4 hx:w-4"&gt;&lt;/div&gt;
&lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Then check that the release key signed &lt;code&gt;SHA256SUMS&lt;/code&gt;, check the script against it, and run the script once both checks pass:&lt;/p&gt;
&lt;div class="hextra-code-block hx:relative hx:mt-6 hx:first:mt-0 hx:group/code"&gt;
&lt;div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;minisign -Vm SHA256SUMS -P RWSjzFsn7ETaijKJ2y7F4DtZobXmyv+LmdclJwZP/KmAkLUwOCzWF/2b
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;shasum -a &lt;span class="m"&gt;256&lt;/span&gt; -c --ignore-missing SHA256SUMS
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;bash install.sh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="hextra-code-copy-btn-container hx:opacity-0 hx:transition hx:group-hover/code:opacity-100 hx:flex hx:gap-1 hx:absolute hx:m-[11px] hx:right-0 hx:top-0"&gt;
&lt;button
class="hextra-code-copy-btn hx:group/copybtn hx:cursor-pointer hx:transition-all hx:active:opacity-50 hx:bg-primary-700/5 hx:border hx:border-black/5 hx:text-gray-600 hx:hover:text-gray-900 hx:rounded-md hx:p-1.5 hx:dark:bg-primary-300/10 hx:dark:border-white/10 hx:dark:text-gray-400 hx:dark:hover:text-gray-50"
title="Copy code"
aria-label="Copy code"
data-copied-label="Copied!"
&gt;
&lt;div class="hextra-copy-icon hx:group-[.copied]/copybtn:hidden hx:pointer-events-none hx:h-4 hx:w-4"&gt;&lt;/div&gt;
&lt;div class="hextra-success-icon hx:hidden hx:group-[.copied]/copybtn:block hx:pointer-events-none hx:h-4 hx:w-4"&gt;&lt;/div&gt;
&lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;minisign prints &lt;code&gt;Signature and comment signature verified&lt;/code&gt; and a trusted comment that names the release, as in &lt;code&gt;Trusted comment: devvm 0.1.0&lt;/code&gt;, and &lt;code&gt;shasum&lt;/code&gt; prints &lt;code&gt;install.sh: OK&lt;/code&gt;. On Linux without &lt;code&gt;shasum&lt;/code&gt;, &lt;code&gt;sha256sum -c --ignore-missing SHA256SUMS&lt;/code&gt; does the same. When either check fails, don&amp;rsquo;t run the script. The script takes the same options as &lt;code&gt;curl … | bash -s --&lt;/code&gt;, as in &lt;code&gt;bash install.sh --yes&lt;/code&gt;, and it still checks the signature and the archive&amp;rsquo;s checksum itself, as &lt;a href="#the-install-script"&gt;the install script&lt;/a&gt; describes.&lt;/p&gt;
&lt;h2 data-hextra-search-id="what-devvm-doctor-checks"&gt;What devvm doctor checks&lt;span class="hx:absolute hx:-mt-20" id="what-devvm-doctor-checks"&gt;&lt;/span&gt;
&lt;a href="#what-devvm-doctor-checks" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm doctor&lt;/code&gt; checks what &lt;a href="https://next.devvm.dev/docs/backends/lima/#requirements"&gt;Lima&lt;/a&gt;, devvm&amp;rsquo;s backend, needs. It lists everything that&amp;rsquo;s missing, each with what to do, which is the command that installs it when there&amp;rsquo;s one to run. It then lists what Lima can do, which it calls Lima&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/backends/#features"&gt;features&lt;/a&gt;, each as &lt;code&gt;native&lt;/code&gt;, &lt;code&gt;emulated&lt;/code&gt;, &lt;code&gt;unreviewed&lt;/code&gt; for an emulation that devvm refuses until it&amp;rsquo;s reviewed, or &lt;code&gt;none&lt;/code&gt;. It also says whether Docker is installed, which only &lt;code&gt;--from&lt;/code&gt; with &lt;a href="https://next.devvm.dev/docs/using/from/#images-only-docker-has"&gt;an image only Docker has&lt;/a&gt; needs. When &lt;code&gt;HTTPS_PROXY&lt;/code&gt; is set and &lt;code&gt;~/.config/devvm/ca&lt;/code&gt; has no CA certificates, it says that a proxy that inspects TLS needs its CA there (&lt;a href="https://next.devvm.dev/docs/using/settings/#a-companys-ca"&gt;a company&amp;rsquo;s CA&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;It warns in these cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;another devvm comes first on your &lt;code&gt;PATH&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/using/upgrading/#one-devvm"&gt;one devvm&lt;/a&gt;),&lt;/li&gt;
&lt;li&gt;the disk that devvm&amp;rsquo;s images and VMs go on has less free space than building base needs (&lt;a href="https://next.devvm.dev/docs/using/ports-size/#free-space"&gt;free space&lt;/a&gt;),&lt;/li&gt;
&lt;li&gt;this machine has less than the 8 GiB of memory or the 4 CPUs that devvm recommends (&lt;a href="https://next.devvm.dev/docs/getting-started/install/#requirements"&gt;requirements&lt;/a&gt;),&lt;/li&gt;
&lt;li&gt;a line of your policy files isn&amp;rsquo;t a rule, which VMs&amp;rsquo; proxies skip (&lt;a href="https://next.devvm.dev/docs/safety/network/#rules"&gt;rules&lt;/a&gt;),&lt;/li&gt;
&lt;li&gt;a VM&amp;rsquo;s state, its &lt;code&gt;vm.json&lt;/code&gt;, can&amp;rsquo;t be read, or has a section that the package which owns that section can&amp;rsquo;t read, as every command also checks for the VM it finds for a folder. doctor names the VM, or its folder when the file can&amp;rsquo;t be read, and gives the reason, which names the file, and it leaves the file as it is. It doesn&amp;rsquo;t check a value that reads but that a launch refuses, such as a size that isn&amp;rsquo;t a number (&lt;a href="https://next.devvm.dev/docs/using/troubleshooting/#a-file-devvm-cant-read"&gt;a file devvm can&amp;rsquo;t read&lt;/a&gt;),&lt;/li&gt;
&lt;li&gt;a running VM&amp;rsquo;s proxy runs without its sandbox, or with only part of it, such as on a Linux kernel whose Landlock is older than ABI 6. The proxy writes how it&amp;rsquo;s confined in the VM&amp;rsquo;s &lt;code&gt;run/proxy.confined&lt;/code&gt; once it starts, and doctor names what that file says. doctor also names a proxy with no such file that another devvm binary started, which it tells by the &lt;code&gt;devvm_sha256&lt;/code&gt; in the proxy&amp;rsquo;s config, because that&amp;rsquo;s an older devvm&amp;rsquo;s single process, which has no sandbox. A proxy that this devvm started and that hasn&amp;rsquo;t written the file yet is still starting, so it gets no warning (&lt;a href="https://next.devvm.dev/docs/using/troubleshooting/#the-proxy-runs-without-a-sandbox"&gt;the proxy runs without a sandbox&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It also gives a tip, which isn&amp;rsquo;t a warning, when &lt;code&gt;safe.bareRepository&lt;/code&gt; isn&amp;rsquo;t &lt;code&gt;explicit&lt;/code&gt; in your global or system git config, or in the files that &lt;code&gt;GIT_CONFIG_GLOBAL&lt;/code&gt; and &lt;code&gt;GIT_CONFIG_SYSTEM&lt;/code&gt; name: git then takes any folder shaped like a git folder for a bare repo, so a VM can make one that git run below it uses (&lt;a href="https://next.devvm.dev/docs/safety/git-protection/#bare-repos"&gt;bare repos&lt;/a&gt;). doctor only reads the setting.&lt;/p&gt;
&lt;p&gt;Then it says devvm has everything it needs, or it fails. The warnings and tips never make it fail, so a small machine with everything installed passes.&lt;/p&gt;
&lt;h2 data-hextra-search-id="devvm-doctor-json"&gt;devvm doctor &amp;ndash;json&lt;span class="hx:absolute hx:-mt-20" id="devvm-doctor-json"&gt;&lt;/span&gt;
&lt;a href="#devvm-doctor-json" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm doctor --json&lt;/code&gt; prints what doctor finds as one JSON object, for scripts such as the install script, as &lt;a href="https://next.devvm.dev/docs/using/command-line/#output-for-scripts"&gt;output for scripts&lt;/a&gt; describes. It prints nothing else, because its problems and warnings are in the JSON, and it succeeds whatever is missing. A failure that stops the check, such as a data folder devvm can&amp;rsquo;t read, still goes to standard error and makes it fail.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;backend&lt;/code&gt; is the backend that doctor checked, &lt;code&gt;lima&lt;/code&gt;, which every new VM gets.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;problems&lt;/code&gt; has what that backend is missing, each with its &lt;code&gt;key&lt;/code&gt;, the &lt;code&gt;fix&lt;/code&gt; command, and the &lt;code&gt;message&lt;/code&gt; that &lt;code&gt;devvm doctor&lt;/code&gt; prints for it. The &lt;code&gt;fix&lt;/code&gt; is a command whose words are separated by spaces, without shell syntax, or &lt;code&gt;null&lt;/code&gt; when there&amp;rsquo;s none to run, for example when virtualization is turned off in the firmware.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;warnings&lt;/code&gt; has the messages of doctor&amp;rsquo;s warnings, which have no keys, because there&amp;rsquo;s nothing for a script to fix. They&amp;rsquo;re about another devvm on &lt;code&gt;PATH&lt;/code&gt;, low free space, a machine with less than 8 GiB of memory or fewer than 4 CPUs, each line of &lt;code&gt;~/.config/devvm/policy&lt;/code&gt;, &lt;code&gt;~/.config/devvm/layers/*.policy&lt;/code&gt; and &lt;code&gt;~/.local/share/devvm/vms/*/policy&lt;/code&gt; that isn&amp;rsquo;t a rule (&lt;code&gt;policy_not_rule&lt;/code&gt;), and each running VM whose proxy runs without its sandbox (&lt;code&gt;proxy_unconfined&lt;/code&gt; and the &lt;code&gt;proxy_unconfined_*&lt;/code&gt; messages, one for each reason).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tips&lt;/code&gt; has the messages of doctor&amp;rsquo;s tips, which aren&amp;rsquo;t problems: git&amp;rsquo;s &lt;code&gt;safe.bareRepository&lt;/code&gt; (&lt;code&gt;doctor_git_bare&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docker&lt;/code&gt; says whether Docker is installed, which only &lt;code&gt;--from&lt;/code&gt; with an image that only Docker has needs.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;features&lt;/code&gt; has, for each backend, how it has each feature, as &lt;code&gt;native&lt;/code&gt;, &lt;code&gt;emulated&lt;/code&gt;, &lt;code&gt;unreviewed&lt;/code&gt; or &lt;code&gt;none&lt;/code&gt;. The example below shows two of Lima&amp;rsquo;s features.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="hextra-code-block hx:relative hx:mt-6 hx:first:mt-0 hx:group/code"&gt;
&lt;div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-json" data-lang="json"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;version&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;backend&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;lima&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;problems&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;key&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;lima&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;fix&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;brew install lima&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;message&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;Lima isn&amp;#39;t installed. Run brew install lima to install it.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;],&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;warnings&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;tips&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;docker&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;features&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;lima&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;agent-forwarding&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;native&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nt"&gt;&amp;#34;disk&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;native&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="hextra-code-copy-btn-container hx:opacity-0 hx:transition hx:group-hover/code:opacity-100 hx:flex hx:gap-1 hx:absolute hx:m-[11px] hx:right-0 hx:top-0"&gt;
&lt;button
class="hextra-code-copy-btn hx:group/copybtn hx:cursor-pointer hx:transition-all hx:active:opacity-50 hx:bg-primary-700/5 hx:border hx:border-black/5 hx:text-gray-600 hx:hover:text-gray-900 hx:rounded-md hx:p-1.5 hx:dark:bg-primary-300/10 hx:dark:border-white/10 hx:dark:text-gray-400 hx:dark:hover:text-gray-50"
title="Copy code"
aria-label="Copy code"
data-copied-label="Copied!"
&gt;
&lt;div class="hextra-copy-icon hx:group-[.copied]/copybtn:hidden hx:pointer-events-none hx:h-4 hx:w-4"&gt;&lt;/div&gt;
&lt;div class="hextra-success-icon hx:hidden hx:group-[.copied]/copybtn:block hx:pointer-events-none hx:h-4 hx:w-4"&gt;&lt;/div&gt;
&lt;/button&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;These are the keys:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;th&gt;Missing&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;os&lt;/code&gt;, &lt;code&gt;arch&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a host the backend runs on&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;macos&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;macOS at the backend&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/backends/lima/#requirements"&gt;minimum&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lima&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Lima at its &lt;a href="https://next.devvm.dev/docs/backends/lima/#requirements"&gt;minimum&lt;/a&gt;, working&lt;/td&gt;
&lt;td&gt;&lt;code&gt;brew install lima&lt;/code&gt; (&lt;code&gt;upgrade&lt;/code&gt;, &lt;code&gt;reinstall&lt;/code&gt;) with Homebrew, otherwise none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;qemu&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;QEMU, on Linux&lt;/td&gt;
&lt;td&gt;your package manager&amp;rsquo;s install (apt, dnf, pacman or zypper), otherwise none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kvm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/dev/kvm&lt;/code&gt;, on Linux&lt;/td&gt;
&lt;td&gt;none: turn on virtualization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kvm-access&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;access to &lt;code&gt;/dev/kvm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sudo usermod -aG kvm USER&lt;/code&gt;, then log in again&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lima-config&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;no Lima global configs in devvm&amp;rsquo;s Lima home (&lt;a href="https://next.devvm.dev/docs/internals/lima/#a-lima-home-of-its-own"&gt;details&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;none: move them out&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The install script reads &lt;code&gt;problems&lt;/code&gt; with &lt;code&gt;awk&lt;/code&gt;, so it needs no JSON tool on this machine. It relies on the layout that devvm writes, with one field on each line, and it reads a problem&amp;rsquo;s &lt;code&gt;key&lt;/code&gt;, &lt;code&gt;fix&lt;/code&gt; and &lt;code&gt;message&lt;/code&gt; from their lines, with their escapes undone. It offers to fix three of these keys, asking first, and prints the message for the others:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For &lt;code&gt;lima&lt;/code&gt;, it runs the fix when there is one, which is Homebrew&amp;rsquo;s. Without Homebrew, it offers Lima&amp;rsquo;s latest release instead, which it checks against that release&amp;rsquo;s &lt;code&gt;SHA256SUMS&lt;/code&gt; and installs into &lt;code&gt;~/.local&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For &lt;code&gt;qemu&lt;/code&gt; and &lt;code&gt;kvm-access&lt;/code&gt;, it runs the fix when there is one, and the fix uses sudo. After you join the &lt;code&gt;kvm&lt;/code&gt; group, the script doesn&amp;rsquo;t run &lt;code&gt;devvm doctor&lt;/code&gt;, because the group applies only to new logins, and it tells you to log out and back in first.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With &lt;code&gt;--yes&lt;/code&gt;, the script answers yes to every question. Without a terminal and without &lt;code&gt;--yes&lt;/code&gt;, it installs none of the fixes and says so.&lt;/p&gt;
&lt;h2 data-hextra-search-id="devvms-own-files"&gt;devvm&amp;rsquo;s own files&lt;span class="hx:absolute hx:-mt-20" id="devvms-own-files"&gt;&lt;/span&gt;
&lt;a href="#devvms-own-files" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm is one binary. Its own files are built into it, so a copy of it runs anywhere. They are &lt;code&gt;base.yaml&lt;/code&gt;, base&amp;rsquo;s scripts and policy, the features, the shared tools&amp;rsquo; config and build script, what devvm sends into VMs, and &lt;code&gt;--from&lt;/code&gt;&amp;rsquo;s conversion. The binary is the only copy, and devvm never writes them to a folder of its own that outlives a run. Lima gets &lt;code&gt;base.yaml&lt;/code&gt; on &lt;code&gt;limactl create&lt;/code&gt;&amp;rsquo;s standard input, VMs&amp;rsquo; proxies read devvm&amp;rsquo;s built-in policies from the binary, and &lt;code&gt;--from&lt;/code&gt;&amp;rsquo;s build writes the conversion&amp;rsquo;s scripts into its own temporary folder, which it deletes when the build ends. So editing a file on disk can&amp;rsquo;t change devvm&amp;rsquo;s built-in rules or what goes into an image.&lt;/p&gt;
&lt;h2 data-hextra-search-id="upgrading"&gt;Upgrading&lt;span class="hx:absolute hx:-mt-20" id="upgrading"&gt;&lt;/span&gt;
&lt;a href="#upgrading" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When the script installs a new version, it removes the older versions in &lt;code&gt;~/.local/lib/devvm&lt;/code&gt;, except a version that a running VM&amp;rsquo;s proxy, or QEMU on Linux, still runs. A later install removes that version once nothing runs it. A VM&amp;rsquo;s proxy moves to the new version at the VM&amp;rsquo;s next launch (&lt;code&gt;devvm&lt;/code&gt; in its folder), and QEMU moves when the VM next starts.&lt;/p&gt;
&lt;h2 data-hextra-search-id="devvm-upgrade"&gt;devvm upgrade&lt;span class="hx:absolute hx:-mt-20" id="devvm-upgrade"&gt;&lt;/span&gt;
&lt;a href="#devvm-upgrade" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm upgrade&lt;/code&gt; installs a release in Go, with the same files and checks as the install script, and it never runs the script. It reads the newest release&amp;rsquo;s version from where GitHub&amp;rsquo;s &lt;code&gt;releases/latest&lt;/code&gt; redirects, &lt;code&gt;releases/tag/v&amp;lt;version&amp;gt;&lt;/code&gt;, as the script does, so it needs no API and has no rate limit. Every request goes over HTTPS, and a redirect to anything else is refused.&lt;/p&gt;
&lt;p&gt;GitHub&amp;rsquo;s &lt;code&gt;releases/latest&lt;/code&gt; skips the releases marked as prereleases, which are the versions with a suffix, such as &lt;code&gt;0.2.0-rc.1&lt;/code&gt;. devvm upgrade, the daily release check and the install script also refuse a prerelease there, so none of them installs or announces one as the newest release, and a prerelease is installed only when &lt;code&gt;--to&lt;/code&gt; or the script&amp;rsquo;s &lt;code&gt;--version&lt;/code&gt; names it. A record of the daily check that names a prerelease as the newest release counts as no record, and the next check replaces it. Versions compare as semver orders them: the numbers as numbers, a prerelease before its release, and a prerelease&amp;rsquo;s suffix part by part, a number below a word and numbers as numbers, so &lt;code&gt;0.2.0-rc.9&lt;/code&gt; comes before &lt;code&gt;0.2.0-rc.10&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Homebrew&amp;rsquo;s &lt;code&gt;devvm-rc&lt;/code&gt; formula is the one exception, because it follows prereleases. For a devvm that &lt;code&gt;devvm-rc&lt;/code&gt; installed, devvm upgrade and the daily check read the repository&amp;rsquo;s releases feed, &lt;code&gt;releases.atom&lt;/code&gt;, which lists the newest releases, prereleases among them, and needs no API either. The newest version in it, a prerelease or a release, is the newest release for that devvm. The daily check records it as &lt;code&gt;newest&lt;/code&gt; in its record, beside &lt;code&gt;latest&lt;/code&gt;, the newest release in the feed that isn&amp;rsquo;t a prerelease, which stays as it was when the feed lists only prereleases.&lt;/p&gt;
&lt;h3 data-hextra-search-id="how-it-tells-how-devvm-was-installed"&gt;How it tells how devvm was installed&lt;span class="hx:absolute hx:-mt-20" id="how-it-tells-how-devvm-was-installed"&gt;&lt;/span&gt;
&lt;a href="#how-it-tells-how-devvm-was-installed" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;It follows the links of the running binary&amp;rsquo;s path, and it reads only that path, never running anything:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It&amp;rsquo;s the install script&amp;rsquo;s when the binary is &lt;code&gt;devvm&lt;/code&gt; in &lt;code&gt;&amp;lt;prefix&amp;gt;/lib/devvm/&amp;lt;version&amp;gt;&lt;/code&gt;, with a release&amp;rsquo;s version as the folder&amp;rsquo;s name, and &lt;code&gt;&amp;lt;prefix&amp;gt;/bin/devvm&lt;/code&gt; is a link that resolves to that same binary. The prefix comes from the binary&amp;rsquo;s own path, so &lt;code&gt;DEVVM_PREFIX&lt;/code&gt; needs no setting.&lt;/li&gt;
&lt;li&gt;It&amp;rsquo;s Homebrew&amp;rsquo;s when the path has &lt;code&gt;Cellar/devvm/&lt;/code&gt; in it, a keg of Homebrew&amp;rsquo;s &lt;code&gt;devvm&lt;/code&gt; formula, or &lt;code&gt;Cellar/devvm-rc/&lt;/code&gt;, a keg of its &lt;code&gt;devvm-rc&lt;/code&gt; formula, which follows prereleases.&lt;/li&gt;
&lt;li&gt;Anything else is another way. A devvm whose version isn&amp;rsquo;t a release&amp;rsquo;s, such as a checkout&amp;rsquo;s pseudo-version or &lt;code&gt;(devel)&lt;/code&gt;, was built from the source. One with a release&amp;rsquo;s version that wasn&amp;rsquo;t set when it was built, as &lt;code&gt;go install&lt;/code&gt; gives, was installed with &lt;code&gt;go install&lt;/code&gt;. One that has a release&amp;rsquo;s version is a copy of a release somewhere else.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-hextra-search-id="the-release-keys-and-the-signatures"&gt;The release keys and the signatures&lt;span class="hx:absolute hx:-mt-20" id="the-release-keys-and-the-signatures"&gt;&lt;/span&gt;
&lt;a href="#the-release-keys-and-the-signatures" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The public halves of the three release keys, CI&amp;rsquo;s, the co-signer&amp;rsquo;s and the recovery key&amp;rsquo;s, are built into devvm from &lt;code&gt;packaging/keys&lt;/code&gt;, the same keys the script holds, once they&amp;rsquo;re made. Until then devvm has none of them, and checks each release with the old release key alone, so a release that only the release keys signed is refused. The old release key&amp;rsquo;s public half is built in too, from &lt;code&gt;packaging/minisign.pub&lt;/code&gt;, the file the script that comes with a release gets its key from. So devvm upgrade trusts the keys in the devvm you have, never ones that come with the release. A key that devvm can&amp;rsquo;t read is no key, and so is a set of release keys with a key missing or with one key in two roles, and devvm upgrade refuses to install a release without a key it can read.&lt;/p&gt;
&lt;p&gt;devvm checks minisign&amp;rsquo;s signatures itself. Each signature file holds a signature and a trusted comment, each signed with the file&amp;rsquo;s key. devvm accepts only minisign&amp;rsquo;s default, prehashed signature, marked &lt;code&gt;ED&lt;/code&gt;, which is Ed25519 over the BLAKE2b-512 hash of &lt;code&gt;SHA256SUMS&lt;/code&gt;, and refuses the legacy one, marked &lt;code&gt;Ed&lt;/code&gt;, over the file itself. The signature&amp;rsquo;s key ID must be its key&amp;rsquo;s, and the global signature, Ed25519 over the signature followed by the trusted comment, must verify too. devvm accepts &lt;code&gt;SHA256SUMS&lt;/code&gt; in either of two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Two of the three release keys, in a devvm that has them:&lt;/strong&gt; it downloads &lt;code&gt;SHA256SUMS.ci.minisig&lt;/code&gt;, &lt;code&gt;SHA256SUMS.cosign.minisig&lt;/code&gt; and &lt;code&gt;SHA256SUMS.recovery.minisig&lt;/code&gt;, and checks each against its own role&amp;rsquo;s key, never another&amp;rsquo;s. Two of them must check out, with the trusted comment &lt;code&gt;devvm-release &amp;lt;version&amp;gt;&lt;/code&gt; exactly, and two different keys must have made them, as each role&amp;rsquo;s key is a different key with a different key ID.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The old release key, while releases bridge from it:&lt;/strong&gt; when two of the release keys&amp;rsquo; signatures don&amp;rsquo;t check out, it downloads &lt;code&gt;SHA256SUMS.minisig&lt;/code&gt; and checks it against the old key, with the trusted comment &lt;code&gt;devvm &amp;lt;version&amp;gt;&lt;/code&gt;, as the release script writes it. Every release so far is signed this way, and so is each release while the bridge lasts, so the devvm upgrade of 0.1 and 0.2, which knows only this key, can check it. While the bridge lasts, a release that only the old key signed is still accepted.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Either way, a &lt;code&gt;SHA256SUMS&lt;/code&gt; signed for one release can&amp;rsquo;t stand in for another&amp;rsquo;s, and a signature of one form can&amp;rsquo;t stand in for the other&amp;rsquo;s, because their trusted comments differ. When neither way checks out, devvm upgrade installs nothing, and it says the signatures couldn&amp;rsquo;t be downloaded when none of them could. Then the archive for this machine, &lt;code&gt;devvm-&amp;lt;version&amp;gt;-&amp;lt;os&amp;gt;-&amp;lt;arch&amp;gt;.tar.gz&lt;/code&gt; for the binary&amp;rsquo;s own OS and processor, must match its line in &lt;code&gt;SHA256SUMS&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The archive is unpacked into &lt;code&gt;&amp;lt;prefix&amp;gt;/lib/devvm/.&amp;lt;version&amp;gt;.new.&amp;lt;pid&amp;gt;&lt;/code&gt;, beside the version that runs. Only its one top-level folder and the regular files in it are unpacked, at most 512 MiB in all, and an archive with a link, a folder inside that one, or a path out of it is refused. devvm is unpacked with mode 755 and the other files with mode 644.&lt;/p&gt;
&lt;h3 data-hextra-search-id="rollbacks"&gt;Rollbacks&lt;span class="hx:absolute hx:-mt-20" id="rollbacks"&gt;&lt;/span&gt;
&lt;a href="#rollbacks" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A server, or someone in the way of one, can offer an older release that&amp;rsquo;s still properly signed. devvm upgrade refuses a newest release older than the running devvm, whatever the flags, and installs an older one only when &lt;code&gt;--to&lt;/code&gt; names it, after a question that says it&amp;rsquo;s older. When the running devvm is a prerelease, an older newest release is what&amp;rsquo;s expected before the prerelease&amp;rsquo;s own release is out, so devvm upgrade says so and installs nothing, without failing. It can&amp;rsquo;t tell a server that keeps offering the release you already have from one with nothing newer, which is a limit of reading the newest release from the server.&lt;/p&gt;
&lt;h3 data-hextra-search-id="switching-the-link"&gt;Switching the link&lt;span class="hx:absolute hx:-mt-20" id="switching-the-link"&gt;&lt;/span&gt;
&lt;a href="#switching-the-link" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;The unpacked folder&amp;rsquo;s devvm runs with &lt;code&gt;--version&lt;/code&gt;, which must print the release&amp;rsquo;s version.&lt;/li&gt;
&lt;li&gt;The folder is renamed to &lt;code&gt;&amp;lt;prefix&amp;gt;/lib/devvm/&amp;lt;version&amp;gt;&lt;/code&gt;. A folder of that version from before is set aside first, and it&amp;rsquo;s put back if a later step fails.&lt;/li&gt;
&lt;li&gt;The link switches in one step: a new link to the new devvm is made beside &lt;code&gt;&amp;lt;prefix&amp;gt;/bin/devvm&lt;/code&gt; and renamed over it, so the link is never missing or half made.&lt;/li&gt;
&lt;li&gt;The new devvm runs again, through the link. When it fails, the link is switched back to the devvm that ran devvm upgrade, and the new folder goes.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Then devvm upgrade removes the other versions in &lt;code&gt;&amp;lt;prefix&amp;gt;/lib/devvm&lt;/code&gt;, as the script does: it keeps the new version, the one that ran devvm upgrade, and any version that a running process&amp;rsquo;s command line names, such as a VM&amp;rsquo;s proxy, which it lists with &lt;code&gt;ps&lt;/code&gt;. When &lt;code&gt;ps&lt;/code&gt; fails, it keeps them all. An interrupted upgrade leaves a &lt;code&gt;.&amp;lt;version&amp;gt;.new.&amp;lt;pid&amp;gt;&lt;/code&gt; folder at most. The next upgrade removes it once no process has that pid, so it never takes the folder of an upgrade that&amp;rsquo;s still running, and the script&amp;rsquo;s next install removes it too.&lt;/p&gt;
&lt;p&gt;With Homebrew, devvm upgrade runs &lt;code&gt;brew upgrade devvm&lt;/code&gt;, or &lt;code&gt;brew upgrade devvm-rc&lt;/code&gt; for a &lt;code&gt;devvm-rc&lt;/code&gt; keg, into the run log, after asking, and checks nothing of its own, because Homebrew checks the source against the formula&amp;rsquo;s checksum.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-release-check"&gt;The release check&lt;span class="hx:absolute hx:-mt-20" id="the-release-check"&gt;&lt;/span&gt;
&lt;a href="#the-release-check" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When you run devvm in a terminal, it checks at most once a day for a newer release (&lt;a href="https://next.devvm.dev/docs/using/settings/#the-release-check"&gt;the release check&lt;/a&gt;). The check reads only where GitHub&amp;rsquo;s latest devvm release is, over HTTPS, and sends nothing about you or your machine. The latest release is never a prerelease, so the check never announces one. The exception is a devvm that Homebrew&amp;rsquo;s &lt;code&gt;devvm-rc&lt;/code&gt; formula installed, which follows prereleases: its check reads GitHub&amp;rsquo;s list of devvm&amp;rsquo;s newest releases instead, as &lt;a href="#devvm-upgrade"&gt;devvm upgrade&lt;/a&gt; describes, and it announces a newer prerelease or release, whichever is newest.&lt;/p&gt;
&lt;p&gt;The check runs beside the launch, so it never makes devvm wait, and when you&amp;rsquo;re offline it says nothing and tries again the next day. The line comes from what the last check found, so a release that came out since then shows up at the launch after the next check. devvm keeps what the check found in &lt;code&gt;~/.local/share/devvm/cache/release.json&lt;/code&gt;, and &lt;code&gt;devvm doctor&lt;/code&gt; shows it.&lt;/p&gt;</description></item><item><title>Images and caching</title><link>https://next.devvm.dev/docs/internals/images/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/images/</guid><description>
&lt;p&gt;This page explains how devvm builds images and shared tools, how it keys and caches them, and how it checks what they start from: Ubuntu&amp;rsquo;s cloud image, a container image from &lt;code&gt;--from&lt;/code&gt;, and each tool&amp;rsquo;s downloads. &lt;a href="https://next.devvm.dev/docs/using/images/"&gt;Images and tools&lt;/a&gt; covers choosing, rebuilding and cleaning up images, and &lt;a href="https://next.devvm.dev/docs/using/from/"&gt;Starting from a container image&lt;/a&gt; covers &lt;code&gt;--from&lt;/code&gt;.&lt;/p&gt;
&lt;h2 data-hextra-search-id="building"&gt;Building&lt;span class="hx:absolute hx:-mt-20" id="building"&gt;&lt;/span&gt;
&lt;a href="#building" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm builds each image in a VM of its own, and that VM then is the image:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;For base, devvm makes a new VM from &lt;a href="#ubuntus-cloud-image"&gt;Ubuntu&amp;rsquo;s cloud image&lt;/a&gt; with &lt;code&gt;base.yaml&lt;/code&gt;&amp;rsquo;s settings, or, with &lt;code&gt;--from&lt;/code&gt;, from a container image &lt;a href="#how-its-converted"&gt;converted into a disk&lt;/a&gt;. A layer&amp;rsquo;s VM is a copy of its parent image.&lt;/li&gt;
&lt;li&gt;The VM starts confined, and it forwards no ports. What a build with the internet reaches of the host depends on the backend: on macOS, Lima keeps it out of the host&amp;rsquo;s loopback, and on Linux it reaches the host&amp;rsquo;s loopback too, as &lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;Lima&lt;/a&gt; describes.&lt;/li&gt;
&lt;li&gt;The script runs. For base, that&amp;rsquo;s base&amp;rsquo;s own script, &lt;code&gt;base.sh&lt;/code&gt;, and then the &lt;a href="https://next.devvm.dev/docs/using/customizing/"&gt;features&lt;/a&gt; you chose, and for a layer, it&amp;rsquo;s the layer&amp;rsquo;s script.&lt;/li&gt;
&lt;li&gt;The VM stops. devvm writes the image&amp;rsquo;s record last, &lt;code&gt;~/.local/share/devvm/images/&amp;lt;key&amp;gt;/record.json&lt;/code&gt;, with its name, its chain, what base started from and its digest, its C library, the glibc version of a &lt;code&gt;--from&lt;/code&gt; base with glibc, when the build finished and the version of the devvm that built it (&lt;code&gt;made_by&lt;/code&gt;). The record is JSON that only devvm writes, and devvm ignores fields it doesn&amp;rsquo;t know, so a newer devvm&amp;rsquo;s record still reads.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;While the VM is being built, it already has the image&amp;rsquo;s final name, so devvm holds a lock for each image it builds, &lt;code&gt;~/.local/share/devvm/images/locks/&amp;lt;key&amp;gt;&lt;/code&gt;, from before it looks for the image until the record is written. Another devvm that builds the same image waits for that lock under a status line (&lt;code&gt;image_build_waiting&lt;/code&gt;), 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 (&lt;code&gt;image_leftover&lt;/code&gt;). While the lock is held, the image is &lt;code&gt;building&lt;/code&gt;, and &lt;code&gt;devvm gc&lt;/code&gt;, &lt;code&gt;devvm rebuild&lt;/code&gt; and &lt;code&gt;devvm images rm&lt;/code&gt; leave it alone (&lt;code&gt;image_building&lt;/code&gt;). 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&amp;rsquo;s still being built. devvm deletes the lock file together with the image&amp;rsquo;s folder.&lt;/p&gt;
&lt;p&gt;Nothing from the host is mounted into a build, because layer scripts run third-party installers, which mustn&amp;rsquo;t see your files. Behind a company proxy, a build on Lima goes through a proxy of devvm&amp;rsquo;s on this machine for that build alone, which goes through the company proxy. The scripts&amp;rsquo; commands get only that proxy&amp;rsquo;s address, with a password devvm makes for the build, so neither the build nor its image ever has the company proxy&amp;rsquo;s password (&lt;a href="https://next.devvm.dev/docs/contributing/design/#a-company-proxy"&gt;a company proxy&lt;/a&gt;). A build gets base&amp;rsquo;s size fitted to the host, which the images built on base, and their VMs, keep (&lt;a href="#bases-size"&gt;base&amp;rsquo;s size&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;A build&amp;rsquo;s downloads survive a network that cuts or stalls them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;devvm-fetch&lt;/code&gt;&lt;/strong&gt;, which base installs and every layer downloads through, gives up on a connection that takes more than 20 seconds to open or stays slower than 1 KB/s for 30 seconds, and tries again from where it stopped, five tries in all, waiting a little longer after each. A server that won&amp;rsquo;t resume (curl&amp;rsquo;s exits 33 and 36) starts the file again from nothing, and so does a file that doesn&amp;rsquo;t match its checksum, once, as a resume may have joined two versions of it. It follows a redirect only to https, and it keeps only a file whose checksum is the pinned one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;apt&lt;/strong&gt; tries a package&amp;rsquo;s download again three times once a source has answered (&lt;a href="#bases-packages"&gt;base&amp;rsquo;s packages&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;crane&lt;/strong&gt;, in a &lt;code&gt;--from&lt;/code&gt; conversion, is tried again five times, and &lt;strong&gt;oh-my-bash&lt;/strong&gt;&amp;rsquo;s clone, in the &lt;code&gt;omb&lt;/code&gt; feature, is tried five times in all, each failing on a connection that stays slower than 1 KB/s for 30 seconds.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;mise&lt;/strong&gt;, in a tool image&amp;rsquo;s build and on this machine, tries each download again six times (&lt;code&gt;MISE_HTTP_RETRIES&lt;/code&gt;), as its own three end within a two-minute stall.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;tldr --update&lt;/code&gt;&lt;/strong&gt;, in the &lt;code&gt;cli-tools&lt;/code&gt; feature, gives up after a minute, as it has no timeout of its own, and the feature warns that you can run it in the VM.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="keys-and-caching"&gt;Keys and caching&lt;span class="hx:absolute hx:-mt-20" id="keys-and-caching"&gt;&lt;/span&gt;
&lt;a href="#keys-and-caching" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm builds images in layers and caches them, as Docker does. &lt;code&gt;base&lt;/code&gt; comes first, and each layer is built on its parent, so &lt;code&gt;foo+bar&lt;/code&gt; is &lt;code&gt;bar&lt;/code&gt; on &lt;code&gt;foo&lt;/code&gt; on &lt;code&gt;base&lt;/code&gt;. A layer starts from its parent and runs its script inside it, and devvm stores it under a key, which is a hash of everything that goes into it. When an image with that key already exists, devvm uses it, and otherwise it builds one.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Image&lt;/th&gt;
&lt;th&gt;Its key hashes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;base&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the backend, base&amp;rsquo;s Lima template (&lt;code&gt;base.yaml&lt;/code&gt;), devvm&amp;rsquo;s prelude (&lt;code&gt;prelude.sh&lt;/code&gt;), the apt script (&lt;code&gt;apt.sh&lt;/code&gt;), base&amp;rsquo;s script (&lt;code&gt;base.sh&lt;/code&gt;), the chosen features that devvm has, in order (each name and its script), its rebuild counter, and with &lt;code&gt;--from&lt;/code&gt;, the image, its digest and the scripts that convert it; on Lima, the Ubuntu cloud image pinned on this machine (its release, file and SHA-256), base&amp;rsquo;s disk size, and the user that a &lt;code&gt;--from&lt;/code&gt; conversion puts in the image (its name, uid and home folder) with the converted disk&amp;rsquo;s size&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a built-in layer&lt;/td&gt;
&lt;td&gt;its parent&amp;rsquo;s key, its name, the prelude, the apt script, its own script, which devvm ships, and its rebuild counter&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a custom layer&lt;/td&gt;
&lt;td&gt;its parent&amp;rsquo;s key, its name, the prelude, the apt script, its script (&lt;code&gt;~/.config/devvm/layers/&amp;lt;name&amp;gt;.sh&lt;/code&gt;) with the prelude before it, and its rebuild counter&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;devvm puts together each image&amp;rsquo;s recipe once, as the ordered list of steps its build runs. A step is a script with its name, its arguments and whether it runs as root. Each script in a recipe that runs with bash, devvm&amp;rsquo;s own and a custom layer&amp;rsquo;s alike, starts with devvm&amp;rsquo;s prelude, which &lt;a href="#the-scripts-prelude"&gt;the scripts&amp;rsquo; prelude&lt;/a&gt; describes, so the recipe holds the prelude and the script together. The recipe of &lt;code&gt;base&lt;/code&gt; starts with the backend&amp;rsquo;s own steps, which say what the backend makes &lt;code&gt;base&lt;/code&gt;&amp;rsquo;s disk from. On Lima, those are the Ubuntu cloud image pinned on this machine, base&amp;rsquo;s disk size and &lt;code&gt;base.yaml&lt;/code&gt;, and with &lt;code&gt;--from&lt;/code&gt;, the conversion&amp;rsquo;s scripts too, &lt;code&gt;build.sh&lt;/code&gt; with its arguments. Then come &lt;code&gt;apt.sh begin&lt;/code&gt;, &lt;code&gt;base.sh&lt;/code&gt;, the chosen features&amp;rsquo; scripts and &lt;code&gt;apt.sh end&lt;/code&gt;, while a layer&amp;rsquo;s recipe is &lt;code&gt;apt.sh lists&lt;/code&gt; and then its own script. The key hashes that recipe, and the backend is given the same recipe and runs it as it is, so nothing reaches a build that its key doesn&amp;rsquo;t hold, apart from base&amp;rsquo;s packages: those are the ones its key recorded at its first build, or the mirror to record them from, which &lt;a href="#bases-packages"&gt;base&amp;rsquo;s packages&lt;/a&gt; describes. A chosen feature without a script isn&amp;rsquo;t in the recipe, and devvm warns about it (&lt;code&gt;unknown_feature&lt;/code&gt;) when it builds &lt;code&gt;base&lt;/code&gt;. The user&amp;rsquo;s CAs and a company proxy&amp;rsquo;s variables are added to each step while it runs and taken out again, so they aren&amp;rsquo;t in the recipe, and the image keeps none of them. A build&amp;rsquo;s CPUs and memory aren&amp;rsquo;t in it either, because the host&amp;rsquo;s size doesn&amp;rsquo;t change what an image holds, but base&amp;rsquo;s disk size is, because the disk is part of the image (&lt;a href="#bases-size"&gt;base&amp;rsquo;s size&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;A key is the first 12 hex digits of a SHA-256. Each input goes into the hash with its length, so different inputs never hash the same bytes. An image&amp;rsquo;s record keeps its chain, which is the key of each image it&amp;rsquo;s built on, from &lt;code&gt;base&lt;/code&gt; up.&lt;/p&gt;
&lt;p&gt;Each key hashes its parent&amp;rsquo;s, so a new key anywhere in the chain changes the key of every image above it:&lt;/p&gt;
&lt;div class="devvm-diagram" style="contain-intrinsic-block-size: auto 456px; --devvm-diagram-width: 513px"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" class="pele pele-flowchart" viewBox="0 0 513 456" width="513" height="456" style="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,&amp;quot;Departure Mono&amp;quot;, monospace);font:14px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,&amp;quot;Departure Mono&amp;quot;, monospace)" fill="var(--_fg)" role="graphics-document document" aria-roledescription="flowchart" aria-labelledby="d6b5091369547aaca--title" aria-describedby="d6b5091369547aaca--desc"&gt;&lt;title id="d6b5091369547aaca--title"&gt;Image keys in a chain&lt;/title&gt;&lt;desc id="d6b5091369547aaca--desc"&gt;Each image's key hashes its parent's key, as in base, then foo, then foo+bar. After foo.sh is edited, or devvm rebuild foo, base keeps its key and is reused, and foo and foo+bar get new keys and are built again.&lt;/desc&gt;&lt;g class="pele-clusters"&gt;&lt;g class="pele-cluster" data-id="built"&gt;&lt;rect x="285.91" y="42.5" width="218.55" height="371" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-cluster-label" fill="var(--_m)" x="322.18" y="65.9" text-anchor="middle"&gt;built&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-cluster" data-id="next"&gt;&lt;rect x="8" y="8" width="232.91" height="440" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-cluster-label" fill="var(--_m)" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="124.45" y="29.9"&gt;after foo.sh is edited,&lt;/tspan&gt;&lt;tspan x="124.45" y="47.9"&gt;or devvm rebuild foo&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round"&gt;&lt;g class="pele-edge" data-id="L_b2_f2_0"&gt;&lt;path d="M124.45,138L124.45,198"/&gt;&lt;path class="pele-marker" d="M124.45,205L121.09,197L127.81,197Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_f2_fb2_0"&gt;&lt;path d="M124.45,283L124.45,343"/&gt;&lt;path class="pele-marker" d="M124.45,350L121.09,342L127.81,342Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_b1_f1_0"&gt;&lt;path d="M395.18,139.5L395.18,199.5"/&gt;&lt;path class="pele-marker" d="M395.18,206.5L391.82,198.5L398.54,198.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_f1_fb1_0"&gt;&lt;path d="M395.18,266.5L395.18,326.5"/&gt;&lt;path class="pele-marker" d="M395.18,333.5L391.82,325.5L398.54,325.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edge-labels" font-size="14"&gt;&lt;g class="pele-edge-label" data-id="L_b2_f2_0"&gt;&lt;rect x="89.27" y="162.5" width="70.36" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="124.45" y="175.7" text-anchor="middle"&gt;its key&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_f2_fb2_0"&gt;&lt;rect x="89.27" y="307.5" width="70.36" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="124.45" y="320.7" text-anchor="middle"&gt;its key&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_b1_f1_0"&gt;&lt;rect x="360" y="164" width="70.36" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="395.18" y="177.2" text-anchor="middle"&gt;its key&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_f1_fb1_0"&gt;&lt;rect x="360" y="291" width="70.36" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="395.18" y="304.2" text-anchor="middle"&gt;its key&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-nodes"&gt;&lt;g class="pele-node pele-shape-rect" data-id="b2" transform="translate(124.45,99)"&gt;&lt;rect x="-89.27" y="-39" width="178.55" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;base&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;key 1a2b3c4d5e6f&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;reused&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="f2" transform="translate(124.45,244)"&gt;&lt;rect x="-89.27" y="-39" width="178.55" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;foo&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;key 9a0b1c2d3e4f&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;built again&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="fb2" transform="translate(124.45,389)"&gt;&lt;rect x="-89.27" y="-39" width="178.55" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;foo+bar&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;key 5a6b7c8d9e0f&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;built again&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="b1" transform="translate(395.18,109.5)"&gt;&lt;rect x="-89.27" y="-30" width="178.55" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;base&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;key 1a2b3c4d5e6f&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="f1" transform="translate(395.18,236.5)"&gt;&lt;rect x="-89.27" y="-30" width="178.55" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;foo&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;key 7a8b9c0d1e2f&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="fb1" transform="translate(395.18,363.5)"&gt;&lt;rect x="-89.27" y="-30" width="178.55" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;foo+bar&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;key 3a4b5c6d7e8f&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/div&gt;&lt;p&gt;This means:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When you edit a script, its layer and every layer above it rebuild the next time they&amp;rsquo;re used, and the layers below are reused.&lt;/li&gt;
&lt;li&gt;Each backend builds its own images and never uses another backend&amp;rsquo;s.&lt;/li&gt;
&lt;li&gt;With &lt;code&gt;--from&lt;/code&gt;, base&amp;rsquo;s key has the image&amp;rsquo;s &lt;a href="#digests"&gt;digest&lt;/a&gt;, so when the tag moves to a new image, base and everything on it rebuild.&lt;/li&gt;
&lt;li&gt;A layer whose script is gone hashes as missing, so its images don&amp;rsquo;t match any more.&lt;/li&gt;
&lt;li&gt;Nothing else counts. Features you haven&amp;rsquo;t chosen change no key, and neither do policy files (&lt;code&gt;*.policy&lt;/code&gt;), which the proxy reads at run time and which never go into an image.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;An image whose key doesn&amp;rsquo;t match its inputs any more is stale. It stays until it&amp;rsquo;s deleted (&lt;a href="https://next.devvm.dev/docs/using/images/#cleaning-up"&gt;cleaning up&lt;/a&gt;), and the next use builds a new one.&lt;/p&gt;
&lt;h2 data-hextra-search-id="rebuilding"&gt;Rebuilding&lt;span class="hx:absolute hx:-mt-20" id="rebuilding"&gt;&lt;/span&gt;
&lt;a href="#rebuilding" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm rebuild&lt;/code&gt; works through the rebuild counter, which each image&amp;rsquo;s key hashes. The counters are in &lt;code&gt;~/.local/share/devvm/images/rebuilds.json&lt;/code&gt;, one for each backend, each image that base starts from, as &lt;code&gt;--from&lt;/code&gt; gives it, and each image, so a rebuild on one backend leaves the other backends&amp;rsquo; images and their VMs as they are, and so does a rebuild from another container image. A rebuild writes a new value into its counter, made of the time and a random part, so the image gets a new key, and so does every image built on it. A rebuild of base on Lima also pins the newest &lt;a href="#ubuntus-cloud-image"&gt;Ubuntu cloud image&lt;/a&gt; first, while a rebuild of a &lt;code&gt;--from&lt;/code&gt; base looks up its container image&amp;rsquo;s digest again and keeps the cloud image pinned. The counters can&amp;rsquo;t be in an image&amp;rsquo;s folder, because a counter is an input to the key that names that folder. A devvm changing a counter holds a lock, &lt;code&gt;~/.local/share/devvm/images/locks/rebuilds&lt;/code&gt;, while it reads the file and writes it whole, so two rebuilds at once both keep their new values. devvm lists those images first (&lt;code&gt;rebuild_replaces&lt;/code&gt;). After the build, it deletes every stale image that no VM uses, which includes the old image and those built on it, and they&amp;rsquo;re built again, on the new image, the next time they&amp;rsquo;re needed. On Linux hosts, an image whose disk VMs are overlays of stays, and devvm says which VMs use it.&lt;/p&gt;
&lt;p&gt;A VM keeps the image it was made from, and its state keeps that image&amp;rsquo;s chain. When a key in the chain changes, after an edited script or a rebuild, devvm warns on each launch that the VM is outdated (&lt;code&gt;vm_outdated&lt;/code&gt;) and leaves the VM as it is (&lt;a href="https://next.devvm.dev/docs/using/images/#outdated-vms"&gt;outdated VMs&lt;/a&gt;). &lt;code&gt;devvm update&lt;/code&gt; makes the same check, comparing each image&amp;rsquo;s key in the recorded chain with its key as it is now, and when one differs, it makes the VM again from the same image name (&lt;a href="https://next.devvm.dev/docs/internals/overview/#making-a-vm-again"&gt;making a VM again&lt;/a&gt;). Otherwise, when the VM also had the newest shared tools, it says the VM is current (&lt;code&gt;vm_current&lt;/code&gt;). Shared tool images have keys of their own, which &lt;a href="#building-tools"&gt;building tools&lt;/a&gt; describes, and they&amp;rsquo;re never in the chain, so newer shared tools alone don&amp;rsquo;t lead &lt;code&gt;devvm update&lt;/code&gt; to make the VM again.&lt;/p&gt;
&lt;h2 data-hextra-search-id="ubuntus-cloud-image"&gt;Ubuntu&amp;rsquo;s cloud image&lt;span class="hx:absolute hx:-mt-20" id="ubuntus-cloud-image"&gt;&lt;/span&gt;
&lt;a href="#ubuntus-cloud-image" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;On Lima, base starts from a dated release of Ubuntu 26.04&amp;rsquo;s cloud image (&lt;code&gt;release-YYYYMMDD&lt;/code&gt; on cloud-images.ubuntu.com), which devvm pins on this machine the first time it builds base. devvm&amp;rsquo;s own files hold only the release, 26.04, and Ubuntu&amp;rsquo;s cloud image key (fingerprint &lt;code&gt;D2EB44626FDDC30B513D5BB71A5D6C4C7DB87C81&lt;/code&gt;), so nothing in devvm needs moving when Ubuntu publishes a new image.&lt;/p&gt;
&lt;p&gt;To pin an image, devvm reads the list of dated releases at cloud-images.ubuntu.com and takes the newest one whose checksums list an image for the host:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The release&amp;rsquo;s &lt;code&gt;SHA256SUMS&lt;/code&gt; must carry a valid signature from Ubuntu&amp;rsquo;s cloud image key, in its &lt;code&gt;SHA256SUMS.gpg&lt;/code&gt;. No other key counts. devvm checks the signature itself, with the standard library&amp;rsquo;s RSA and SHA-2, so it needs no &lt;code&gt;gpgv&lt;/code&gt; or other program. When the signature is missing or doesn&amp;rsquo;t check out, devvm refuses the release (&lt;code&gt;ubuntu_bad_signature&lt;/code&gt;), and it never falls back to an older release for that reason.&lt;/li&gt;
&lt;li&gt;The host&amp;rsquo;s image, &lt;code&gt;ubuntu-26.04-server-cloudimg-arm64.img&lt;/code&gt; or &lt;code&gt;-amd64.img&lt;/code&gt;, must be listed with a SHA-256 of 64 hex digits. A release that lists none is passed over for the next older one, and when no release has one, devvm stops (&lt;code&gt;no_ubuntu_release&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;When devvm can&amp;rsquo;t read the list, it stops (&lt;code&gt;ubuntu_unreachable&lt;/code&gt;), and nothing is pinned. When a server&amp;rsquo;s certificate is what stops devvm reading the list, a release&amp;rsquo;s checksums or their signature, it says why, as it does for the download below (&lt;code&gt;ubuntu_untrusted&lt;/code&gt;, &lt;code&gt;ubuntu_bad_certificate&lt;/code&gt;, &lt;code&gt;ubuntu_certificate_invalid&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;devvm records the pin in &lt;code&gt;~/.local/share/devvm/images/ubuntu.json&lt;/code&gt;: the release, the image&amp;rsquo;s file name, its SHA-256 and when it was pinned. One devvm pins at a time, holding &lt;code&gt;~/.local/share/devvm/images/locks/ubuntu&lt;/code&gt;, so two first builds pin the same image. Every later build of base on this machine uses the pinned image without looking anything up, so it needs no network for the image once devvm has it.&lt;/p&gt;
&lt;p&gt;devvm downloads the image itself, into &lt;code&gt;~/.local/share/devvm/images/ubuntu/&amp;lt;sha256&amp;gt;.img&lt;/code&gt;, and gives Lima that file, so Lima downloads nothing. The download goes through the company proxy, when there is one (&lt;a href="https://next.devvm.dev/docs/contributing/design/#a-company-proxy"&gt;a company proxy&lt;/a&gt;), and it trusts the CAs in &lt;code&gt;~/.config/devvm/ca&lt;/code&gt; as well as this machine&amp;rsquo;s own, as the lookups of the dated releases do. A server whose certificate this machine doesn&amp;rsquo;t trust fails it at once (&lt;code&gt;ubuntu_untrusted&lt;/code&gt;), naming the folder of your CAs, and so does a certificate from a CA it trusts that&amp;rsquo;s for another host, out of date or not valid yet (&lt;code&gt;ubuntu_bad_certificate&lt;/code&gt;), which a wrong clock or another server answering for the host causes, so no CA mends it. Any other certificate that fails to verify, such as one signed with SHA-1 or by a CA whose name constraints leave the host out, fails it at once too, naming Go&amp;rsquo;s reason (&lt;code&gt;ubuntu_certificate_invalid&lt;/code&gt;). These are &lt;code&gt;fetch.Untrusted&lt;/code&gt;, &lt;code&gt;fetch.BadCertificate&lt;/code&gt; and &lt;code&gt;fetch.Unverified&lt;/code&gt;, which the lookups ask too, so each names the same cause, and devvm&amp;rsquo;s own mise asks &lt;code&gt;fetch.Untrusted&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;What came stays in &lt;code&gt;&amp;lt;sha256&amp;gt;.img.part&lt;/code&gt; across failures and runs, and the next try asks only for the rest, with an HTTP range and the file as it is, never compressed on the way. A try that reads nothing for 60 seconds ends, and five tries in a row that bring nothing fail the download (&lt;code&gt;ubuntu_download_failed&lt;/code&gt;), as do 100 tries in all, however much each brought. A failure that trying again in the same run won&amp;rsquo;t mend, such as a 403 or a company proxy that refuses, keeps the part for the next run too. Only a server that says the file is gone (404 or 410) and a file over 4 GiB take the part with them. A release that&amp;rsquo;s gone fails with &lt;code&gt;ubuntu_release_gone&lt;/code&gt;, which names &lt;code&gt;devvm rebuild base&lt;/code&gt;, as every try would get the same answer. A server that answers a range from another byte starts the part again, and a part that&amp;rsquo;s already the whole file, as a run killed before it kept the file leaves it, is kept without asking for more. A part that can&amp;rsquo;t be written, such as on a full disk, fails at once with that cause. devvm keeps the file only once its SHA-256 is the pin&amp;rsquo;s, and a file that doesn&amp;rsquo;t check out is downloaded again from nothing once before it fails (&lt;code&gt;ubuntu_image_checksum&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;One devvm downloads at a time, holding &lt;code&gt;~/.local/share/devvm/images/locks/ubuntu-image&lt;/code&gt;, and another waits for it under a status line (&lt;code&gt;ubuntu_image_waiting&lt;/code&gt;). Before it downloads, devvm takes the image from Lima&amp;rsquo;s own download cache when that holds it with the pin&amp;rsquo;s SHA-256, where a build of base by an earlier release of devvm, which had Lima download the image, left it, under the SHA-256 of the image&amp;rsquo;s address. devvm copies the file into a new file of its own, &lt;code&gt;&amp;lt;sha256&amp;gt;.img.import&lt;/code&gt;, which only you can read, hashes the bytes as it writes them and keeps the copy only once they&amp;rsquo;re the pin&amp;rsquo;s. It never links to Lima&amp;rsquo;s file or changes Lima&amp;rsquo;s cache. Lima 2.3 and newer check the file devvm gives it against the pin&amp;rsquo;s SHA-256 too, before they copy the file into the VM&amp;rsquo;s disk, and refuse one that doesn&amp;rsquo;t match. A &lt;code&gt;file://&lt;/code&gt; address, which only a test build&amp;rsquo;s &lt;code&gt;DEVVM_UBUNTU_URL&lt;/code&gt; can name, goes the same way, read from disk, and devvm refuses any other address that isn&amp;rsquo;t https.&lt;/p&gt;
&lt;p&gt;A pin for another architecture, such as in a data folder copied from another machine, counts as none, and the next build pins one for this host. A &lt;code&gt;--from&lt;/code&gt; base&amp;rsquo;s conversion boots the pinned image too, and pins one only when none is.&lt;/p&gt;
&lt;p&gt;An image devvm pinned in the same run that doesn&amp;rsquo;t boot, so that the backend fails to start base&amp;rsquo;s build VM, gets one second chance. devvm says so (&lt;code&gt;origin_no_boot&lt;/code&gt;), pins the newest release older than it, which it checks the same way, and builds base on that, so a broken new release of Ubuntu&amp;rsquo;s doesn&amp;rsquo;t stop new machines&amp;rsquo; first builds. The older release is what stays pinned. devvm tries this once a run, and never for an image that was pinned before the run, because that one booted then. The build VM that didn&amp;rsquo;t boot stays, stopped, as a &lt;a href="https://next.devvm.dev/docs/using/troubleshooting/#a-build-fails"&gt;failed build&lt;/a&gt; does.&lt;/p&gt;
&lt;p&gt;The pin is part of base&amp;rsquo;s recipe, so base&amp;rsquo;s key hashes the release, the file and its SHA-256, and a new pin makes a new base. base&amp;rsquo;s record keeps the address and SHA-256 of the image it was built from. Ubuntu removes its dated releases after a few months, so a base built from one that&amp;rsquo;s gone can still be used, but building it again needs devvm&amp;rsquo;s copy of the image, or Lima&amp;rsquo;s. &lt;code&gt;devvm gc --caches&lt;/code&gt; deletes devvm&amp;rsquo;s copies that no image&amp;rsquo;s record names and that aren&amp;rsquo;t pinned now, with a stopped download&amp;rsquo;s &lt;code&gt;.part&lt;/code&gt; and a stopped copy&amp;rsquo;s &lt;code&gt;.import&lt;/code&gt;, and those of any image once its &lt;code&gt;.img&lt;/code&gt; is there, unless one changed in the last hour. When devvm can&amp;rsquo;t read the pin, &lt;code&gt;devvm gc --caches&lt;/code&gt; fails rather than delete a copy the pin may name.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm gc --caches&lt;/code&gt; deletes an entry of Lima&amp;rsquo;s cache only when devvm&amp;rsquo;s own state shows that a build of devvm&amp;rsquo;s left it there and none needs it now: an image&amp;rsquo;s record names its address, as a build of base by an earlier release of devvm had Lima download it, devvm has its own copy of that image, which builds use instead, and it hasn&amp;rsquo;t changed in the last hour. An entry that no record names stays, because the user&amp;rsquo;s own Lima VMs share the cache and may have downloaded the same image. So does an entry for an image that the installed Lima&amp;rsquo;s own templates name, which devvm reads from the &lt;code&gt;share/lima/templates&lt;/code&gt; folder beside the &lt;code&gt;limactl&lt;/code&gt; on &lt;code&gt;PATH&lt;/code&gt;, as &lt;code&gt;limactl start&lt;/code&gt; with Lima&amp;rsquo;s templates starts from it, and devvm frees no entry of Lima&amp;rsquo;s when it can&amp;rsquo;t read them, with a line in the run log that names the folder and why.&lt;/p&gt;
&lt;h2 data-hextra-search-id="bases-settings-and-pins"&gt;Base&amp;rsquo;s settings and pins&lt;span class="hx:absolute hx:-mt-20" id="bases-settings-and-pins"&gt;&lt;/span&gt;
&lt;a href="#bases-settings-and-pins" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Base&amp;rsquo;s size is 4 CPUs, 8 GiB of memory and a 100 GiB disk, which devvm sets in its own code, and it fits the CPUs and memory to the host (&lt;a href="#bases-size"&gt;base&amp;rsquo;s size&lt;/a&gt;). On Lima, base&amp;rsquo;s Lima template holds base&amp;rsquo;s other VM settings. Base&amp;rsquo;s script installs base, and the optional &lt;a href="https://next.devvm.dev/docs/using/customizing/"&gt;features&lt;/a&gt; you chose follow it.&lt;/p&gt;
&lt;p&gt;Each download in base&amp;rsquo;s script is pinned to a version and a SHA-256 at the top of the script, and the build fails if a checksum doesn&amp;rsquo;t match. Each feature pins its downloads in the same way, at the top of its script in the repo, which is built into devvm (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt; has where each script is). apt&amp;rsquo;s packages are pinned per image key, as &lt;a href="#bases-packages"&gt;base&amp;rsquo;s packages&lt;/a&gt; describes.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-scripts-prelude"&gt;The scripts&amp;rsquo; prelude&lt;span class="hx:absolute hx:-mt-20" id="the-scripts-prelude"&gt;&lt;/span&gt;
&lt;a href="#the-scripts-prelude" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;devvm&amp;rsquo;s prelude, &lt;code&gt;prelude.sh&lt;/code&gt;, comes first in each script that a build runs with bash: &lt;code&gt;base.sh&lt;/code&gt; and &lt;code&gt;apt.sh&lt;/code&gt;, the built-in layers and features, your own layers, the shared tools&amp;rsquo; &lt;code&gt;build.sh&lt;/code&gt;, and a &lt;code&gt;--from&lt;/code&gt; conversion&amp;rsquo;s &lt;code&gt;build.sh&lt;/code&gt;. devvm puts it before the script on the script&amp;rsquo;s standard input, and for the conversion, in the copy of &lt;code&gt;build.sh&lt;/code&gt; that it writes into the conversion&amp;rsquo;s own temporary folder, so no copy of either is kept anywhere else. The prelude sets no shell options and runs only &lt;code&gt;uname&lt;/code&gt; and &lt;code&gt;command -v&lt;/code&gt;. It gives the script three things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;$devvm_arch&lt;/code&gt; is the VM&amp;rsquo;s architecture as the pins name it, &lt;code&gt;arm64&lt;/code&gt; or &lt;code&gt;amd64&lt;/code&gt;. On any other architecture, the prelude stops the script.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$devvm_libc&lt;/code&gt; is the VM&amp;rsquo;s C library, &lt;code&gt;musl&lt;/code&gt; on Alpine, where &lt;code&gt;apk&lt;/code&gt; is, and &lt;code&gt;gnu&lt;/code&gt; everywhere else.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;devvm_sha TOOL&lt;/code&gt; prints TOOL&amp;rsquo;s pinned SHA-256 for this VM, which is the script&amp;rsquo;s own &lt;code&gt;TOOL_sha256_&amp;lt;arch&amp;gt;_musl&lt;/code&gt; on musl when the script pins one, and its &lt;code&gt;TOOL_sha256_&amp;lt;arch&amp;gt;&lt;/code&gt; otherwise. A script that pins none for this VM gets an error that names the pin.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The prelude goes in as one line, &lt;code&gt;eval $'…'&lt;/code&gt;, which holds the whole file in bash&amp;rsquo;s ANSI-C quoting, and that line takes the place of the script&amp;rsquo;s &lt;code&gt;#!&lt;/code&gt; line. Each of the script&amp;rsquo;s lines then keeps its number in bash&amp;rsquo;s errors and in &lt;code&gt;$LINENO&lt;/code&gt;, and a script without a &lt;code&gt;#!&lt;/code&gt; line gets the prelude&amp;rsquo;s line before its first, so its lines are one further down. A build&amp;rsquo;s exports for a company proxy and for your CAs go on that same first line, before the &lt;code&gt;eval&lt;/code&gt;, so they don&amp;rsquo;t move the script&amp;rsquo;s lines either.&lt;/p&gt;
&lt;p&gt;Each of devvm&amp;rsquo;s scripts that uses the prelude checks that it came first, with &lt;code&gt;: &amp;quot;${devvm_arch:?}&amp;quot;&lt;/code&gt; for each variable it reads, so it stops at once when run without it. The key of each image and tool image whose build runs one of these scripts hashes the prelude with the script, so a change to the prelude rebuilds every image and every shared tool image. &lt;code&gt;bootify.sh&lt;/code&gt;, which runs with the container image&amp;rsquo;s own &lt;code&gt;sh&lt;/code&gt;, and &lt;code&gt;kernel.sh&lt;/code&gt; don&amp;rsquo;t get it.&lt;/p&gt;
&lt;p&gt;Your own layer gets the prelude in the same way, so it can pin its downloads as devvm&amp;rsquo;s scripts do and pick them with &lt;code&gt;devvm_sha&lt;/code&gt;, which &lt;a href="https://next.devvm.dev/docs/using/customizing/#example-mailpit"&gt;Customizing&amp;rsquo;s example&lt;/a&gt; shows. The prelude runs first, so a name your script sets or defines afterwards, &lt;code&gt;devvm_arch&lt;/code&gt; or &lt;code&gt;devvm_sha&lt;/code&gt; included, is your script&amp;rsquo;s from then on, and a script that never uses the prelude runs just as it would without it. Your layer&amp;rsquo;s step in its image&amp;rsquo;s recipe holds the prelude and your script together, so a change to either one rebuilds that image and the images above it.&lt;/p&gt;
&lt;h2 data-hextra-search-id="bases-packages"&gt;Base&amp;rsquo;s packages&lt;span class="hx:absolute hx:-mt-20" id="bases-packages"&gt;&lt;/span&gt;
&lt;a href="#bases-packages" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;base&amp;rsquo;s recipe runs &lt;code&gt;apt.sh begin&lt;/code&gt; as root before &lt;code&gt;base.sh&lt;/code&gt;, and &lt;code&gt;apt.sh end&lt;/code&gt; after the last feature. Both are steps of the recipe, so base&amp;rsquo;s key hashes the script. What the build gives the script in &lt;code&gt;/var/cache/devvm/packages/in&lt;/code&gt; decides where apt&amp;rsquo;s packages come from:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A first build of a key records them.&lt;/strong&gt; devvm sends &lt;code&gt;in/mirrors&lt;/code&gt;, which holds the mirror that &lt;a href="https://next.devvm.dev/docs/using/settings/#an-ubuntu-mirror"&gt;&lt;code&gt;ubuntu-mirror&lt;/code&gt;&lt;/a&gt; sets, or nothing. &lt;code&gt;apt.sh begin&lt;/code&gt; points each of the image&amp;rsquo;s sources at an apt &lt;code&gt;mirror+file:&lt;/code&gt; list of that mirror and then the source&amp;rsquo;s own archive (&lt;code&gt;archive.ubuntu.com&lt;/code&gt;, or &lt;code&gt;ports.ubuntu.com&lt;/code&gt; on arm64), so apt tries them in that order, and it keeps every package it downloads. apt also installs phased updates (&lt;code&gt;APT::Get::Always-Include-Phased-Updates&lt;/code&gt;), which Ubuntu otherwise rolls out to only some machines at first, so it always takes the newest version that the lists have. apt checks the archive&amp;rsquo;s signature with Ubuntu&amp;rsquo;s archive key, which the image has, whichever mirror answers. At the end, &lt;code&gt;apt.sh end&lt;/code&gt; moves each downloaded package to &lt;code&gt;out/&amp;lt;sha256&amp;gt;.deb&lt;/code&gt; and writes its entry from apt&amp;rsquo;s package lists, which apt checked against that signature, to &lt;code&gt;out/Packages&lt;/code&gt;. The script fails the build when the lists have no entry with the file&amp;rsquo;s SHA-256. It also copies each &lt;code&gt;InRelease&lt;/code&gt; file and package list that apt used to &lt;code&gt;out/&amp;lt;n&amp;gt;.InRelease&lt;/code&gt; or &lt;code&gt;out/&amp;lt;n&amp;gt;.Packages&lt;/code&gt;, so devvm can check them on this machine. apt keeps those lists uncompressed while base builds (&lt;code&gt;Acquire::GzipIndexes &amp;quot;false&amp;quot;&lt;/code&gt;), as they&amp;rsquo;re signed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Every later build of the key replays them.&lt;/strong&gt; devvm sends the files the key recorded, from its cache, and &lt;code&gt;in/Packages&lt;/code&gt;, their entries, each naming its file. &lt;code&gt;apt.sh begin&lt;/code&gt; moves the image&amp;rsquo;s sources aside and gives apt only that folder, so &lt;code&gt;base.sh&lt;/code&gt; and the features install exactly what the first build did, with no network for them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A &lt;code&gt;--from&lt;/code&gt; base gets neither.&lt;/strong&gt; Its packages come from the container image&amp;rsquo;s own sources as they are when it builds, and they aren&amp;rsquo;t pinned.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both ends put the image&amp;rsquo;s own sources back, remove devvm&amp;rsquo;s apt settings, empty apt&amp;rsquo;s cache and delete the package lists, so a first build and a replay make the same image. A VM made from it fetches lists when you run &lt;code&gt;sudo apt update&lt;/code&gt;, and each layer&amp;rsquo;s recipe starts with &lt;code&gt;apt.sh lists&lt;/code&gt;, as root, which fetches them from the image&amp;rsquo;s own sources when there are none, so a layer&amp;rsquo;s script installs as it would on any Ubuntu. &lt;code&gt;apt.sh&lt;/code&gt; makes a source that sends nothing for 30 seconds fail. While it fetches the package lists, it turns apt&amp;rsquo;s retries off, and when no source answers, it exits 75, which the backend reports as &lt;code&gt;build_sources_unreachable&lt;/code&gt;, not as a script that failed. Once a source has answered, apt tries a package&amp;rsquo;s failed download again three times, each after a longer wait. A build fetches only the lists apt installs from, with no translations, AppStream components or command-not-found metadata (&lt;code&gt;Acquire::Languages &amp;quot;none&amp;quot;&lt;/code&gt;, and the &lt;code&gt;DEP-11&lt;/code&gt; and &lt;code&gt;CNF&lt;/code&gt; targets off), which is about a third less than an update fetches, and the image keeps none of them.&lt;/p&gt;
&lt;p&gt;The backend sends the build&amp;rsquo;s input into the VM as a tar stream before the first step, and after the last step it hands devvm a tar stream of &lt;code&gt;out/&lt;/code&gt; and deletes the folder, which is the backend&amp;rsquo;s packages role (&lt;a href="https://next.devvm.dev/docs/contributing/extending/#how-a-backend-plugs-in"&gt;how a backend plugs in&lt;/a&gt;). On Lima, both run as root over &lt;code&gt;limactl shell&lt;/code&gt;. What comes back is the build VM&amp;rsquo;s, so devvm checks it before it keeps anything (&lt;code&gt;packages_refused&lt;/code&gt;). It takes only regular files named &lt;code&gt;Packages&lt;/code&gt;, &lt;code&gt;&amp;lt;64 hex digits&amp;gt;.deb&lt;/code&gt;, &lt;code&gt;&amp;lt;n&amp;gt;.InRelease&lt;/code&gt; or &lt;code&gt;&amp;lt;n&amp;gt;.Packages&lt;/code&gt;, each package&amp;rsquo;s content must hash to its name, and each entry must name a file that came back with the size and SHA-256 the entry gives, with no file left over. Each &lt;code&gt;InRelease&lt;/code&gt; file is at most 4 MiB and all of them 32 MiB, and each package list is at most 512 MiB, with lines of at most 1 MiB and entries of at most 4 MiB, and all the lists 2 GiB. A name that comes back twice is refused.&lt;/p&gt;
&lt;p&gt;devvm doesn&amp;rsquo;t take the build VM&amp;rsquo;s word for the entries, because anything with root in that VM could write them. It checks each &lt;code&gt;InRelease&lt;/code&gt; file&amp;rsquo;s clearsigned signature itself, in Go, against Ubuntu&amp;rsquo;s archive key, which devvm&amp;rsquo;s own files hold (fingerprint &lt;code&gt;F6ECB3762474EDA9D21B7022871920D1991BC93C&lt;/code&gt;), and refuses one that doesn&amp;rsquo;t check out or isn&amp;rsquo;t one of the suites an Ubuntu 26.04 image&amp;rsquo;s sources name: &lt;code&gt;resolute&lt;/code&gt;, &lt;code&gt;resolute-updates&lt;/code&gt;, &lt;code&gt;resolute-security&lt;/code&gt; and &lt;code&gt;resolute-backports&lt;/code&gt;, never &lt;code&gt;resolute-proposed&lt;/code&gt;. It tries at most 4 signatures in each file, because each one hashes the whole file. It also refuses an &lt;code&gt;InRelease&lt;/code&gt; whose &lt;code&gt;Date:&lt;/code&gt; is older than the archive state the pinned cloud image was built from, because Ubuntu&amp;rsquo;s &lt;code&gt;InRelease&lt;/code&gt; files carry no &lt;code&gt;Valid-Until&lt;/code&gt;, so a mirror that stopped updating still serves validly signed ones. The release pocket, &lt;code&gt;resolute&lt;/code&gt;, which Ubuntu stopped changing at release, must be dated no earlier than that day, 2026-04-23, which devvm&amp;rsquo;s code records. Every other pocket (&lt;code&gt;resolute-updates&lt;/code&gt;, &lt;code&gt;resolute-security&lt;/code&gt;, &lt;code&gt;resolute-backports&lt;/code&gt;) must be dated no more than a day before the pinned release&amp;rsquo;s date (&lt;code&gt;release-YYYYMMDD&lt;/code&gt;). devvm names the mirror that &lt;a href="https://next.devvm.dev/docs/using/settings/#an-ubuntu-mirror"&gt;&lt;code&gt;ubuntu-mirror&lt;/code&gt;&lt;/a&gt; sets (&lt;code&gt;packages_stale_mirror&lt;/code&gt;), or Ubuntu&amp;rsquo;s archive when none is set (&lt;code&gt;packages_stale&lt;/code&gt;). devvm compares the lists with the cloud image&amp;rsquo;s date, not with today&amp;rsquo;s, so a mirror that&amp;rsquo;s behind, or one that&amp;rsquo;s lying, can&amp;rsquo;t serve lists older than that, but a mirror that fell behind after that date can still give base packages older than Ubuntu&amp;rsquo;s, which is why &lt;a href="https://next.devvm.dev/docs/using/settings/#an-ubuntu-mirror"&gt;&lt;code&gt;ubuntu-mirror&lt;/code&gt;&lt;/a&gt; should name only a mirror you trust to keep up. Each package list must have the SHA-256 and size that a verified &lt;code&gt;InRelease&lt;/code&gt; gives for one of its &lt;code&gt;Packages&lt;/code&gt; lists, which devvm checks before it reads the list, and each package&amp;rsquo;s SHA-256 must be in one of those lists, as the same package, version, architecture and size that apt&amp;rsquo;s entry says. devvm then keeps the archive&amp;rsquo;s own entry for the package, not apt&amp;rsquo;s.&lt;/p&gt;
&lt;p&gt;devvm also checks that each package is the newest version that apt would install, because whatever has root in the build VM could hand back only the lists it chooses, such as the release pocket&amp;rsquo;s, and record an older version than &lt;code&gt;resolute-updates&lt;/code&gt; or &lt;code&gt;resolute-security&lt;/code&gt; has. A recording must give back the &lt;code&gt;InRelease&lt;/code&gt; files of &lt;code&gt;resolute-updates&lt;/code&gt; and &lt;code&gt;resolute-security&lt;/code&gt; with lists for the architectures whose lists have the recorded packages, such as &lt;code&gt;binary-arm64&lt;/code&gt;, so another archive&amp;rsquo;s &lt;code&gt;InRelease&lt;/code&gt;, such as &lt;code&gt;archive.ubuntu.com&lt;/code&gt;&amp;rsquo;s on arm64, where &lt;code&gt;ports.ubuntu.com&lt;/code&gt; has the lists, doesn&amp;rsquo;t count. For each &lt;code&gt;InRelease&lt;/code&gt; it gives back, it must also give back every package list that the file gives for those architectures, in every component (&lt;code&gt;main&lt;/code&gt;, &lt;code&gt;restricted&lt;/code&gt;, &lt;code&gt;universe&lt;/code&gt; and &lt;code&gt;multiverse&lt;/code&gt;). An empty list is the one exception, because it lists nothing. When one is missing, devvm names the suite and keeps nothing (&lt;code&gt;packages_lists_missing&lt;/code&gt;). devvm then refuses a recorded package when the release pocket&amp;rsquo;s list, &lt;code&gt;resolute-updates&lt;/code&gt;&amp;rsquo; or &lt;code&gt;resolute-security&lt;/code&gt;&amp;rsquo;s has a newer version of it for that architecture, and it names the package, both versions and the suite (&lt;code&gt;packages_not_newest&lt;/code&gt;). &lt;code&gt;resolute-backports&lt;/code&gt; doesn&amp;rsquo;t count, because apt installs its packages only when you ask for them (its &lt;code&gt;InRelease&lt;/code&gt; says &lt;code&gt;NotAutomatic&lt;/code&gt;). devvm orders versions as &lt;code&gt;dpkg --compare-versions&lt;/code&gt; does, in its own Go code: the epoch first, then the upstream version, then the Debian revision, with letters before other characters and &lt;code&gt;~&lt;/code&gt; before everything, even the end, so &lt;code&gt;1.0~rc1&lt;/code&gt; is older than &lt;code&gt;1.0&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;A recording that gives back no packages needs no lists. devvm writes the files into a folder of the build&amp;rsquo;s own in the cache while it checks them, and once the image is built, it moves each into the cache, &lt;code&gt;~/.local/share/devvm/packages/&amp;lt;sha256&amp;gt;.deb&lt;/code&gt;, and writes the key&amp;rsquo;s set, &lt;code&gt;~/.local/share/devvm/packages/sets/&amp;lt;key&amp;gt;.json&lt;/code&gt;: each package&amp;rsquo;s name, version, architecture, SHA-256, size and entry. A file the cache already has under that name is kept only when its checksum still matches it; devvm replaces a changed one with the build&amp;rsquo;s copy and notes that in the run log. That happens before the image&amp;rsquo;s record, under a lock, &lt;code&gt;~/.local/share/devvm/images/locks/packages&lt;/code&gt;, and a build that fails keeps nothing.&lt;/p&gt;
&lt;p&gt;A key&amp;rsquo;s set is written once, and the cache holds each file under its own SHA-256, so a build can&amp;rsquo;t change what another key installs. Before a replay, devvm reads each of the set&amp;rsquo;s files and checks its SHA-256 and size, and it refuses to build when one is gone or changed (&lt;code&gt;packages_missing&lt;/code&gt;), so it never records the key&amp;rsquo;s packages again. &lt;a href="#rebuilding"&gt;&lt;code&gt;devvm rebuild base&lt;/code&gt;&lt;/a&gt; gives base a new key, which records anew. &lt;code&gt;devvm gc&lt;/code&gt; deletes the sets of keys that are neither base&amp;rsquo;s key as it is now nor an image the backend has, and then, holding the lock, the package files that no set names then, so a set recorded meanwhile keeps its files. It also deletes a build&amp;rsquo;s own folder of what it gave back that&amp;rsquo;s over a day old, which a build that was killed leaves.&lt;/p&gt;
&lt;h2 data-hextra-search-id="bases-size"&gt;Base&amp;rsquo;s size&lt;span class="hx:absolute hx:-mt-20" id="bases-size"&gt;&lt;/span&gt;
&lt;a href="#bases-size" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm fits base&amp;rsquo;s CPUs and memory to the host with one rule that every backend uses. Base gets its 4 CPUs, or the host&amp;rsquo;s count when the host has fewer, because a Lima &lt;code&gt;vz&lt;/code&gt; VM given more CPUs than the Mac has can start so slowly that its ssh never comes up, as &lt;a href="https://github.com/lima-vm/lima/issues/1621" target="_blank" rel="noopener"&gt;Lima&amp;rsquo;s issue&lt;/a&gt; reports. Base gets its 8 GiB of memory, or half the host&amp;rsquo;s whole GiB when 8 GiB would leave the host less than 2 GiB, because a VM asking for all of the host&amp;rsquo;s memory doesn&amp;rsquo;t start.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Lima&lt;/strong&gt; passes the fitted size to &lt;code&gt;limactl create&lt;/code&gt; as &lt;code&gt;--cpus&lt;/code&gt; and &lt;code&gt;--memory&lt;/code&gt;, and base&amp;rsquo;s 100 GiB disk as &lt;code&gt;--disk&lt;/code&gt;, for base and for the VM that converts a &lt;code&gt;--from&lt;/code&gt; image. The images built on base are clones of it, so they and their VMs keep that size. A new VM&amp;rsquo;s disk is never smaller than base&amp;rsquo;s, because disks can&amp;rsquo;t shrink.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A size you set with &lt;code&gt;--cpus&lt;/code&gt;, &lt;code&gt;--memory&lt;/code&gt; or &lt;code&gt;devvm size -g&lt;/code&gt; replaces the fitted one. devvm checks that size against the same rule, so it refuses more memory than the host&amp;rsquo;s whole GiB less 2, or half of them on a host of 4 GiB or less, and the fitted memory always passes (&lt;a href="https://next.devvm.dev/docs/using/ports-size/#size-and-ports"&gt;size&lt;/a&gt;). The fitted size isn&amp;rsquo;t in image keys, because the host&amp;rsquo;s size doesn&amp;rsquo;t change what an image holds.&lt;/p&gt;
&lt;p&gt;base also drops the server extras that Ubuntu&amp;rsquo;s cloud image comes with, which are snapd, multipath, ModemManager, udisks, firmware updates, crash reporting, tracing tools, kernel headers, and apt&amp;rsquo;s background updates and upgrades. That saves 0.9 GB of disk and 100 MB of memory per VM, and the everyday tools stay (&lt;a href="https://next.devvm.dev/docs/using/images/#base"&gt;base&lt;/a&gt;). base&amp;rsquo;s own packages stay too, because devvm marks each one as installed by hand before it drops the extras. Otherwise a package that the cloud image has only for one of the extras, such as jq, would go with them whenever base&amp;rsquo;s install upgraded it to a newer version, because apt keeps such a package marked as one that only something else needs. If any of base&amp;rsquo;s packages is gone after the extras are dropped, the build fails and names it, so no base is recorded without it.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-desktop-layer"&gt;The desktop layer&lt;span class="hx:absolute hx:-mt-20" id="the-desktop-layer"&gt;&lt;/span&gt;
&lt;a href="#the-desktop-layer" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The built-in &lt;a href="https://next.devvm.dev/docs/using/images/#desktop"&gt;&lt;code&gt;desktop&lt;/code&gt; layer&lt;/a&gt;&amp;rsquo;s script is &lt;code&gt;desktop.sh&lt;/code&gt;, and its allowlist, &lt;code&gt;desktop.policy&lt;/code&gt;, has no rules, because the layer downloads nothing of its own and its packages come from the distribution&amp;rsquo;s archive, which base&amp;rsquo;s allowlist has. base&amp;rsquo;s image has no package lists, so the layer&amp;rsquo;s &lt;code&gt;apt.sh lists&lt;/code&gt; step fetches them first, and its packages are the archive&amp;rsquo;s as they are when the layer builds, which aren&amp;rsquo;t pinned. On &lt;code&gt;--from alpine&lt;/code&gt;, the script installs Alpine&amp;rsquo;s own packages, which aren&amp;rsquo;t pinned either. Besides Xfce and TigerVNC, the script writes &lt;code&gt;/usr/local/bin/devvm-desktop&lt;/code&gt;, which &lt;a href="https://next.devvm.dev/docs/internals/desktop/#in-the-vm"&gt;&lt;code&gt;devvm desktop&lt;/code&gt;&lt;/a&gt; runs in the VM. The layer needs no backend feature of its own, because it runs on any VM that can build an image and reach its ssh.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-docker-layer"&gt;The docker layer&lt;span class="hx:absolute hx:-mt-20" id="the-docker-layer"&gt;&lt;/span&gt;
&lt;a href="#the-docker-layer" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The built-in &lt;a href="https://next.devvm.dev/docs/using/images/#built-in-layers"&gt;&lt;code&gt;docker&lt;/code&gt; layer&lt;/a&gt;&amp;rsquo;s script is &lt;code&gt;docker.sh&lt;/code&gt;, embedded in devvm, and its &lt;a href="https://next.devvm.dev/docs/safety/network/#allowlists"&gt;allowlist&lt;/a&gt; is &lt;code&gt;docker.policy&lt;/code&gt;. The script pins the checksum of the signing key of Docker&amp;rsquo;s apt repository and each package&amp;rsquo;s version at the top. On &lt;code&gt;--from alpine&lt;/code&gt;, it installs Alpine&amp;rsquo;s own packages, which aren&amp;rsquo;t pinned. Running Docker&amp;rsquo;s engine in a VM is a backend feature of its own, &lt;code&gt;docker-layer&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/backends/#features"&gt;features&lt;/a&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-nix-layer"&gt;The nix layer&lt;span class="hx:absolute hx:-mt-20" id="the-nix-layer"&gt;&lt;/span&gt;
&lt;a href="#the-nix-layer" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The built-in &lt;a href="https://next.devvm.dev/docs/using/images/#nix"&gt;&lt;code&gt;nix&lt;/code&gt; layer&lt;/a&gt;&amp;rsquo;s script is &lt;code&gt;nix.sh&lt;/code&gt;, and its allowlist is &lt;code&gt;nix.policy&lt;/code&gt;. The script pins Nix&amp;rsquo;s release tarball, the direnv binary and nix-direnv&amp;rsquo;s &lt;code&gt;direnvrc&lt;/code&gt; at the top, each with its version and SHA-256, which are per architecture for Nix and direnv, and fetches them with &lt;code&gt;devvm-fetch&lt;/code&gt;. The repo&amp;rsquo;s bump script moves them (&lt;a href="https://next.devvm.dev/docs/contributing/maintaining/#updating-pinned-versions"&gt;updating pinned versions&lt;/a&gt;). Nix&amp;rsquo;s version is the one nixos.org&amp;rsquo;s installer fetches, at least 2.35.3, which fixes the scripted installer&amp;rsquo;s store ownership (GHSA-hf6w-2rg9-v84g) and the daemon&amp;rsquo;s store corruption through &lt;code&gt;repair&lt;/code&gt; (CVE-2026-110450). Nix&amp;rsquo;s newer releases come with another installer, from artifacts.nixos.org, so the layer&amp;rsquo;s pins change shape when it moves to one of them.&lt;/p&gt;
&lt;p&gt;The script runs the tarball&amp;rsquo;s own installer as &lt;code&gt;install --daemon --yes --no-channel-add&lt;/code&gt;, which copies the tarball&amp;rsquo;s store into &lt;code&gt;/nix&lt;/code&gt;, downloading nothing, makes the &lt;code&gt;nixbld&lt;/code&gt; build users and, under systemd, starts &lt;code&gt;nix-daemon&lt;/code&gt;. On OpenRC, which a base &lt;code&gt;--from alpine&lt;/code&gt; runs, the script adds a service of devvm&amp;rsquo;s, &lt;code&gt;/etc/init.d/nix-daemon&lt;/code&gt;, to the default runlevel and starts it, and before the install it adds Alpine&amp;rsquo;s &lt;code&gt;xz&lt;/code&gt;, unpinned, which GNU tar needs for the tarball. Nix&amp;rsquo;s own binaries are static or linked against the C library in its store, so they run on musl. Its extra settings turn on flakes and the &lt;code&gt;nix&lt;/code&gt; command and keep &lt;code&gt;trusted-users = root&lt;/code&gt;, so only root can choose caches and signing keys. They also set &lt;code&gt;sandbox = true&lt;/code&gt; and &lt;code&gt;sandbox-fallback = false&lt;/code&gt;, so a build fails where the kernel can&amp;rsquo;t sandbox it, rather than run outside the sandbox without a word. The installer writes any proxy variables it finds into a systemd drop-in for the daemon, which would put a build&amp;rsquo;s proxy into the image, so the script runs it without them. It points Nix at the system&amp;rsquo;s CAs, which hold devvm&amp;rsquo;s and yours. After the install, the script checks that every path in the store is root&amp;rsquo;s, and it fails otherwise.&lt;/p&gt;
&lt;p&gt;It also adds Nix&amp;rsquo;s default profile to the end of sudo&amp;rsquo;s &lt;code&gt;secure_path&lt;/code&gt;, through &lt;code&gt;/etc/sudoers.d/devvm-nix&lt;/code&gt;, so &lt;code&gt;sudo nix&lt;/code&gt; works, and appends Nix&amp;rsquo;s profiles to the &lt;code&gt;PATH&lt;/code&gt; that &lt;code&gt;BASH_ENV&lt;/code&gt; gives shells that read no profile. direnv goes into &lt;code&gt;/usr/local/bin&lt;/code&gt; and nix-direnv into &lt;code&gt;/usr/local/share/nix-direnv&lt;/code&gt;. A file in &lt;code&gt;~/.config/direnv/lib&lt;/code&gt; loads nix-direnv and puts each project&amp;rsquo;s direnv layout under &lt;code&gt;~/.cache/direnv/layouts&lt;/code&gt;, named by a hash of the project&amp;rsquo;s path, so its cached dev shell and garbage collector roots stay in the VM&amp;rsquo;s home and out of the project folder. direnv&amp;rsquo;s shell hook is in &lt;code&gt;~/.bashrc.d/direnv.sh&lt;/code&gt;, which bash loads before &lt;code&gt;mise.sh&lt;/code&gt;, and since each hook puts itself first in &lt;code&gt;PROMPT_COMMAND&lt;/code&gt;, direnv&amp;rsquo;s runs after mise&amp;rsquo;s, and a dev shell&amp;rsquo;s &lt;code&gt;PATH&lt;/code&gt; comes before the shared tools'.&lt;/p&gt;
&lt;p&gt;The daemon doesn&amp;rsquo;t read &lt;code&gt;/etc/environment&lt;/code&gt;, so the &lt;a href="https://next.devvm.dev/docs/internals/network/#the-vms-setup"&gt;VM&amp;rsquo;s setup&lt;/a&gt; gives it the VM&amp;rsquo;s proxy on every tier, in a drop-in of its own under systemd, or else in &lt;code&gt;/etc/conf.d/nix-daemon&lt;/code&gt;, which OpenRC reads for the service. The setup also puts the &lt;a href="https://next.devvm.dev/docs/internals/network/#the-shared-nix-cache"&gt;shared Nix cache&lt;/a&gt; first in Nix&amp;rsquo;s substituters, in &lt;code&gt;/etc/nix/devvm-cache.conf&lt;/code&gt;. It removes both files from a VM whose environment names no proxy. Running the layer is a backend feature, &lt;code&gt;nix-layer&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/backends/#features"&gt;features&lt;/a&gt;), and building it also needs the feature, so a backend without it refuses &lt;code&gt;devvm build nix&lt;/code&gt;. With &lt;code&gt;sandbox-fallback = false&lt;/code&gt;, every Nix build fails in a VM that can&amp;rsquo;t make the kernel namespaces that Nix&amp;rsquo;s sandbox needs.&lt;/p&gt;
&lt;h2 data-hextra-search-id="how-its-converted"&gt;How it&amp;rsquo;s converted&lt;span class="hx:absolute hx:-mt-20" id="how-its-converted"&gt;&lt;/span&gt;
&lt;a href="#how-its-converted" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;With &lt;code&gt;--from&lt;/code&gt;, devvm turns the container image into a disk in a throwaway VM, &lt;code&gt;devvm-oci-build&lt;/code&gt;, which it makes from Ubuntu&amp;rsquo;s cloud image with &lt;code&gt;base.yaml&lt;/code&gt;&amp;rsquo;s settings and base&amp;rsquo;s size. No Docker is needed:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/google/go-containerregistry/tree/main/cmd/crane" target="_blank" rel="noopener"&gt;crane&lt;/a&gt; downloads exactly the &lt;a href="#digests"&gt;digest&lt;/a&gt; in &lt;code&gt;base&lt;/code&gt;&amp;rsquo;s key, for this machine&amp;rsquo;s architecture, and flattens its layers. crane is pinned like every download: its version and SHA-256 are at the top of the conversion&amp;rsquo;s &lt;code&gt;build.sh&lt;/code&gt;, checked with &lt;code&gt;sha256sum&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;bootify.sh&lt;/code&gt;, in a chroot of the image, adds what a container lacks to boot as a VM: a kernel and initramfs, an init system (systemd, or OpenRC on Alpine), cloud-init, sshd and sudo, and your user in the VM. Your user has your uid, so &lt;code&gt;bootify.sh&lt;/code&gt; first removes a user of the image&amp;rsquo;s that has it, such as Ubuntu&amp;rsquo;s own &lt;code&gt;ubuntu&lt;/code&gt; (uid 1000, the uid a Linux host&amp;rsquo;s first user usually has).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;mke2fs&lt;/code&gt; writes the image&amp;rsquo;s files into a raw ext4 disk, and &lt;code&gt;base&lt;/code&gt; grows it to base&amp;rsquo;s 100 GiB disk.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;code&gt;build.sh&lt;/code&gt; also writes down the image&amp;rsquo;s C library, from its &lt;code&gt;/etc/os-release&lt;/code&gt;, and for a glibc image, its glibc version, which &lt;code&gt;getconf GNU_LIBC_VERSION&lt;/code&gt; prints in a chroot of the image. devvm checks both, keeps them in the record of &lt;code&gt;base&lt;/code&gt; and of every image on it (&lt;code&gt;libc&lt;/code&gt; and &lt;code&gt;glibc&lt;/code&gt;), and checks each shared tool against that glibc version (&lt;a href="#building-tools"&gt;building tools&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;devvm then deletes the build VM and creates &lt;code&gt;base&lt;/code&gt; from the disk, booting its kernel and initrd directly. One conversion runs at a time, because each holds a lock, &lt;code&gt;~/.local/share/devvm/oci-build.lock&lt;/code&gt;, so another devvm&amp;rsquo;s conversion waits for it under a status line (&lt;code&gt;oci_waiting&lt;/code&gt;). The lock is an OS lock on an open file, which the system releases when its devvm ends, however it ends, so a devvm that crashed never keeps another from converting.&lt;/p&gt;
&lt;h2 data-hextra-search-id="digests"&gt;Digests&lt;span class="hx:absolute hx:-mt-20" id="digests"&gt;&lt;/span&gt;
&lt;a href="#digests" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;base&lt;/code&gt; is keyed by the container image&amp;rsquo;s digest, not its tag. When devvm builds, it asks the image&amp;rsquo;s registry for the digest anonymously, with a &lt;code&gt;HEAD&lt;/code&gt; request for the image&amp;rsquo;s manifest, which doesn&amp;rsquo;t count against Docker Hub&amp;rsquo;s pull limit. When the registry asks for a token, devvm gets one from the registry&amp;rsquo;s token service, at an &lt;code&gt;https&lt;/code&gt; address only. The digest goes into &lt;code&gt;base&lt;/code&gt;&amp;rsquo;s key, and devvm records it for each container image in its cache, &lt;code&gt;~/.local/share/devvm/cache/from-digests.json&lt;/code&gt;, and in the record of each image it builds on that base. An existing VM&amp;rsquo;s state records what its base was made from (&lt;code&gt;from&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;For a VM made with &lt;code&gt;--from&lt;/code&gt;, devvm tells whether the VM is outdated from the container image&amp;rsquo;s digest that it last recorded, without looking anything up. When devvm makes the VM again, the build looks up the digest as every build does, so a tag that has moved since gives the VM the container image&amp;rsquo;s newer version too, and a pinned digest stays as it is (&lt;a href="https://next.devvm.dev/docs/using/images/#outdated-vms"&gt;outdated VMs&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The cache may be deleted at any time. Without it, devvm takes the digest from the record of the newest base built from the same container image, so every key stays as it was, and images stay current until a lookup finds that the tag has moved. The next lookup writes the cache again.&lt;/p&gt;
&lt;p&gt;devvm refuses a reference it can&amp;rsquo;t read (&lt;code&gt;bad_from&lt;/code&gt;). When it can&amp;rsquo;t reach the registry, it uses the digest it recorded last, with a warning (&lt;code&gt;from_cached_unreachable&lt;/code&gt;), and with none recorded, it fails (&lt;code&gt;from_unreachable&lt;/code&gt;). &lt;a href="https://next.devvm.dev/docs/using/from/#tags-and-digests"&gt;Tags and digests&lt;/a&gt; covers when a moved tag rebuilds base, how &lt;code&gt;@sha256:&lt;/code&gt; pins an image, and how devvm reads a reference.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-image-is-untrusted"&gt;The image is untrusted&lt;span class="hx:absolute hx:-mt-20" id="the-image-is-untrusted"&gt;&lt;/span&gt;
&lt;a href="#the-image-is-untrusted" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The container image&amp;rsquo;s own code runs as root in the build VM, so devvm treats what it writes as hostile:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The build VM is &lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;confined&lt;/a&gt; like any build with the internet, which it needs for crane, so on macOS it can&amp;rsquo;t reach this machine&amp;rsquo;s loopback, though on Linux it can. It mounts three folders of the conversion&amp;rsquo;s own temporary folder, &lt;code&gt;devvm-oci.&amp;lt;random&amp;gt;&lt;/code&gt;, and nothing else. &lt;code&gt;oci/&lt;/code&gt; holds the conversion&amp;rsquo;s scripts, which devvm writes there from &lt;a href="https://next.devvm.dev/docs/internals/install/#devvms-own-files"&gt;its own files&lt;/a&gt; for this build alone, and the VM mounts it read-only. &lt;code&gt;guest/&lt;/code&gt;, also read-only, holds only &lt;code&gt;ca.sh&lt;/code&gt;, and devvm writes and mounts it only when there are &lt;a href="#a-companys-ca-in-builds"&gt;company CAs&lt;/a&gt;. &lt;code&gt;vm/&lt;/code&gt; is the one writable folder, and devvm writes nothing there itself except an &lt;a href="#images-only-docker-has"&gt;image only Docker has&lt;/a&gt;, before the VM starts. The scripts sit beside &lt;code&gt;vm/&lt;/code&gt;, never inside it, so what the image writes can&amp;rsquo;t replace them on this machine.&lt;/li&gt;
&lt;li&gt;devvm checks what comes out once the build VM is gone. Each file must be a regular file, because a link could point Lima at a file on this machine. The kernel command line can hold only letters, digits, spaces and &lt;code&gt;=,./:_-&lt;/code&gt;, because it goes into Lima&amp;rsquo;s config. The C library must be &lt;code&gt;gnu&lt;/code&gt; or &lt;code&gt;musl&lt;/code&gt;. The disk must be raw ext4 as &lt;code&gt;mke2fs&lt;/code&gt; writes it into a new file, its first 1024 bytes zero and an ext4 superblock after them, because another format, such as qcow2, can name a file on this machine as its backing file, and its header would sit in those first bytes. A &lt;code&gt;glibc&lt;/code&gt; file must be a regular file before devvm reads it, because a link could name a FIFO on this machine, and the read would wait. devvm refuses anything else (&lt;code&gt;convert_bad_output&lt;/code&gt;), and it doesn&amp;rsquo;t create &lt;code&gt;base&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;devvm deletes the build VM and the temporary folder, with the scripts it wrote there, however the run ends, Ctrl+C included.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="images-only-docker-has"&gt;Images only Docker has&lt;span class="hx:absolute hx:-mt-20" id="images-only-docker-has"&gt;&lt;/span&gt;
&lt;a href="#images-only-docker-has" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When the registry doesn&amp;rsquo;t give devvm the image (&lt;a href="https://next.devvm.dev/docs/using/from/#images-only-docker-has"&gt;images only Docker has&lt;/a&gt;), devvm keys &lt;code&gt;base&lt;/code&gt; by Docker&amp;rsquo;s image ID instead of a digest. devvm exports the image with &lt;code&gt;docker save&lt;/code&gt; into the build VM&amp;rsquo;s folder, where crane reads it, and it checks that the export is the image it looked up. The image is saved by name, so if the tag has moved since, for example after a rebuild, devvm stops and asks you to run it again. devvm only asks Docker about images, with &lt;code&gt;docker image inspect&lt;/code&gt;, &lt;code&gt;docker info&lt;/code&gt; and &lt;code&gt;docker save&lt;/code&gt;.&lt;/p&gt;
&lt;h2 data-hextra-search-id="versions"&gt;Versions&lt;span class="hx:absolute hx:-mt-20" id="versions"&gt;&lt;/span&gt;
&lt;a href="#versions" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm doesn&amp;rsquo;t pin the shared tools&amp;rsquo; versions (&lt;a href="https://next.devvm.dev/docs/using/images/#shared-tools"&gt;shared tools&lt;/a&gt;). Instead, the shared tools&amp;rsquo; &lt;code&gt;mise.toml&lt;/code&gt;, which devvm ships, says which releases to follow, which is the latest of each tool, and Node 24. The first time a tool is needed, devvm resolves it to upstream&amp;rsquo;s newest release and writes that into the tools lock, &lt;code&gt;~/.local/share/devvm/mise.lock&lt;/code&gt;, with each download&amp;rsquo;s checksum for every platform that VMs run (Linux, with glibc and with musl). Builds install exactly the lock&amp;rsquo;s versions and check them against those checksums. Resolving needs this machine to be online once, and until it has been, devvm says so (&lt;code&gt;tools_need_resolve&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;mise&amp;rsquo;s registry decides where a tool comes from, and a mise release can change its choice, so that &lt;code&gt;mise.toml&lt;/code&gt; names the backend of every tool that isn&amp;rsquo;t one of mise&amp;rsquo;s own &lt;code&gt;core:&lt;/code&gt; tools in its &lt;code&gt;[tool_alias]&lt;/code&gt; table. Claude Code, Codex, pnpm and uv come from their GitHub releases through &lt;a href="https://aquaproj.github.io/" target="_blank" rel="noopener"&gt;aqua&lt;/a&gt;, and opencode comes from its GitHub releases directly (&lt;code&gt;github:anomalyco/opencode&lt;/code&gt;), because only that gives musl VMs opencode&amp;rsquo;s own musl build. pi comes from its GitHub releases directly too (&lt;code&gt;github:earendil-works/pi&lt;/code&gt;), one Bun-built program for each platform, which the build checks against the SHA-256 the lock records for it, as it checks every tool&amp;rsquo;s. Its releases have no musl build, so mise locks the glibc download for musl as well, and devvm refuses pi for a musl VM before any build (&lt;code&gt;tool_glibc_only&lt;/code&gt;), because the shared tools&amp;rsquo; registry marks it as glibc only. Without the alias, mise&amp;rsquo;s registry would take opencode 2 from npm, which has no download for each platform. The step back locks the older versions from the backend that the newest came from, and every project VM&amp;rsquo;s mise config gets the same &lt;code&gt;[tool_alias]&lt;/code&gt; table, so the VM&amp;rsquo;s mise finds each tool where its image came from.&lt;/p&gt;
&lt;p&gt;The resolving runs on this machine with a mise of devvm&amp;rsquo;s own. That mise is a pinned release, which devvm downloads once into &lt;code&gt;~/.local/share/devvm/cache/mise/&amp;lt;version&amp;gt;&lt;/code&gt; as its &lt;code&gt;.tar.gz&lt;/code&gt;, a third of the binary&amp;rsquo;s size, and checks against its SHA-256 before it takes the binary out and runs it (&lt;code&gt;mise_checksum&lt;/code&gt;). A download that gets no answer, loses it partway or gets a 408, 429 or server error is tried again up to three times, after one second and then twice as long each time, and any other answer fails it at once (&lt;code&gt;mise_download_failed&lt;/code&gt;). One devvm downloads it at a time, holding &lt;code&gt;~/.local/share/devvm/cache/mise/download.lock&lt;/code&gt;, and another waits for it under a status line (&lt;code&gt;mise_waiting&lt;/code&gt;) and then takes what it kept. The download goes into a folder of its own, which the next download takes away when a killed run left it, and devvm hashes the archive again through the file it then unpacks, so the binary comes from the bytes it checked. devvm never uses the mise you have installed, and nothing it does reaches your own mise config. Each run of that mise gets temporary folders for its data, cache, state and config, which devvm deletes afterwards, so &lt;code&gt;cache/mise/&amp;lt;version&amp;gt;&lt;/code&gt; holds only the binary. &lt;code&gt;devvm gc&lt;/code&gt; deletes the folders of other versions, unless one changed in the last hour.&lt;/p&gt;
&lt;p&gt;A new VM&amp;rsquo;s tools resolve while its image builds, as neither needs the other. The resolve starts once an image starts to build, after the build&amp;rsquo;s questions, and when every image is built already, devvm resolves them before the tool images build, with its status lines as usual. The resolve says nothing while the build runs, because the build has the terminal. devvm holds back what the resolve says until the build ends, shows no status line for it, refuses any question it would ask, and starts its commands&amp;rsquo; lines in the run log with &lt;code&gt;[resolve]&lt;/code&gt;. When the build ends with the resolve still running, devvm shows what the resolve does from then on, and waits for it under a status line of its own (&lt;code&gt;resolving_tools&lt;/code&gt;). When the resolve fails, devvm says so once, after the build, and the launch fails, and when the build fails, devvm stops the resolve.&lt;/p&gt;
&lt;p&gt;Sometimes a tool&amp;rsquo;s newest version isn&amp;rsquo;t published for every platform yet, for example when a release is still uploading, when a tag has no release, or for a few days after a Node release until its musl builds appear. A version counts as published only where its lock entry has a download with a checksum, since mise checks the download against it. mise downloads some files as it locks them, and when one of them isn&amp;rsquo;t there (a 404), mise fails the whole lock and writes nothing. devvm then locks each tool on its own, and it locks a tool that still fails one platform at a time, so that tool has no download for the platform that&amp;rsquo;s missing it. A tool whose newest version has no download on any platform gets no entry, and resolving fails (&lt;code&gt;tools_resolve_failed&lt;/code&gt;). For a tool without every download, devvm takes the newest of the next five older versions that is published everywhere, and says so (&lt;code&gt;tool_stepped_back&lt;/code&gt;), locking those versions one at a time when one of them is missing a download too. When none of them is published everywhere, devvm says that too (&lt;code&gt;tool_no_download&lt;/code&gt;). The next check tries the newest version again.&lt;/p&gt;
&lt;p&gt;A new VM gets the lock&amp;rsquo;s versions, and devvm checks the lock again first when the last check was more than a day ago. When a check fails, devvm uses the versions it found last (&lt;code&gt;tools_check_failed&lt;/code&gt;). When the shared tools&amp;rsquo; &lt;code&gt;mise.toml&lt;/code&gt; changes, as it can in a devvm upgrade, devvm resolves the tools again. A VM lists its tool images in its state, so a newer version never changes a VM that has an older one. Older versions that no VM has are unused, and &lt;code&gt;devvm gc&lt;/code&gt; deletes them.&lt;/p&gt;
&lt;h2 data-hextra-search-id="building-tools"&gt;Building tools&lt;span class="hx:absolute hx:-mt-20" id="building-tools"&gt;&lt;/span&gt;
&lt;a href="#building-tools" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm builds the tool images that a VM&amp;rsquo;s shared tools need when it makes the VM, after its image, and when &lt;code&gt;devvm tools add&lt;/code&gt;, &lt;code&gt;devvm tools update&lt;/code&gt; or &lt;code&gt;devvm update&lt;/code&gt; gives a VM new ones, unless the share already has them. &lt;code&gt;devvm build&lt;/code&gt; builds images alone, never tool images. Each tool image builds in a throwaway VM of its own, which devvm makes from a base image and confines like an image build. Up to four build side by side, as many as this machine&amp;rsquo;s memory and CPUs give a build VM of 2 GiB and 2 CPUs each after keeping 6 GiB and 2 CPUs for itself and the memory devvm&amp;rsquo;s running VMs have, and as many as the backend&amp;rsquo;s disks have room for, each build VM counted as a whole copy of base (&lt;a href="#free-space"&gt;free space&lt;/a&gt;). When the backend can&amp;rsquo;t list its VMs, they build one at a time. Each build VM running at once has a name of its own on Lima, &lt;code&gt;devvm-tools-build&lt;/code&gt; and then &lt;code&gt;devvm-tools-build-2&lt;/code&gt; to &lt;code&gt;devvm-tools-build-4&lt;/code&gt;, and the first one&amp;rsquo;s build deletes what a killed run left in the others that this run doesn&amp;rsquo;t use. A build that runs alone gets base&amp;rsquo;s size.&lt;/p&gt;
&lt;p&gt;Side by side, one status line covers the builds (&lt;code&gt;building_tools_together&lt;/code&gt;), and each line of a build&amp;rsquo;s commands in the run log starts with its tool&amp;rsquo;s name, such as &lt;code&gt;[node]&lt;/code&gt;. The first failure stops the others, which are cancelled, and is what devvm reports, with the end of that tool&amp;rsquo;s own lines in the run log rather than the others&amp;rsquo; that came after. Every write of a build&amp;rsquo;s commands to the run log starts with its tool&amp;rsquo;s name, a line that a progress bar&amp;rsquo;s &lt;code&gt;\r&lt;/code&gt; ends included, so no build can pass a line off as another&amp;rsquo;s. A failed build&amp;rsquo;s VM is deleted once devvm has shown that end, when devvm takes the share&amp;rsquo;s lock again for it. While another devvm holds that lock, whether for a build, &lt;code&gt;devvm gc&lt;/code&gt; or the daily refresh of the tools lock, the VM stays, and the next tools build deletes what it finds in the slots first, as &lt;code&gt;devvm gc&lt;/code&gt; does once it holds the share&amp;rsquo;s lock, without asking but naming each one (&lt;code&gt;tools_build_vms_deleted&lt;/code&gt;), because a build VM holds nothing of yours. That lock is the data folder&amp;rsquo;s, so two devvms with data folders of their own and one Lima home (&lt;code&gt;DEVVM_LIMA_HOME&lt;/code&gt;) don&amp;rsquo;t keep out each other&amp;rsquo;s builds: a tools build or &lt;code&gt;devvm gc&lt;/code&gt; in one can delete a build VM that the other is still using, and that build fails until it&amp;rsquo;s run again. Don&amp;rsquo;t build tools or run &lt;code&gt;devvm gc&lt;/code&gt; in both at once. Which base it makes the VM from depends on the C library the images are for, because any VM whose tools need an image&amp;rsquo;s key mounts it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;glibc:&lt;/strong&gt; devvm&amp;rsquo;s own base from Ubuntu&amp;rsquo;s cloud image, on the VM&amp;rsquo;s backend, whatever base the VM has. A VM on a &lt;code&gt;--from&lt;/code&gt; Debian or Ubuntu image gets images built there too, so the container image&amp;rsquo;s code never runs in the build of images that other VMs mount. When that base isn&amp;rsquo;t built yet, devvm says so (&lt;code&gt;tools_need_own_base&lt;/code&gt;) and builds it first, pinning the cloud image on its first build as usual (&lt;a href="#ubuntus-cloud-image"&gt;Ubuntu&amp;rsquo;s cloud image&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;musl:&lt;/strong&gt; the VM&amp;rsquo;s own &lt;code&gt;--from&lt;/code&gt; base, as it is now, because musl builds need Alpine. Its key hashes that base&amp;rsquo;s digest, so the images are only ever another VM&amp;rsquo;s on the same container image. &lt;code&gt;devvm tools add&lt;/code&gt;, &lt;code&gt;devvm tools update&lt;/code&gt; and &lt;code&gt;devvm update&lt;/code&gt; build that base first, looking up its digest, so the keys they work out are those of the base that the images build in.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Before a build, devvm reads the record of the base it&amp;rsquo;s about to clone and refuses to build in it unless it&amp;rsquo;s the base the images are for (&lt;code&gt;tools_wrong_base&lt;/code&gt;): &lt;code&gt;base&lt;/code&gt; from Ubuntu&amp;rsquo;s cloud image for glibc, and for musl a &lt;code&gt;--from&lt;/code&gt; base with the digest that the images&amp;rsquo; keys hash. A tool&amp;rsquo;s installer can run anything in its VM, as root too, so a VM and a folder for each tool are what keep one tool from writing into another tool&amp;rsquo;s image, whose key doesn&amp;rsquo;t hash it. A build VM gets its one tool and version, and it never sees the share. It writes into a folder of its own, &lt;code&gt;~/.local/share/devvm/tools-build.&amp;lt;random&amp;gt;&lt;/code&gt;, which devvm deletes once that tool is done. Lima mounts that folder at boot and goes on when the mount fails, so the build script waits up to 60 seconds for the tools lock that devvm put in the folder, mounting the folder again while it isn&amp;rsquo;t mounted. If the lock never appears, the build fails, naming the folder and the mount&amp;rsquo;s last error. devvm then checks that each image is a plain file and not a link (&lt;code&gt;tool_bad_output&lt;/code&gt;), moves it into the share and writes its record beside it, never through a name the VM could have planted.&lt;/p&gt;
&lt;p&gt;A glibc build also measures the newest glibc version that each tool needs, because each upstream download is built against a glibc of its own and doesn&amp;rsquo;t run on an older one. After installing the tool, the build script reads the version needs of every ELF program and library in it with &lt;code&gt;readelf&lt;/code&gt;, which base&amp;rsquo;s &lt;code&gt;build-essential&lt;/code&gt; installs, and writes the newest &lt;code&gt;GLIBC_&lt;/code&gt; version they name into &lt;code&gt;&amp;lt;image&amp;gt;.glibc&lt;/code&gt;, or nothing when none needs one. It leaves out folders named &lt;code&gt;testdata&lt;/code&gt;, because Go&amp;rsquo;s has ELF files from other systems that nothing runs. devvm takes that file only as a plain file holding one version (&lt;code&gt;tool_bad_output&lt;/code&gt;) and keeps the version in the image&amp;rsquo;s record (&lt;code&gt;glibc&lt;/code&gt;). Before it gives a VM its tools, devvm compares each image&amp;rsquo;s version with the glibc of the VM&amp;rsquo;s &lt;code&gt;--from&lt;/code&gt; base, and an older base refuses the tool, naming it and both versions (&lt;code&gt;tool_needs_glibc&lt;/code&gt;). It checks the same way when &lt;code&gt;devvm tools add&lt;/code&gt;, &lt;code&gt;devvm tools update&lt;/code&gt; or &lt;code&gt;devvm update&lt;/code&gt; gives an existing VM tools, against the glibc its state recorded when it was made. A base from Ubuntu&amp;rsquo;s cloud image has no glibc version in its record, so its tools aren&amp;rsquo;t checked, and a musl base gets musl builds, which need no glibc. Only one build at a time writes to the share, because each holds the share&amp;rsquo;s lock, &lt;code&gt;~/.local/share/devvm/tools.lock&lt;/code&gt;, outside the share that VMs mount. Another devvm waits for it under a status line (&lt;code&gt;share_waiting&lt;/code&gt;) until the build ends or you press Ctrl+C. The lock is an OS lock on an open file, so the system releases it when its devvm ends, however it ends, and a devvm that crashed or that you killed never leaves another one waiting.&lt;/p&gt;
&lt;p&gt;Each tool image is named &lt;code&gt;&amp;lt;tool&amp;gt;-&amp;lt;version&amp;gt;-&amp;lt;key&amp;gt;.erofs&lt;/code&gt;. Its key hashes the tool&amp;rsquo;s entry in the tools lock (its version, its downloads and their checksums), the shared tools&amp;rsquo; &lt;code&gt;build.sh&lt;/code&gt; with &lt;a href="#the-scripts-prelude"&gt;the prelude&lt;/a&gt; before it, the &lt;code&gt;[settings]&lt;/code&gt; table of their &lt;code&gt;mise.toml&lt;/code&gt;, the version of mise that &lt;code&gt;base.sh&lt;/code&gt; pins, the C library the image is built for, the base it builds in (devvm&amp;rsquo;s own for glibc, and for musl the digest of the &lt;code&gt;--from&lt;/code&gt; base), and the backend&amp;rsquo;s format. The build VM is made from base, so base&amp;rsquo;s mise is the one that installs the tool, and a new mise builds every tool image it installs again. A tool that &lt;code&gt;build.sh&lt;/code&gt; installs itself, without mise, doesn&amp;rsquo;t have mise&amp;rsquo;s version in its key, because mise doesn&amp;rsquo;t install it: rustup installs rust, and dotnet comes from Microsoft&amp;rsquo;s own archive (&lt;a href="#dotnets-download"&gt;dotnet&amp;rsquo;s download&lt;/a&gt;). The tests check that &lt;code&gt;base.sh&lt;/code&gt; pins the same mise as the one devvm runs on the host, with the same Linux checksums. devvm reads the lock as TOML and hashes what the tool&amp;rsquo;s entry says, the entry of the version the image installs, so a mise that writes the same lock in another order, with other spacing or quoting, leaves every key as it is. The settings are in the key because they change what mise installs, such as &lt;code&gt;python.compile&lt;/code&gt;, and the key reads what they say in the same way, so a comment or another way of writing the same settings leaves it as it is. Lima&amp;rsquo;s format is &lt;code&gt;build.sh&lt;/code&gt;&amp;rsquo;s own, compressed EROFS, which adds nothing to the key. A new version, a new download, an edited build script or a changed setting builds the image again, and a base with a different C library, such as Alpine&amp;rsquo;s musl, gets an image of its own, and so would a VM on another backend. Every glibc image&amp;rsquo;s key names devvm&amp;rsquo;s own base, because glibc images build only there, so a VM on Ubuntu&amp;rsquo;s base and one on a &lt;code&gt;--from&lt;/code&gt; Debian image share them. A musl image&amp;rsquo;s key has its base&amp;rsquo;s digest, so when the container image&amp;rsquo;s tag moves to a new image, its VMs&amp;rsquo; next tools build again in the new base. When the lock has no download of a tool for the VM&amp;rsquo;s platform, devvm doesn&amp;rsquo;t build it and says to try again later (&lt;code&gt;tool_unbuilt&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;An image is base and its layers alone, and a VM&amp;rsquo;s shared tools are a list in its state (the &lt;code&gt;tools&lt;/code&gt; section&amp;rsquo;s &lt;code&gt;names&lt;/code&gt;) beside its image. devvm&amp;rsquo;s check of an image name refuses a shared tool&amp;rsquo;s name in it (&lt;code&gt;tool_not_layer&lt;/code&gt;), so &lt;code&gt;devvm build&lt;/code&gt;, &lt;code&gt;devvm rebuild&lt;/code&gt; and &lt;code&gt;devvm images rm&lt;/code&gt; refuse one, because shared tools aren&amp;rsquo;t images and their versions come from the lock.&lt;/p&gt;
&lt;h3 data-hextra-search-id="dotnets-download"&gt;dotnet&amp;rsquo;s download&lt;span class="hx:absolute hx:-mt-20" id="dotnets-download"&gt;&lt;/span&gt;
&lt;a href="#dotnets-download" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;mise resolves dotnet&amp;rsquo;s version like any tool&amp;rsquo;s, but it locks the version alone, without a download, because its installer runs Microsoft&amp;rsquo;s install script, which nothing pins. So devvm adds each platform&amp;rsquo;s SDK archive to the lock itself (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt; names the code). For each dotnet entry that lacks a platform&amp;rsquo;s download, it fetches the channel&amp;rsquo;s list of releases, &lt;code&gt;https://builds.dotnet.microsoft.com/dotnet/release-metadata/&amp;lt;channel&amp;gt;/releases.json&lt;/code&gt;, over HTTPS and capped at 32 MB, and it records that platform&amp;rsquo;s &lt;code&gt;dotnet-sdk-&amp;lt;rid&amp;gt;.tar.gz&lt;/code&gt; with its SHA-512. It keeps a file only when its URL is under &lt;code&gt;https://builds.dotnet.microsoft.com/dotnet/&lt;/code&gt; and its hash is 128 hex digits, and a version that Microsoft doesn&amp;rsquo;t list gets no download, so devvm doesn&amp;rsquo;t build it. The image&amp;rsquo;s key hashes that lock entry, its URLs and checksums included, as it does every tool&amp;rsquo;s.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;build.sh&lt;/code&gt; gets the URL and the SHA-512 from devvm and downloads the archive with &lt;code&gt;devvm-fetch&lt;/code&gt;, which checks a 128-character checksum as a SHA-512 and any other as a SHA-256, and which deletes the file and fails when the sum differs. The script unpacks the archive and checks that &lt;code&gt;dotnet --list-sdks&lt;/code&gt; names the locked version. The SDK&amp;rsquo;s folder is read-only in VMs, so the script puts a &lt;code&gt;userlocal&lt;/code&gt; marker in its &lt;code&gt;metadata/workloads/&amp;lt;band&amp;gt;&lt;/code&gt; folder, for its feature band (10.0.400 for 10.0.403), which makes &lt;code&gt;dotnet workload install&lt;/code&gt; install into &lt;code&gt;~/.dotnet&lt;/code&gt; in the VM. In the VM, &lt;code&gt;sync.sh&lt;/code&gt; writes the shared SDK&amp;rsquo;s folder into &lt;code&gt;/etc/dotnet/install_location&lt;/code&gt;, where .NET&amp;rsquo;s programs look for an installed runtime, so global tools find it in every shell and not only those that mise activates, and it sets mise&amp;rsquo;s &lt;code&gt;dotnet.isolated&lt;/code&gt;, which gives each SDK a folder of its own, so the shared one runs from its image.&lt;/p&gt;
&lt;p&gt;The trust root is Microsoft&amp;rsquo;s &lt;code&gt;releases.json&lt;/code&gt;, read over HTTPS, which is the same model as the upstream checksums that mise locks for the other tools. An SDK that a project&amp;rsquo;s &lt;code&gt;global.json&lt;/code&gt; asks for is different: mise installs it in the VM with Microsoft&amp;rsquo;s install script, which checks only HTTPS and the download&amp;rsquo;s size, and it stays in that VM&amp;rsquo;s home, so no image or other VM gets it.&lt;/p&gt;
&lt;h2 data-hextra-search-id="a-companys-ca-in-builds"&gt;A company&amp;rsquo;s CA in builds&lt;span class="hx:absolute hx:-mt-20" id="a-companys-ca-in-builds"&gt;&lt;/span&gt;
&lt;a href="#a-companys-ca-in-builds" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Build VMs trust the CA certificates in &lt;code&gt;~/.config/devvm/ca&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/using/settings/#a-companys-ca"&gt;a company&amp;rsquo;s CA&lt;/a&gt;) while they build, and images never keep them. &lt;a href="https://next.devvm.dev/docs/internals/network/#a-companys-ca"&gt;Network tiers&lt;/a&gt; describes how devvm reads them and how the guest&amp;rsquo;s &lt;code&gt;ca.sh&lt;/code&gt; installs them.&lt;/p&gt;
&lt;p&gt;A build carries two scripts made from &lt;code&gt;ca.sh&lt;/code&gt;, which run as root: one to add the CAs, which writes the certificates from heredocs to a temporary folder and installs them, and one to remove them, which is &lt;code&gt;ca.sh&lt;/code&gt; without a folder. Each script of the build, &lt;code&gt;build.sh&lt;/code&gt; of a tools build too, also gets an environment at its start that exports the CAs&amp;rsquo; variables, so its tools find the CAs, and nothing of that is written in the VM. The backend puts it there, as it does the build&amp;rsquo;s proxy variables (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt; names the types). Each backend runs the add script before anything in the build VM downloads, and the remove script once the scripts are done, before the VM stops:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Lima:&lt;/strong&gt; the add script runs right after the start, through &lt;code&gt;sudo sh&lt;/code&gt;, then base&amp;rsquo;s or the layer&amp;rsquo;s scripts, then the remove script, before the final &lt;code&gt;sync&lt;/code&gt; and the stop.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lima with &lt;code&gt;--from&lt;/code&gt;:&lt;/strong&gt; the conversion&amp;rsquo;s build VM, which is deleted afterwards, also runs the add script. &lt;code&gt;oci/build.sh&lt;/code&gt; gets &lt;code&gt;ca.sh&lt;/code&gt;, from devvm&amp;rsquo;s &lt;code&gt;guest/&lt;/code&gt; folder mounted read-only, and runs it in the image&amp;rsquo;s chroot with the CAs before &lt;code&gt;bootify.sh&lt;/code&gt; and without them after it, so that Alpine&amp;rsquo;s &lt;code&gt;apk&lt;/code&gt; reaches its HTTPS mirrors. The converted base then builds as Lima&amp;rsquo;s does.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shared tools:&lt;/strong&gt; the add script runs before &lt;code&gt;build.sh&lt;/code&gt;. devvm deletes the build VM and keeps only its output folder, so it needs no remove script.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;An image is therefore the same with or without CAs, which is why its key holds none of them, and a tool image&amp;rsquo;s key stays its lock entry, &lt;code&gt;build.sh&lt;/code&gt;, mise&amp;rsquo;s settings, the C library and the base it builds in. When there are CAs, the build&amp;rsquo;s numbered steps include the two scripts. A layer script that copies the system&amp;rsquo;s bundle elsewhere keeps that copy.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;End-to-end checks&lt;/strong&gt; (the &lt;code&gt;images&lt;/code&gt; section, &lt;a href="https://next.devvm.dev/docs/contributing/tests/#the-tests-behind-how-it-works"&gt;the tests behind it&lt;/a&gt;): a layer built with a test CA in the folder trusts it while its script runs, keeps its key once the folder is emptied, and a copy of its image booted without devvm has none of devvm&amp;rsquo;s CA files.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-share"&gt;The share&lt;span class="hx:absolute hx:-mt-20" id="the-share"&gt;&lt;/span&gt;
&lt;a href="#the-share" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm builds each tool version once for each backend and C library into a read-only image (EROFS) in &lt;code&gt;~/.local/share/devvm/tools&lt;/code&gt;, with its record next to it in &lt;code&gt;&amp;lt;image&amp;gt;.json&lt;/code&gt;. The record is JSON that only devvm writes, with the image&amp;rsquo;s SHA-256 (&lt;code&gt;sha256&lt;/code&gt;), its C library (&lt;code&gt;libc&lt;/code&gt;), for glibc the newest glibc version it needs (&lt;code&gt;glibc&lt;/code&gt;), for musl the digest of the base it was built in (&lt;code&gt;base&lt;/code&gt;), its backend&amp;rsquo;s format (&lt;code&gt;format&lt;/code&gt;), the backend that built it (&lt;code&gt;backend&lt;/code&gt;), when it was moved in (&lt;code&gt;built&lt;/code&gt;), the version of the devvm that built it (&lt;code&gt;made_by&lt;/code&gt;) and, once retention finds that no VM has it, since when (&lt;code&gt;idle_since&lt;/code&gt;). The share holds only the images and their records, and Lima&amp;rsquo;s images are compressed. That folder is mounted read-only in every VM at &lt;code&gt;/mnt/devvm-tools&lt;/code&gt;, and each VM mounts the images its tools need at &lt;code&gt;/opt/devvm/tools/&amp;lt;tool&amp;gt;/&amp;lt;version&amp;gt;&lt;/code&gt;, at boot and on every launch. A VM can&amp;rsquo;t change the shared images, even as root.&lt;/p&gt;
&lt;p&gt;A tool that doesn&amp;rsquo;t mount fails the launch (&lt;code&gt;tools_unmounted&lt;/code&gt;). mise&amp;rsquo;s &lt;code&gt;auto_install&lt;/code&gt; stays on for a project&amp;rsquo;s own version files, so without this check a tool that isn&amp;rsquo;t mounted would download into the VM on first use without a word. The VM&amp;rsquo;s mount script, &lt;code&gt;devvm-tools&lt;/code&gt;, tries every image in the VM&amp;rsquo;s list. It leaves out the empty mount point of one that fails, lists each failed image in &lt;code&gt;/run/devvm/tools-unmounted&lt;/code&gt; and exits non-zero, which fails the launch&amp;rsquo;s setup. The setup removes that list before anything else it runs, so a list left from the VM&amp;rsquo;s boot isn&amp;rsquo;t read after a failure that has nothing to do with the tools. devvm then reads the first 16 KiB of that list from the VM, and it gives up after 10 seconds, because root in the VM could make the read hang. It counts only a whole line that is one of the VM&amp;rsquo;s own tool images from its state, so the error shows devvm&amp;rsquo;s own names, never the VM&amp;rsquo;s text. devvm reads the list with a command of its own because the setup&amp;rsquo;s output goes straight to the run log, and a pipe for reading it would keep devvm waiting on any process that the setup left running.&lt;/p&gt;
&lt;p&gt;At boot the same failure fails only the &lt;code&gt;devvm-tools&lt;/code&gt; service, and the boot goes on. Either way, the launch&amp;rsquo;s setup runs the mount script again and stops on the failure.&lt;/p&gt;
&lt;h2 data-hextra-search-id="listing-and-cleaning-up"&gt;Listing and cleaning up&lt;span class="hx:absolute hx:-mt-20" id="listing-and-cleaning-up"&gt;&lt;/span&gt;
&lt;a href="#listing-and-cleaning-up" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href="https://next.devvm.dev/docs/using/images/#listing-images"&gt;Listing images&lt;/a&gt; describes the columns of &lt;code&gt;devvm images&lt;/code&gt;. An &lt;code&gt;unfinished&lt;/code&gt; image is a build that didn&amp;rsquo;t finish, so it has no record, and a &lt;code&gt;building&lt;/code&gt; image has no record yet because another devvm holds its &lt;a href="#building"&gt;lock&lt;/a&gt;. A tool image&amp;rsquo;s &lt;code&gt;STATE&lt;/code&gt; compares it with the tools lock and with the VMs&amp;rsquo; state:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;current&lt;/code&gt; is the tools lock&amp;rsquo;s version, for the C library of the base that new VMs get, which &lt;code&gt;--from&lt;/code&gt; changes, and for musl, for that base&amp;rsquo;s digest.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;in use&lt;/code&gt; is another version, which a VM has in its state.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;unused&lt;/code&gt; is neither.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;not built&lt;/code&gt; is the lock&amp;rsquo;s version of a tool that the share has other versions of.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;not installed&lt;/code&gt; means the share has nothing of that name&amp;rsquo;s.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Listing never resolves the tools lock. Before there is a lock, no tool image is current, and the tool images that no VM has show no state.&lt;/p&gt;
&lt;p&gt;A tool image&amp;rsquo;s name doesn&amp;rsquo;t say which backend and C library it&amp;rsquo;s built for, so &lt;code&gt;LIBC&lt;/code&gt; comes from its record, which also names the backend that built it, as &lt;code&gt;devvm images --json&lt;/code&gt; shows in &lt;code&gt;backend&lt;/code&gt;. An image without a record shows &lt;code&gt;-&lt;/code&gt;, and has no &lt;code&gt;backend&lt;/code&gt; or &lt;code&gt;libc&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm images rm&lt;/code&gt; deletes images with their records. &lt;code&gt;devvm gc&lt;/code&gt; deletes stale and unfinished images with their records, and unused tool images with theirs. With &lt;code&gt;--tool-images&lt;/code&gt;, it also deletes the current tool images that no VM&amp;rsquo;s state lists and that have a record, however recently they were built.&lt;/p&gt;
&lt;p&gt;A VM&amp;rsquo;s launch builds its tools before it records them in its state, and a new VM can also pick a tool that was built long before and that no VM has, so deleting current tools needs a reliable sign that no VM is being made. That sign is the making lock, &lt;code&gt;~/.local/share/devvm/making.lock&lt;/code&gt;. Each devvm that makes a VM holds it shared from before it picks the VM&amp;rsquo;s tools, and &lt;code&gt;devvm tools add&lt;/code&gt;, &lt;code&gt;devvm tools update&lt;/code&gt; and &lt;code&gt;devvm update&lt;/code&gt; hold it until the VM&amp;rsquo;s state lists the new tools. A new VM&amp;rsquo;s devvm keeps it until just before the VM&amp;rsquo;s first shell. Any number of devvms hold it at once, on every backend, because it&amp;rsquo;s taken before the backend does anything. &lt;code&gt;devvm gc --tool-images&lt;/code&gt; and retention&amp;rsquo;s &lt;code&gt;tools.unused-age&lt;/code&gt; take it exclusively without waiting (&lt;code&gt;flock&lt;/code&gt; with &lt;code&gt;LOCK_NB&lt;/code&gt;), after the share&amp;rsquo;s lock, and hold it until they&amp;rsquo;re done, so no VM picks its tools between their list and their deletions. A devvm that starts to make a VM meanwhile waits under a status line (&lt;code&gt;making_waiting&lt;/code&gt;). In a terminal, gc holds it while it asks. Every tool image build runs for one of those devvms, under the making lock, and holds the share&amp;rsquo;s lock while it builds and moves the images in, so gc, which takes the share&amp;rsquo;s lock first, waits for a build in progress and then finds the making lock held until the VM&amp;rsquo;s state lists what it built.&lt;/p&gt;
&lt;p&gt;When a VM is being made, &lt;code&gt;devvm gc --tool-images&lt;/code&gt; keeps every current tool image that no VM&amp;rsquo;s state lists and names them (&lt;code&gt;gc_tools_making&lt;/code&gt;), after the same filters, and deletes the rest of its list. Retention deletes no tool images in that run and leaves their records&amp;rsquo; &lt;code&gt;idle_since&lt;/code&gt; as it is, then applies its other settings. The lock is an OS lock on an open file, which the system releases when the last descriptor closes, so a devvm that crashes or is killed lets go of it. Its descriptor is close-on-exec, so neither the processes devvm starts (a Lima host agent, a proxy) nor the shell that takes devvm&amp;rsquo;s place inherit it. gc and retention never wait for it, so they can&amp;rsquo;t block, and the order the two locks are taken in can&amp;rsquo;t deadlock: a devvm making a VM takes the making lock and then the share&amp;rsquo;s, and gc and retention take the share&amp;rsquo;s and only try the making lock. Retention at a command&amp;rsquo;s start doesn&amp;rsquo;t wait for the share&amp;rsquo;s lock either: while another devvm holds it, as a tool build does, that run deletes no tool images, and they wait for the next day&amp;rsquo;s run.&lt;/p&gt;
&lt;p&gt;When a tool image that a new VM&amp;rsquo;s state lists is gone by the VM&amp;rsquo;s setup, &lt;code&gt;devvm-tools&lt;/code&gt; can&amp;rsquo;t mount it, the setup fails with &lt;code&gt;tools_unmounted&lt;/code&gt;, and the VM and its state stay, because only an interrupt undoes a new VM. Every launch of the VM fails the same way until &lt;code&gt;devvm tools update&lt;/code&gt; builds the missing images, as a launch builds whatever the share lacks.&lt;/p&gt;
&lt;p&gt;gc holds the share&amp;rsquo;s lock throughout, so no tool build or &lt;code&gt;devvm tools update&lt;/code&gt; changes the share meanwhile. A tool image is unused only when compared with the tools lock, so before there is a lock, gc deletes none. Because &lt;code&gt;current&lt;/code&gt; is for the C library of the base that new VMs get, the musl tool images of an Alpine VM are unused once it&amp;rsquo;s gone, unless you give gc that &lt;code&gt;--from&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;gc also trims the &lt;a href="https://next.devvm.dev/docs/internals/network/#the-shared-nix-cache"&gt;shared Nix cache&lt;/a&gt; to its cap, deleting its least recently used files under the lock that the VMs&amp;rsquo; proxies take, and with &lt;code&gt;--nix-cache&lt;/code&gt;, it deletes all of the cache&amp;rsquo;s files. &lt;code&gt;devvm images&lt;/code&gt; ends with what the cache takes of its cap when it holds anything.&lt;/p&gt;
&lt;h2 data-hextra-search-id="free-space"&gt;Free space&lt;span class="hx:absolute hx:-mt-20" id="free-space"&gt;&lt;/span&gt;
&lt;a href="#free-space" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Before each build and each new VM, devvm checks the free space on the disk that will hold it, and &lt;a href="https://next.devvm.dev/docs/using/ports-size/#free-space"&gt;free space&lt;/a&gt; lists what each step needs. devvm checks the disk that holds the images and VMs, which is the disk of devvm&amp;rsquo;s Lima home. Shared tool images come out into devvm&amp;rsquo;s data folder, so a tools build also checks that folder&amp;rsquo;s disk, which needs 0.5 GiB and 0.25 GiB for each tool, rounded up: 1 GiB for one tool and 3 GiB for all ten. When devvm&amp;rsquo;s data folder is on a small temporary disk, such as a tmpfs &lt;code&gt;/tmp&lt;/code&gt; on Linux, devvm checks that disk.&lt;/p&gt;
&lt;p&gt;The numbers leave a margin over what each step took when devvm&amp;rsquo;s tests measured the free space before, during and after it. Most of a step&amp;rsquo;s space is only needed while it runs. On Lima on macOS, base took about 1 GiB with Ubuntu&amp;rsquo;s cloud image already downloaded, and downloading the image takes up to another 0.9 GiB, which devvm keeps in its data folder (&lt;a href="#ubuntus-cloud-image"&gt;Ubuntu&amp;rsquo;s cloud image&lt;/a&gt;). A tools build counts its build VMs&amp;rsquo; floor once for each that runs at once, as on a disk with no copy on write, such as ext4, each is a full copy of base. base&amp;rsquo;s features add up to 2.5 GiB. A build of all ten shared tools took 6 GiB at its peak and kept 1.5 GiB of images. On macOS, an image built on another and a new VM take only what they write. On Linux hosts, an image and the VM that builds shared tools start as a full copy of their parent&amp;rsquo;s disk, but a new VM&amp;rsquo;s disk holds only its own changes. A VM then grows as you work in it, and its disk never shrinks.&lt;/p&gt;</description></item><item><title>Port forwarding</title><link>https://next.devvm.dev/docs/internals/ports/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/ports/</guid><description>
&lt;p&gt;This page explains how devvm&amp;rsquo;s forwarder forwards a VM&amp;rsquo;s ports to this machine, which ports it never takes, and how it runs. &lt;a href="https://next.devvm.dev/docs/using/ports-size/#ports"&gt;Ports and size&lt;/a&gt; covers choosing a VM&amp;rsquo;s ports with &lt;code&gt;--ports&lt;/code&gt; and &lt;code&gt;devvm ports&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;devvm forwards a VM&amp;rsquo;s ports with its own forwarder, never with Lima&amp;rsquo;s own forwards. &lt;a href="https://next.devvm.dev/docs/internals/lima/#ports"&gt;Lima&lt;/a&gt; explains why, and what devvm sets on Lima instead.&lt;/p&gt;
&lt;h2 data-hextra-search-id="what-it-forwards"&gt;What it forwards&lt;span class="hx:absolute hx:-mt-20" id="what-it-forwards"&gt;&lt;/span&gt;
&lt;a href="#what-it-forwards" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href="https://next.devvm.dev/docs/using/ports-size/#ports"&gt;Ports&lt;/a&gt; lists which ports the forwarder forwards, for &lt;code&gt;--ports all&lt;/code&gt;, the default, and for a list such as &lt;code&gt;--ports 5173,8000-8010&lt;/code&gt;, and how soon. A listed port also carries a server on the VM&amp;rsquo;s loopback (&lt;code&gt;127.0.0.1&lt;/code&gt; or &lt;code&gt;::1&lt;/code&gt;) to this machine. You can list port 22, which forwards the VM&amp;rsquo;s sshd to port 22 on this machine, while ssh by name keeps using the VM&amp;rsquo;s own ssh port.&lt;/p&gt;
&lt;p&gt;The forwarder never forwards a server on an address in &lt;code&gt;127.77.0.0/16&lt;/code&gt;, on any VM, because that&amp;rsquo;s where a VM listens for its &lt;a href="#links-between-vms"&gt;links to other VMs&lt;/a&gt;, so a link never appears on this machine&amp;rsquo;s &lt;code&gt;localhost&lt;/code&gt;. A server of the VM&amp;rsquo;s own on &lt;code&gt;127.0.0.1&lt;/code&gt; with the same port is forwarded as usual. It also never forwards a server on &lt;code&gt;127.0.77.1&lt;/code&gt;, where the desktop&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/desktop/#the-local-proxy"&gt;local proxy&lt;/a&gt; listens, because the local proxy adds the VM&amp;rsquo;s password to what it sends to the VM&amp;rsquo;s proxy, and on this machine&amp;rsquo;s &lt;code&gt;localhost&lt;/code&gt; other users and programs could use it.&lt;/p&gt;
&lt;h2 data-hextra-search-id="what-it-never-takes"&gt;What it never takes&lt;span class="hx:absolute hx:-mt-20" id="what-it-never-takes"&gt;&lt;/span&gt;
&lt;a href="#what-it-never-takes" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The forwarder never takes a port that a program on this machine has on any address. That program keeps the port and its &lt;code&gt;localhost&lt;/code&gt; connections, and the forward waits until the VM&amp;rsquo;s server stops and starts again.&lt;/p&gt;
&lt;p&gt;The forwarder also never takes a port that devvm records for a VM, even while that port is free. Those are the ssh, proxy and desktop ports that devvm chooses for VMs, running or not, and the VM&amp;rsquo;s own ssh port. devvm chooses and records every VM&amp;rsquo;s ssh port, whatever its tier, so no forwarder takes it in the seconds before Lima binds it (&lt;a href="https://next.devvm.dev/docs/contributing/design/#ports-on-lima"&gt;the threat check&lt;/a&gt;). It chooses that port only from the 17 ports that every browser refuses (&lt;a href="https://next.devvm.dev/docs/internals/lima/#what-devvm-sets-on-a-vm"&gt;the ssh port&lt;/a&gt;), which devvm&amp;rsquo;s proxy and desktop ports never take. A forwarder never takes one of those 17 either, unless its VM lists it, so a VM that forwards every port can&amp;rsquo;t take the ports other VMs&amp;rsquo; ssh needs. When devvm chooses one of those ports, it also avoids every port that any VM lists, running or not, so a stopped VM&amp;rsquo;s listed ports stay free for it.&lt;/p&gt;
&lt;p&gt;When a start, or a change of a running VM&amp;rsquo;s ports, finds that a program on this machine has a listed port, devvm doesn&amp;rsquo;t forward that port and warns you (&lt;code&gt;ports_taken&lt;/code&gt;). The VM starts or runs on all the same, and the next start or change that finds the port free forwards it again. &lt;a href="https://next.devvm.dev/docs/using/ports-size/#ports"&gt;Ports&lt;/a&gt; says what happens to a program that binds a port on all addresses after the forwarder has forwarded it.&lt;/p&gt;
&lt;h3 data-hextra-search-id="ports-other-vms-forward"&gt;Ports other VMs forward&lt;span class="hx:absolute hx:-mt-20" id="ports-other-vms-forward"&gt;&lt;/span&gt;
&lt;a href="#ports-other-vms-forward" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A host port that two VMs could forward belongs to the running VM that forwards it, never to a stopped one, so a stopped VM&amp;rsquo;s listed ports are free to the others until it starts again. Each forwarder writes the ports it forwards to &lt;code&gt;ports.forwarded&lt;/code&gt; in its VM&amp;rsquo;s run folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/&lt;/code&gt;, after each change, with its pid on the first line and the ports it forwards on the second. The next three lines hold the ports it tried and couldn&amp;rsquo;t take, by why: those a program on this machine has, those past its limit of 256 forwards, and those this machine refused for another reason, such as a port below 1024 on Linux. It writes an empty record when it starts. A record counts only while that pid is the VM&amp;rsquo;s running forwarder, as &lt;code&gt;ports.pid&lt;/code&gt; and the process&amp;rsquo;s arguments say, so the record of a VM that stopped or crashed, whose forwarder ended with it, holds nothing. devvm also removes the record under the VM&amp;rsquo;s &lt;code&gt;ports.lock&lt;/code&gt; each time it starts the VM&amp;rsquo;s forwarder, so a pid used again never makes an old record count.&lt;/p&gt;
&lt;p&gt;At each report from its VM, every forwarder reads the other VMs&amp;rsquo; states and records again, and it never takes these ports:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a port that another VM&amp;rsquo;s running forwarder forwards now&lt;/li&gt;
&lt;li&gt;a port that another VM lists while that VM has a claim on it, unless this VM lists it too. A VM has a claim while its forwarder runs, and while devvm holds its &lt;code&gt;ports.lock&lt;/code&gt; to start the forwarder again, so no other VM takes its listed ports between the old forwarder&amp;rsquo;s stop and the new one&amp;rsquo;s start.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A VM that lists a port comes before one that forwards every port. Besides its VM&amp;rsquo;s reports, every forwarder checks the ports it forwards against those rules every 10 seconds on its own clock and closes a forward whose port is now another VM&amp;rsquo;s, so a VM that keeps its session open without reporting can&amp;rsquo;t keep a port. Closing a forward also closes the connections it accepted that are still open, such as a browser&amp;rsquo;s keep-alive connections, so none of them reaches the old VM afterwards. A VM that forwards every port therefore gives up a port within about 10 seconds of a running VM listing it.&lt;/p&gt;
&lt;p&gt;A port the forwarder never takes for those reasons, and that its VM listens on, waits: the forwarder tries it again at each report, which comes at least every 10 seconds, and forwards it once it&amp;rsquo;s free, even when an earlier try found it taken. A port the other VM gives up can therefore take up to about 20 seconds to reach this VM: up to 10 for the other forwarder&amp;rsquo;s check and up to 10 for this one&amp;rsquo;s next report. When a start or a change of ports finds that another VM forwards one of the VM&amp;rsquo;s listed ports now, whether that VM lists it or forwards every port, devvm keeps the port in the VM&amp;rsquo;s list and warns you (&lt;code&gt;ports_held&lt;/code&gt;), and &lt;code&gt;devvm ports&lt;/code&gt; warns again, with the other VM in its JSON&amp;rsquo;s &lt;code&gt;held_by&lt;/code&gt;. A port that another VM forwards isn&amp;rsquo;t a program&amp;rsquo;s, so it never gets &lt;code&gt;ports_taken&lt;/code&gt;. A listed port of a running VM that its forwarder tried and couldn&amp;rsquo;t take is only logged by the forwarder, and &lt;code&gt;devvm ports&lt;/code&gt; warns about it, as &lt;a href="#when-it-cant-forward"&gt;When it can&amp;rsquo;t forward&lt;/a&gt; describes.&lt;/p&gt;
&lt;p&gt;When two VMs that list the same port start at once, neither waits for the other, because neither forwards it yet. The first forwarder to bind the port on this machine&amp;rsquo;s loopback has it, because the system lets one listener have it, and the other forwarder&amp;rsquo;s try fails. That forwarder sees the winner&amp;rsquo;s record at its next report and waits for the port from then on. No lock is needed for this, and no port is shared.&lt;/p&gt;
&lt;h2 data-hextra-search-id="how-it-reaches-the-vm"&gt;How it reaches the VM&lt;span class="hx:absolute hx:-mt-20" id="how-it-reaches-the-vm"&gt;&lt;/span&gt;
&lt;a href="#how-it-reaches-the-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The forwarder reaches the VM over the VM&amp;rsquo;s ssh, with a key and a host key that devvm pins, and it asks for no forwarding into this machine. Only a &lt;a href="#the-link-session"&gt;link session&lt;/a&gt; asks a VM for a remote forward, on a connection of its own. Every connection starts on this machine, and the VM opens none to it. The VM sees each forwarded connection only as one to its own loopback, and on a confined tier the VM still reaches only its proxy.&lt;/p&gt;
&lt;p&gt;A connection to a forwarded port, such as 5173, takes this path:&lt;/p&gt;
&lt;div class="devvm-diagram" style="contain-intrinsic-block-size: auto 455px; --devvm-diagram-width: 320px"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" class="pele pele-flowchart" viewBox="0 0 320 455" width="320" height="455" style="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,&amp;quot;Departure Mono&amp;quot;, monospace);font:14px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,&amp;quot;Departure Mono&amp;quot;, monospace)" fill="var(--_fg)" role="graphics-document document" aria-roledescription="flowchart" aria-labelledby="ddbfff724d47f759c--title" aria-describedby="ddbfff724d47f759c--desc"&gt;&lt;title id="ddbfff724d47f759c--title"&gt;A connection to a forwarded port&lt;/title&gt;&lt;desc id="ddbfff724d47f759c--desc"&gt;Your browser on this machine connects to localhost:5173, where devvm's forwarder, on this machine, takes it over ssh, with a key and a host key devvm pins, to the VM's sshd, which connects to your server on the VM's own loopback, 127.0.0.1:5173.&lt;/desc&gt;&lt;g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round"&gt;&lt;g class="pele-edge" data-id="L_browser_fwd_0"&gt;&lt;path d="M159.64,68L159.64,128"/&gt;&lt;path class="pele-marker" d="M159.64,135L156.28,127L163,127Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_fwd_sshd_0"&gt;&lt;path d="M159.64,195L159.64,269"/&gt;&lt;path class="pele-marker" d="M159.64,276L156.28,268L163,268Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_sshd_server_0"&gt;&lt;path d="M159.64,321L159.64,395"/&gt;&lt;path class="pele-marker" d="M159.64,402L156.28,394L163,394Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edge-labels" font-size="14"&gt;&lt;g class="pele-edge-label" data-id="L_browser_fwd_0"&gt;&lt;rect x="93.27" y="92.5" width="132.73" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="159.64" y="105.7" text-anchor="middle"&gt;localhost:5173&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_fwd_sshd_0"&gt;&lt;rect x="62.09" y="219.5" width="195.09" height="32" rx="3" fill="var(--_bg)"/&gt;&lt;text text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="159.64" y="231.7"&gt;ssh, with a key and&lt;/tspan&gt;&lt;tspan x="159.64" y="247.7"&gt;a host key devvm pins&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_sshd_server_0"&gt;&lt;rect x="84.36" y="345.5" width="150.55" height="32" rx="3" fill="var(--_bg)"/&gt;&lt;text text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="159.64" y="357.7"&gt;127.0.0.1:5173,&lt;/tspan&gt;&lt;tspan x="159.64" y="373.7"&gt;its own loopback&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-nodes"&gt;&lt;g class="pele-node pele-shape-rect" data-id="browser" transform="translate(159.64,38)"&gt;&lt;rect x="-151.64" y="-30" width="303.27" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;your browser, on this machine,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;where every connection starts&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="fwd" transform="translate(159.64,165)"&gt;&lt;rect x="-98.18" y="-30" width="196.36" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;devvm's forwarder,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;on this machine&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="sshd" transform="translate(159.64,298.5)"&gt;&lt;rect x="-75.91" y="-22.5" width="151.82" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;the VM's sshd&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="server" transform="translate(159.64,424.5)"&gt;&lt;rect x="-116" y="-22.5" width="232" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;your server, in the VM&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/div&gt;&lt;p&gt;The forwarder is devvm&amp;rsquo;s own, the same on every backend. The backend only says how the forwarder reaches a running VM&amp;rsquo;s sshd, which is a user, a key and a port on this machine&amp;rsquo;s loopback, and which file the forwarder follows to know the VM still runs, as Lima&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/lima/#ports"&gt;Ports&lt;/a&gt; section describes.&lt;/p&gt;
&lt;p&gt;Each forwarded connection gets an ssh process of its own, which carries it over the forwarder&amp;rsquo;s ssh connection to the VM, and the forwarder carries at most 256 connections at once, refusing the next one. When accepting a connection fails while the forward still listens, such as when the forwarder runs out of open files in a burst, it tries again after a wait that starts at 5 ms and doubles with each failure in a row, up to a second, so the port answers again once files are free. Its log gets only the first failure of each run. When a forward closes, because the VM&amp;rsquo;s server stopped or its port is now another VM&amp;rsquo;s, the forwarder closes that forward&amp;rsquo;s open connections and ends their ssh processes too. A VM that never closes its end of a connection therefore can&amp;rsquo;t keep that connection&amp;rsquo;s ssh process, or one of the 256, after its port&amp;rsquo;s forward has gone.&lt;/p&gt;
&lt;p&gt;A connection&amp;rsquo;s ssh process also ends once the program on this machine has closed its side and the VM has sent nothing for 30 seconds, whether or not the VM closes its end. A program that only stops sending, and waits for an answer, still gets one for as long as the VM keeps sending it, however slowly the program reads it, but the VM has to send something at least every 30 seconds, its first byte included. So a program that stops sending and then waits longer than that for the answer to begin, such as &lt;code&gt;nc -N&lt;/code&gt; in front of a slow database query, has its connection cut. The same holds for every link&amp;rsquo;s connections (&lt;a href="#each-connection"&gt;each connection&lt;/a&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="its-process-and-files"&gt;Its process and files&lt;span class="hx:absolute hx:-mt-20" id="its-process-and-files"&gt;&lt;/span&gt;
&lt;a href="#its-process-and-files" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The forwarder runs as a hidden devvm command, &lt;code&gt;devvm _ports&lt;/code&gt;, one process for each VM. devvm starts it after each start of the VM, once the backend says the VM runs, and again with the new ports when you change a running VM&amp;rsquo;s ports. &lt;code&gt;devvm stop&lt;/code&gt;, &lt;code&gt;devvm rm&lt;/code&gt; and &lt;code&gt;devvm gc --orphans&lt;/code&gt; stop it, and a VM that stops some other way ends it, because the forwarder exits once the backend&amp;rsquo;s process for the VM is gone. Which ports a VM forwards is in the VM&amp;rsquo;s state, which devvm reads each time it starts the forwarder, so &lt;code&gt;devvm ports&lt;/code&gt; changes the state and never the backend&amp;rsquo;s config, and the backend never hears of them. The forwarder&amp;rsquo;s log is &lt;code&gt;ports.log&lt;/code&gt; in the VM&amp;rsquo;s logs folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/logs/&lt;/code&gt;, and its &lt;code&gt;ports.pid&lt;/code&gt;, &lt;code&gt;ports.status&lt;/code&gt;, &lt;code&gt;ports.lock&lt;/code&gt; and &lt;code&gt;ports.forwarded&lt;/code&gt; are in the VM&amp;rsquo;s run folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/&lt;/code&gt;, beside the VM&amp;rsquo;s host keys for its current start, &lt;code&gt;known_hosts&lt;/code&gt;, which the forwarder checks the VM against, as devvm&amp;rsquo;s ssh config does (&lt;a href="https://next.devvm.dev/docs/internals/security/#ssh-into-vms"&gt;ssh into VMs&lt;/a&gt;). Its control socket is &lt;code&gt;~/.local/share/devvm/run/port-&amp;lt;hash&amp;gt;.ctl&lt;/code&gt;, named by a hash of the VM&amp;rsquo;s name, outside the VM&amp;rsquo;s folder, because a unix socket&amp;rsquo;s path has fewer than 104 characters. &lt;a href="https://next.devvm.dev/docs/internals/processes/#the-port-forwarder"&gt;Processes&lt;/a&gt; has what the forwarder holds, what it reads from the VM and the bounds on its log, and &lt;a href="https://next.devvm.dev/docs/internals/processes/#ssh-masters-and-relays"&gt;ssh masters and relays&lt;/a&gt; has its ssh processes.&lt;/p&gt;
&lt;p&gt;devvm reads every list of ports the same way, whether it comes from &lt;code&gt;--ports&lt;/code&gt;, &lt;code&gt;devvm ports&lt;/code&gt; or the VM&amp;rsquo;s state. Each entry is a port from 1 to 65535 or a range of them, such as &lt;code&gt;8000-8010&lt;/code&gt;. When the VM&amp;rsquo;s state holds a list that devvm can&amp;rsquo;t read this way, such as a file edited by hand, the VM doesn&amp;rsquo;t start and devvm names the value it couldn&amp;rsquo;t read with &lt;code&gt;port_invalid&lt;/code&gt;, so a bad entry never becomes a port the VM didn&amp;rsquo;t ask for.&lt;/p&gt;
&lt;h2 data-hextra-search-id="when-it-cant-forward"&gt;When it can&amp;rsquo;t forward&lt;span class="hx:absolute hx:-mt-20" id="when-it-cant-forward"&gt;&lt;/span&gt;
&lt;a href="#when-it-cant-forward" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When a forwarder doesn&amp;rsquo;t start, devvm warns you and names its log (&lt;code&gt;ports_forward_failed&lt;/code&gt;), and the VM runs on without forwarded ports.&lt;/p&gt;
&lt;p&gt;When a running forwarder tries a listed port and can&amp;rsquo;t take it, it logs the port with the system&amp;rsquo;s error and records why in &lt;code&gt;ports.forwarded&lt;/code&gt;. &lt;code&gt;devvm ports&lt;/code&gt; warns about each such port by why:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ports_taken&lt;/code&gt;, when a program on this machine has the port, which the system reports as the address being in use. The forwarder tries the port again only once the VM&amp;rsquo;s server on it stops and starts again.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ports_limit&lt;/code&gt;, when the VM already forwards 256 ports, the most a forwarder forwards at once, so the forwarder didn&amp;rsquo;t try it. The forwarder tries the port again at the VM&amp;rsquo;s next report once it forwards fewer.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ports_refused&lt;/code&gt;, when this machine denied the forwarder the port, such as Linux keeping ports below 1024 for root. The forwarder tries the port again only once the VM&amp;rsquo;s server on it stops and starts again.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Any other error, such as running out of open files for a moment, says nothing about the port, so the forwarder logs it alone, records nothing, and tries the port again at the VM&amp;rsquo;s next report.&lt;/p&gt;
&lt;p&gt;The forwarder listens on both &lt;code&gt;127.0.0.1&lt;/code&gt; and &lt;code&gt;::1&lt;/code&gt;, and it treats an error on &lt;code&gt;::1&lt;/code&gt; as it would treat one on &lt;code&gt;127.0.0.1&lt;/code&gt;, closing the port&amp;rsquo;s &lt;code&gt;127.0.0.1&lt;/code&gt; listener as well. A program that listens on the port&amp;rsquo;s &lt;code&gt;::1&lt;/code&gt; makes the port count as in use, and after any other error the forwarder tries the port again at the next report, so an error that passes never leaves a forward on IPv4 alone. A machine without IPv6 on its loopback gets the port on &lt;code&gt;127.0.0.1&lt;/code&gt; alone, and so does one that refuses the forwarder &lt;code&gt;::1&lt;/code&gt; while it allows &lt;code&gt;127.0.0.1&lt;/code&gt;, such as one whose security module denies IPv6 sockets, and the forwarder logs that.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm ports&lt;/code&gt; reads these from the forwarder&amp;rsquo;s record and binds nothing to find out, so it never takes a port that the forwarder is opening at that moment. A port that another VM forwards isn&amp;rsquo;t one of these, so it gets &lt;code&gt;ports_held&lt;/code&gt; instead. A record that the running forwarder didn&amp;rsquo;t write, or none, gives none of these warnings, and neither does a record from an older devvm&amp;rsquo;s forwarder after an upgrade, which lists every port it couldn&amp;rsquo;t take on one line, without saying why, so devvm never says a port is in use when it may not be.&lt;/p&gt;
&lt;h2 data-hextra-search-id="links-between-vms"&gt;Links between VMs&lt;span class="hx:absolute hx:-mt-20" id="links-between-vms"&gt;&lt;/span&gt;
&lt;a href="#links-between-vms" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A &lt;a href="https://next.devvm.dev/docs/using/links/"&gt;link between VMs&lt;/a&gt; carries a client VM&amp;rsquo;s connections to a port that a target VM publishes. Like the forwarder, it goes over ssh, every connection starts on this machine, and it uses neither VM&amp;rsquo;s network, so no backend&amp;rsquo;s confinement changes and a confined VM still reaches nothing past its proxy over its own network. &lt;a href="https://next.devvm.dev/docs/contributing/design/#links-between-vms"&gt;The design note&lt;/a&gt; has the rules, the threat check and what the prototype showed.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-addresses"&gt;The addresses&lt;span class="hx:absolute hx:-mt-20" id="the-addresses"&gt;&lt;/span&gt;
&lt;a href="#the-addresses" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Each target that a client links to gets an address of its own in &lt;code&gt;127.77.0.0/16&lt;/code&gt; in that client, starting at &lt;code&gt;127.77.0.1&lt;/code&gt;. devvm chooses it when the client&amp;rsquo;s first link to that target is made and keeps it for every port of that target, so two targets can share a port. The client&amp;rsquo;s &lt;code&gt;/etc/hosts&lt;/code&gt; holds a block between &lt;code&gt;# devvm links begin&lt;/code&gt; and &lt;code&gt;# devvm links end&lt;/code&gt;, with a line &lt;code&gt;127.77.x.y NAME NAME.devvm.internal&lt;/code&gt; for each target. The VM&amp;rsquo;s setup replaces the block whole at each launch, and again when links change on a running client. The setup writes the file in place, never renaming over it, and only when the block changed.&lt;/p&gt;
&lt;p&gt;A link listens at its target&amp;rsquo;s address on the target&amp;rsquo;s own port, never on the client&amp;rsquo;s &lt;code&gt;127.0.0.1&lt;/code&gt; or &lt;code&gt;::1&lt;/code&gt;. At each start, the setup sets &lt;code&gt;net.ipv4.ip_unprivileged_port_start&lt;/code&gt; to &lt;code&gt;0&lt;/code&gt; where it&amp;rsquo;s &lt;code&gt;1024&lt;/code&gt;, which is on Lima&amp;rsquo;s Alpine VMs, so a link to a port below 1024 listens on that port too. Lima&amp;rsquo;s Ubuntu and Debian VMs already have &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The addresses are internal to devvm. &lt;code&gt;devvm link&lt;/code&gt; and its JSON never show them, and the forwarder never forwards them (&lt;a href="#what-it-forwards"&gt;above&lt;/a&gt;).&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-link-session"&gt;The link session&lt;span class="hx:absolute hx:-mt-20" id="the-link-session"&gt;&lt;/span&gt;
&lt;a href="#the-link-session" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;For each running client with links, devvm runs a hidden command, &lt;code&gt;devvm _links VM&lt;/code&gt;, as one detached process on this machine. Its pid is in &lt;code&gt;links.pid&lt;/code&gt; in the VM&amp;rsquo;s run folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/&lt;/code&gt;, and its log is &lt;code&gt;links.log&lt;/code&gt; in the VM&amp;rsquo;s logs folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/logs/&lt;/code&gt;. It keeps an ssh connection of its own to the client, never the forwarder&amp;rsquo;s, which starts with no forwards and asks for each link as a remote forward from &lt;code&gt;127.77.x.y:PORT&lt;/code&gt; in the client to a unix socket on this machine. That&amp;rsquo;s the only remote forward devvm asks a VM for. It reads the client&amp;rsquo;s links again every second and adds or cancels one forward at a time as they change, and a cancel leaves the connections that are open. A link whose address and port a program in the client already holds fails alone, with &lt;code&gt;link_port_taken&lt;/code&gt; in the session&amp;rsquo;s log, which the next launch shows. Each line that the session&amp;rsquo;s ssh processes print starts with &lt;code&gt;ssh:&lt;/code&gt; in its log, so no line of theirs reads as one of the session&amp;rsquo;s own, and devvm link add and the launch read only the session&amp;rsquo;s own lines.&lt;/p&gt;
&lt;p&gt;The process ends once the client no longer runs the start it was made for, or has no links left, and &lt;code&gt;devvm stop&lt;/code&gt; stops it with the client, which ends its connections and removes its sockets. &lt;a href="https://next.devvm.dev/docs/internals/processes/#the-link-session"&gt;Processes&lt;/a&gt; has what the session holds, what it reads from the VMs and the bounds on its log.&lt;/p&gt;
&lt;p&gt;Every VM&amp;rsquo;s sshd allows remote forwards on &lt;code&gt;127.77.0.0/16&lt;/code&gt; alone, with &lt;code&gt;AllowTcpForwarding all&lt;/code&gt;, &lt;code&gt;GatewayPorts clientspecified&lt;/code&gt; and &lt;code&gt;PermitListen 127.77.*:*&lt;/code&gt;, written once into every image, so links never change or reload sshd. sshd matches the address a request names against that rule as text, so a remote forward on &lt;code&gt;localhost&lt;/code&gt;, &lt;code&gt;127.0.0.1&lt;/code&gt;, &lt;code&gt;0.0.0.0&lt;/code&gt; or &lt;code&gt;::1&lt;/code&gt; is refused. Root in the client can change sshd, so those settings protect only an honest VM. What keeps the VM from choosing where its connections go on this machine is the host&amp;rsquo;s ssh client, which accepts a forwarded channel only for a forward it asked for and connects it only to that link&amp;rsquo;s socket.&lt;/p&gt;
&lt;h3 data-hextra-search-id="each-connection"&gt;Each connection&lt;span class="hx:absolute hx:-mt-20" id="each-connection"&gt;&lt;/span&gt;
&lt;a href="#each-connection" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A program in the client that connects to &lt;code&gt;db:5432&lt;/code&gt; takes this path:&lt;/p&gt;
&lt;div class="devvm-diagram" style="contain-intrinsic-block-size: auto 580px; --devvm-diagram-width: 293px"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" class="pele pele-flowchart" viewBox="0 0 293 580" width="293" height="580" style="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,&amp;quot;Departure Mono&amp;quot;, monospace);font:14px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,&amp;quot;Departure Mono&amp;quot;, monospace)" fill="var(--_fg)" role="graphics-document document" aria-roledescription="flowchart" aria-labelledby="d895e190151e6a7be--title" aria-describedby="d895e190151e6a7be--desc"&gt;&lt;title id="d895e190151e6a7be--title"&gt;A connection over a link&lt;/title&gt;&lt;desc id="d895e190151e6a7be--desc"&gt;Your program in the client connects to db:5432, which /etc/hosts names as 127.77.0.1. The client's sshd passes it over the link session's ssh, which this machine opened, to devvm _links on this machine, which connects over ssh, with the target's key and pinned host key, to the target's sshd, and so to the server on the target's own loopback, 127.0.0.1:5432.&lt;/desc&gt;&lt;g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round"&gt;&lt;g class="pele-edge" data-id="L_app_csshd_0"&gt;&lt;path d="M146.27,53L146.27,127"/&gt;&lt;path class="pele-marker" d="M146.27,134L142.91,126L149.63,126Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_csshd_links_0"&gt;&lt;path d="M146.27,179L146.27,253"/&gt;&lt;path class="pele-marker" d="M146.27,260L142.91,252L149.63,252Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_links_tsshd_0"&gt;&lt;path d="M146.27,320L146.27,394"/&gt;&lt;path class="pele-marker" d="M146.27,401L142.91,393L149.63,393Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_tsshd_server_0"&gt;&lt;path d="M146.27,446L146.27,520"/&gt;&lt;path class="pele-marker" d="M146.27,527L142.91,519L149.63,519Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edge-labels" font-size="14"&gt;&lt;g class="pele-edge-label" data-id="L_app_csshd_0"&gt;&lt;rect x="30.91" y="77.5" width="230.73" height="32" rx="3" fill="var(--_bg)"/&gt;&lt;text text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="146.27" y="89.7"&gt;db:5432, which /etc/hosts&lt;/tspan&gt;&lt;tspan x="146.27" y="105.7"&gt;names as 127.77.0.1&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_csshd_links_0"&gt;&lt;rect x="30.91" y="203.5" width="230.73" height="32" rx="3" fill="var(--_bg)"/&gt;&lt;text text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="146.27" y="215.7"&gt;the link session's ssh,&lt;/tspan&gt;&lt;tspan x="146.27" y="231.7"&gt;which this machine opened&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_links_tsshd_0"&gt;&lt;rect x="26.45" y="344.5" width="239.64" height="32" rx="3" fill="var(--_bg)"/&gt;&lt;text text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="146.27" y="356.7"&gt;ssh, with the target's key&lt;/tspan&gt;&lt;tspan x="146.27" y="372.7"&gt;and pinned host key&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_tsshd_server_0"&gt;&lt;rect x="71" y="470.5" width="150.55" height="32" rx="3" fill="var(--_bg)"/&gt;&lt;text text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="146.27" y="482.7"&gt;127.0.0.1:5432,&lt;/tspan&gt;&lt;tspan x="146.27" y="498.7"&gt;its own loopback&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-nodes"&gt;&lt;g class="pele-node pele-shape-rect" data-id="app" transform="translate(146.27,30.5)"&gt;&lt;rect x="-138.27" y="-22.5" width="276.55" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;your program, in the client&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="csshd" transform="translate(146.27,156.5)"&gt;&lt;rect x="-93.73" y="-22.5" width="187.45" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;the client's sshd&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="links" transform="translate(146.27,290)"&gt;&lt;rect x="-84.82" y="-30" width="169.64" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;devvm _links,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;on this machine&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="tsshd" transform="translate(146.27,423.5)"&gt;&lt;rect x="-93.73" y="-22.5" width="187.45" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;the target's sshd&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="server" transform="translate(146.27,549.5)"&gt;&lt;rect x="-129.36" y="-22.5" width="258.73" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;the server, in the target&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/div&gt;&lt;ol&gt;
&lt;li&gt;The client&amp;rsquo;s sshd carries the connection over the link session to this machine, where ssh connects it to the link&amp;rsquo;s unix socket. The socket is mode 600, in &lt;code&gt;~/.local/share/devvm/run&lt;/code&gt; (mode 700), and named by a hash of the client, the address and the port, because a socket&amp;rsquo;s path has fewer than 104 characters.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;devvm _links&lt;/code&gt; checks the link again. The link must still exist, the target must be the VM it was made for, by its ID, the port must be published, the &lt;a href="https://next.devvm.dev/docs/using/links/#links-and-network-tiers"&gt;tier rule&lt;/a&gt; must hold, and the target must be running, as its backend says. For a client on a confined tier, the target&amp;rsquo;s tier must also be enforced as the target runs, as &lt;code&gt;devvm ls&lt;/code&gt; shows it, because a target that got a confined tier while it ran stays outside its proxy until its next start, and one whose self-check failed may reach the internet directly. devvm never starts the target for a connection. The link session asks the target&amp;rsquo;s backend whether the target is running and how its ssh reaches it, and the connections to that target share that answer for one second, so a burst of connections asks the backend once and devvm notices a target that stops within a second. For a client on a confined tier, the check of the target&amp;rsquo;s tier asks the backend for each connection, so it notices at once that the target stopped, and devvm logs the connection as refused because the target isn&amp;rsquo;t running, not because its tier isn&amp;rsquo;t in force. An answer that a connection closing cut short isn&amp;rsquo;t shared, so the other connections ask again. devvm makes every other check again for each connection, including the check of the target&amp;rsquo;s tier as it runs.&lt;/li&gt;
&lt;li&gt;It carries the connection over one ssh connection that it keeps to each target, with the target&amp;rsquo;s key and pinned host key, and the target&amp;rsquo;s sshd connects to &lt;code&gt;127.0.0.1:PORT&lt;/code&gt; in the target. That connection to a target ends when the target stops, and the next one reads the target&amp;rsquo;s host keys again, because a VM whose Lima config changed gets new ones when it boots.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;An HTTP client that uses the VM&amp;rsquo;s proxy settings sends &lt;code&gt;db:5432&lt;/code&gt; to the VM&amp;rsquo;s proxy instead, and the proxy connects to the same link socket on this machine (&lt;a href="https://next.devvm.dev/docs/internals/network/#links-through-the-proxy"&gt;links through the proxy&lt;/a&gt;). Steps 2 and 3 are the same for it, so the link&amp;rsquo;s checks, its cap and its events hold for both ways in.&lt;/p&gt;
&lt;p&gt;At most 256 of a client&amp;rsquo;s connections are carried at once, and the next one is refused. A link&amp;rsquo;s socket holds at most 128 connections waiting to be accepted on macOS, and &lt;code&gt;devvm _links&lt;/code&gt; accepts nothing while it starts a process, so it accepts a burst of connections whole before it starts any of their ssh processes: it hands them on once 5 ms pass with nothing more to accept, once the first has waited 50 ms, or once 257 wait. Each one it accepted is carried, or refused when 256 are carried already. The ssh connection to a target takes in two file descriptors for each connection it carries, more than macOS&amp;rsquo;s default limit of 256 open files allows, so &lt;code&gt;devvm _links&lt;/code&gt; and the port forwarder give the ssh processes they start the higher limit that devvm runs with. Each connection carried or refused is written to the client&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/network/#log-files"&gt;event log&lt;/a&gt;, which &lt;code&gt;devvm network log&lt;/code&gt; shows, so every VM gets an event log for its links&amp;rsquo; connections, whatever its tier.&lt;/p&gt;
&lt;h3 data-hextra-search-id="when-links-change"&gt;When links change&lt;span class="hx:absolute hx:-mt-20" id="when-links-change"&gt;&lt;/span&gt;
&lt;a href="#when-links-change" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;devvm link add&lt;/code&gt; and &lt;code&gt;devvm link rm&lt;/code&gt; record the change in the client&amp;rsquo;s state on this machine, never in a VM. On a running client they send its setup again, which rewrites &lt;code&gt;/etc/hosts&lt;/code&gt;, and they start &lt;code&gt;devvm _links&lt;/code&gt; if it isn&amp;rsquo;t running. &lt;code&gt;devvm _links&lt;/code&gt; reads the links again every second and writes the list that the client&amp;rsquo;s proxy reads, so the proxy reaches a new link as soon as its forward is in place. A stopped client gets the change when it next starts. Links change nothing else in the VM: no link name is in its &lt;code&gt;NO_PROXY&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-vms-setup"&gt;the VM&amp;rsquo;s setup&lt;/a&gt;), so no daemon restarts, and on Lima no link changes the VM&amp;rsquo;s Lima config or its ssh host keys.&lt;/p&gt;
&lt;p&gt;When a link goes, &lt;code&gt;devvm _links&lt;/code&gt; stops listening for it and ends the connections that are open through it, with their ssh processes. Each connection&amp;rsquo;s ssh process waits for the target&amp;rsquo;s sshd to end its channel, so ending it is what keeps a target that never closes its end from holding that process, and one of the client&amp;rsquo;s 256 connections, after the link has gone. When a target starts again, the connections still open through its old ssh connection end once the next connection to the target arrives, which makes a new ssh connection, or once the old one dies. A link whose name now leads to another target at the same address and port, because one link was removed and another added within the same second, ends the old target&amp;rsquo;s connections the same way.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm rm&lt;/code&gt; of a target removes every link to it from every client&amp;rsquo;s state and updates the running clients, and &lt;code&gt;devvm gc --orphans&lt;/code&gt; removes links to VMs whose state is gone and the sockets that a killed link session left.&lt;/p&gt;
&lt;h3 data-hextra-search-id="groups"&gt;Groups&lt;span class="hx:absolute hx:-mt-20" id="groups"&gt;&lt;/span&gt;
&lt;a href="#groups" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A &lt;a href="https://next.devvm.dev/docs/using/links/#groups"&gt;group&lt;/a&gt; is recorded in each of its VMs&amp;rsquo; own state, with the name the others reach it by, so a VM made again in a folder, which gets new state, is in none. The links a group makes are links in each VM&amp;rsquo;s state like the ones &lt;code&gt;devvm link add&lt;/code&gt; makes, marked as the group&amp;rsquo;s, so the link session, the proxy&amp;rsquo;s list and every check of a connection treat them alike. devvm works out each VM&amp;rsquo;s group links again from its own links and the other VMs&amp;rsquo; published ports whenever one of them joins or leaves, publishes or unpublishes a port, or adds or removes a link of its own, and it records and applies only the VMs whose links changed, as &lt;a href="#when-links-change"&gt;above&lt;/a&gt;. &lt;a href="https://next.devvm.dev/docs/contributing/design/#groups"&gt;The design note&lt;/a&gt; has the rules and the threat check.&lt;/p&gt;</description></item><item><title>The desktop</title><link>https://next.devvm.dev/docs/internals/desktop/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/desktop/</guid><description>
&lt;p&gt;This page explains how &lt;code&gt;devvm desktop&lt;/code&gt; serves a VM&amp;rsquo;s desktop on this machine, how it checks a viewer&amp;rsquo;s password and keeps the clipboard out of the VM, and why devvm uses VNC and never forwards X11. &lt;a href="https://next.devvm.dev/docs/using/desktop/"&gt;A VM&amp;rsquo;s desktop&lt;/a&gt; covers adding the desktop and opening it.&lt;/p&gt;
&lt;h2 data-hextra-search-id="in-the-vm"&gt;In the VM&lt;span class="hx:absolute hx:-mt-20" id="in-the-vm"&gt;&lt;/span&gt;
&lt;a href="#in-the-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The built-in &lt;code&gt;desktop&lt;/code&gt; layer installs Xfce, TigerVNC&amp;rsquo;s &lt;code&gt;Xvnc&lt;/code&gt;, &lt;code&gt;socat&lt;/code&gt; for &lt;a href="#the-local-proxy"&gt;the local proxy&lt;/a&gt; and a command of devvm&amp;rsquo;s, &lt;code&gt;devvm-desktop&lt;/code&gt;, into the &lt;code&gt;desktop&lt;/code&gt; image, which only the VMs with the layer are made from (&lt;a href="https://next.devvm.dev/docs/internals/images/#the-desktop-layer"&gt;the desktop layer&lt;/a&gt;). Its packages come from the distribution&amp;rsquo;s archive as it is when the layer builds, and it downloads nothing else. When you run &lt;code&gt;devvm desktop&lt;/code&gt;, devvm first checks that the VM has &lt;code&gt;devvm-desktop&lt;/code&gt;, and refuses a VM without it (&lt;code&gt;desktop_no_layer&lt;/code&gt;). Then it runs &lt;code&gt;devvm-desktop start off&lt;/code&gt;, or &lt;code&gt;start on&lt;/code&gt; with &lt;code&gt;--clipboard&lt;/code&gt;, as the VM&amp;rsquo;s user.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm-desktop&lt;/code&gt; starts &lt;code&gt;Xvnc&lt;/code&gt; on display &lt;code&gt;:1&lt;/code&gt; unless it&amp;rsquo;s running. &lt;code&gt;Xvnc&lt;/code&gt; listens on the socket &lt;code&gt;/run/devvm-desktop/vnc.sock&lt;/code&gt; alone, in a folder of the VM&amp;rsquo;s user&amp;rsquo;s own (mode 700), the socket itself mode 600. It listens on no TCP port (&lt;code&gt;-rfbport -1&lt;/code&gt;), and takes no X11 connections over TCP (&lt;code&gt;-nolisten tcp&lt;/code&gt;), so devvm&amp;rsquo;s port forwarder never sees it, even on a VM that forwards every port. It asks for no password of its own (&lt;code&gt;-SecurityTypes None&lt;/code&gt;), because devvm checks the viewer&amp;rsquo;s password on this machine first. The clipboard settings (&lt;code&gt;AcceptCutText&lt;/code&gt;, &lt;code&gt;SendCutText&lt;/code&gt;, &lt;code&gt;SetPrimary&lt;/code&gt;, &lt;code&gt;SendPrimary&lt;/code&gt;) are on or off as asked, and on a desktop that runs already, &lt;code&gt;devvm-desktop&lt;/code&gt; changes them in place with &lt;code&gt;vncconfig&lt;/code&gt;. Then it starts an Xfce session on the display, in a D-Bus session of its own, with the session&amp;rsquo;s proxy settings pointed at &lt;a href="#the-local-proxy"&gt;the VM&amp;rsquo;s local proxy&lt;/a&gt;. Nothing starts the desktop at boot, so a VM whose desktop you never open runs none. Its log is &lt;code&gt;~/.cache/devvm-desktop.log&lt;/code&gt; in the VM.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-local-proxy"&gt;The local proxy&lt;span class="hx:absolute hx:-mt-20" id="the-local-proxy"&gt;&lt;/span&gt;
&lt;a href="#the-local-proxy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Every request from the VM to its &lt;a href="https://next.devvm.dev/docs/internals/network/#the-proxy"&gt;proxy&lt;/a&gt; carries the VM&amp;rsquo;s password in &lt;code&gt;Proxy-Authorization&lt;/code&gt;, and the VM&amp;rsquo;s proxy settings carry it in their URL, &lt;code&gt;http://devvm:[email protected]:PORT&lt;/code&gt;. Command-line tools take the password from that URL, but Chrome, Chromium and Firefox ignore it and ask for the proxy&amp;rsquo;s username and password instead, on every site. So the desktop&amp;rsquo;s programs use a local proxy in the VM, &lt;code&gt;devvm-local-proxy&lt;/code&gt;, which needs no password and adds the VM&amp;rsquo;s.&lt;/p&gt;
&lt;p&gt;The VM&amp;rsquo;s setup writes &lt;code&gt;devvm-local-proxy&lt;/code&gt; into &lt;code&gt;/usr/local/bin&lt;/code&gt; at each launch, mode 700 and the VM&amp;rsquo;s user&amp;rsquo;s, with the VM&amp;rsquo;s proxy address and password in it, and installs it whole, so a connection that&amp;rsquo;s already running keeps the copy it started with. The VM already holds the same password in its environment. &lt;code&gt;devvm-desktop&lt;/code&gt; runs &lt;code&gt;devvm-local-proxy start&lt;/code&gt; before it starts &lt;code&gt;Xvnc&lt;/code&gt;, which starts &lt;code&gt;socat&lt;/code&gt; unless it&amp;rsquo;s running, so the local proxy starts with the desktop and runs until the VM stops. &lt;code&gt;socat&lt;/code&gt; listens on &lt;code&gt;127.0.77.1:3128&lt;/code&gt; alone, which is on the VM&amp;rsquo;s loopback, takes connections only from &lt;code&gt;127.0.0.0/8&lt;/code&gt;, carries at most 256 at once, and runs &lt;code&gt;devvm-local-proxy&lt;/code&gt; on each connection itself. Its log is &lt;code&gt;~/.cache/devvm-local-proxy.log&lt;/code&gt;. The address comes from devvm&amp;rsquo;s proxy code (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt;), which the setup gets as &lt;code&gt;DEVVM_LOCAL_PROXY&lt;/code&gt;, and &lt;code&gt;devvm-desktop&lt;/code&gt; sets &lt;code&gt;http_proxy&lt;/code&gt;, &lt;code&gt;https_proxy&lt;/code&gt;, &lt;code&gt;HTTP_PROXY&lt;/code&gt; and &lt;code&gt;HTTPS_PROXY&lt;/code&gt; to &lt;code&gt;http://127.0.77.1:3128&lt;/code&gt; for the Xfce session. On Xfce, Chrome and Chromium read those variables for their proxy, and Firefox reads them first when its proxy setting is the system&amp;rsquo;s, which is its default.&lt;/p&gt;
&lt;p&gt;For each connection, &lt;code&gt;devvm-local-proxy&lt;/code&gt; reads the request line and the headers, waiting at most 30 seconds for each line and taking at most 100 headers. It takes only what a proxy is sent:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a &lt;code&gt;CONNECT&lt;/code&gt; to a host and port, which becomes a tunnel;&lt;/li&gt;
&lt;li&gt;a request for an absolute &lt;code&gt;http://&lt;/code&gt; or &lt;code&gt;https://&lt;/code&gt; URL, such as &lt;code&gt;GET http://example.com/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Anything else gets &lt;code&gt;400&lt;/code&gt;, and nothing of it reaches the VM&amp;rsquo;s proxy. That includes a request in origin form, such as &lt;code&gt;GET /&lt;/code&gt;, which is what a web page sends when it reaches the local proxy as a server, so a page in the browser can&amp;rsquo;t use it. The local proxy drops the client&amp;rsquo;s own &lt;code&gt;Proxy-Authorization&lt;/code&gt; and &lt;code&gt;Proxy-Connection&lt;/code&gt; headers and adds the VM&amp;rsquo;s password. For a request that isn&amp;rsquo;t a &lt;code&gt;CONNECT&lt;/code&gt;, it drops &lt;code&gt;Connection&lt;/code&gt; and &lt;code&gt;Keep-Alive&lt;/code&gt; and asks for &lt;code&gt;Connection: close&lt;/code&gt;, because the password goes with each request&amp;rsquo;s head and the local proxy reads only the first, so each connection carries one request. Then it connects to the VM&amp;rsquo;s proxy, and to nothing else, sends the head and carries the rest both ways with &lt;code&gt;socat&lt;/code&gt;. The VM&amp;rsquo;s proxy decides as it does for any request: a host the tier allows is reached, and one it doesn&amp;rsquo;t allow gets the proxy&amp;rsquo;s &lt;code&gt;403&lt;/code&gt; with its reason.&lt;/p&gt;
&lt;p&gt;devvm&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/ports/#what-it-forwards"&gt;port forwarder&lt;/a&gt; never forwards a server on &lt;code&gt;127.0.77.1&lt;/code&gt;, on any port, because a forward would put a proxy that adds the VM&amp;rsquo;s password on this machine&amp;rsquo;s &lt;code&gt;localhost&lt;/code&gt;, where other users and programs could reach it.&lt;/p&gt;
&lt;h2 data-hextra-search-id="on-this-machine"&gt;On this machine&lt;span class="hx:absolute hx:-mt-20" id="on-this-machine"&gt;&lt;/span&gt;
&lt;a href="#on-this-machine" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm desktop&lt;/code&gt; listens on &lt;code&gt;127.0.0.1&lt;/code&gt; alone, on the VM&amp;rsquo;s port. That&amp;rsquo;s the port its state records in its &lt;code&gt;ports&lt;/code&gt; section (&lt;code&gt;host.desktop&lt;/code&gt;) while no program on this machine has it, and otherwise a new one that no program and no VM has, which devvm chooses and records in its place under the claims lock, as it does every port it chooses for a VM. New ports come from 20000 up to just below the range this machine gives outgoing connections, which starts at 32768 on Linux by default and 49152 on macOS, because Linux refuses a listener on a port that a live outgoing connection holds. devvm reads that range from the system, and when it can&amp;rsquo;t, or the range leaves fewer than 1000 ports above 20000, it picks from 20000 to 32767. The port is among those devvm records for VMs, with their ssh and proxy ports, so no VM&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/ports/#what-it-never-takes"&gt;port forwarder&lt;/a&gt; takes it and no new VM gets it for its ssh or its proxy. devvm listens without address reuse, so a program that has the port on any address keeps it. The listener stays open until you press Ctrl+C, or until the VM no longer runs, which devvm checks every 5 seconds (&lt;code&gt;desktop_vm_stopped&lt;/code&gt;). Nothing else listens for the desktop on this machine, at any other time.&lt;/p&gt;
&lt;p&gt;Each connection to the port goes through devvm&amp;rsquo;s relay, which runs in &lt;code&gt;devvm desktop&lt;/code&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The relay speaks VNC&amp;rsquo;s protocol (RFB 3.8, and 3.7 and 3.3 for older viewers) as a server, and offers VNC&amp;rsquo;s own authentication alone. It sends a random challenge and checks the viewer&amp;rsquo;s answer against the VM&amp;rsquo;s password, with one check at a time, so a wrong answer holds every other viewer&amp;rsquo;s check for a second, and at one guess a second, guessing the password would take thousands of years. A viewer whose answer is wrong is refused and never reaches the VM.&lt;/li&gt;
&lt;li&gt;Only then does the relay connect to the VM: an ssh channel to the VM&amp;rsquo;s socket (&lt;code&gt;ssh -W /run/devvm-desktop/vnc.sock&lt;/code&gt;), through devvm&amp;rsquo;s ssh config&amp;rsquo;s entry for the VM, with its pinned host key. The channel opens no session, and it carries no agent and no forwarding either way (&lt;code&gt;IdentityAgent=none&lt;/code&gt;, &lt;code&gt;ForwardAgent=no&lt;/code&gt;, &lt;code&gt;ForwardX11=no&lt;/code&gt;, &lt;code&gt;ClearAllForwardings=yes&lt;/code&gt;). The relay does the viewer&amp;rsquo;s side of the VM&amp;rsquo;s handshake, asking for no authentication, and tells the viewer it&amp;rsquo;s in.&lt;/li&gt;
&lt;li&gt;From then on it carries the viewer&amp;rsquo;s messages to the VM and the VM&amp;rsquo;s to the viewer. Without &lt;code&gt;--clipboard&lt;/code&gt;, it reads each of the viewer&amp;rsquo;s messages and drops its clipboard ones (&lt;code&gt;ClientCutText&lt;/code&gt;, extended clipboard ones included). It ends a connection that sends a message it doesn&amp;rsquo;t know, so nothing it can&amp;rsquo;t read reaches the VM.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;At most 8 viewers connect at once. The VM&amp;rsquo;s password is 8 characters of lowercase letters and digits without &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;o&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;l&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt;, about 40 bits, because VNC&amp;rsquo;s authentication uses 8 characters at most. devvm makes it the first time and keeps it in the VM&amp;rsquo;s state, in its &lt;code&gt;desktop&lt;/code&gt; section (&lt;code&gt;made.password&lt;/code&gt;), in a file that only you can read. It never goes into the VM, and devvm prints it only with the address, never into the run log. &lt;a href="https://next.devvm.dev/docs/internals/processes/#the-desktop-relay"&gt;Processes&lt;/a&gt; describes the relay alongside devvm&amp;rsquo;s other processes, and it lists the &lt;a href="https://next.devvm.dev/docs/internals/processes/#listeners-a-vm-reaches"&gt;listeners&lt;/a&gt; that a VM&amp;rsquo;s bytes reach.&lt;/p&gt;
&lt;h2 data-hextra-search-id="what-the-vm-can-and-cant-change"&gt;What the VM can and can&amp;rsquo;t change&lt;span class="hx:absolute hx:-mt-20" id="what-the-vm-can-and-cant-change"&gt;&lt;/span&gt;
&lt;a href="#what-the-vm-can-and-cant-change" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Root in the VM can change its desktop, or run another server on the socket in its place. The relay doesn&amp;rsquo;t depend on the VM&amp;rsquo;s server for its guarantees:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The password:&lt;/strong&gt; the relay checks it on this machine before it opens the channel, so a VM&amp;rsquo;s server that asks for none still gets no viewer without it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The address:&lt;/strong&gt; the relay listens on this machine&amp;rsquo;s loopback, so no server in the VM reaches other machines through it. A server root starts on a TCP port of the VM&amp;rsquo;s is an ordinary server of the VM&amp;rsquo;s, which the VM&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/using/ports-size/#ports"&gt;ports&lt;/a&gt; forward to this machine&amp;rsquo;s loopback, or don&amp;rsquo;t, as for any other.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;This machine&amp;rsquo;s clipboard:&lt;/strong&gt; without &lt;code&gt;--clipboard&lt;/code&gt;, the relay drops it, whatever the VM&amp;rsquo;s server accepts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No way out:&lt;/strong&gt; every connection starts on this machine, and the VM opens none to it through the relay. The channel is a local forward that devvm&amp;rsquo;s ssh asks for, which the VM&amp;rsquo;s sshd connects to the VM&amp;rsquo;s own socket. On a confined tier, the VM&amp;rsquo;s own connections still reach only its proxy.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The relay can&amp;rsquo;t stop a VM&amp;rsquo;s server from sending its clipboard to the viewer, because that would mean reading every screen update the server sends. So the VM&amp;rsquo;s clipboard stays off this machine only while its server is as devvm set it up, or while the viewer doesn&amp;rsquo;t take it, which Screen Sharing&amp;rsquo;s Use Shared Clipboard setting decides.&lt;/p&gt;
&lt;h2 data-hextra-search-id="why-not-x11"&gt;Why not X11&lt;span class="hx:absolute hx:-mt-20" id="why-not-x11"&gt;&lt;/span&gt;
&lt;a href="#why-not-x11" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;ssh&amp;rsquo;s X11 forwarding gives programs in the VM a connection to this machine&amp;rsquo;s display, and an X11 program on a display can read the keys typed into other windows on it, read their contents and send them input. So devvm turns X11 forwarding off on both sides of the VM&amp;rsquo;s ssh. Its ssh config&amp;rsquo;s entries set &lt;code&gt;ForwardX11 no&lt;/code&gt;, and the VM&amp;rsquo;s sshd has &lt;code&gt;X11Forwarding no&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/security/#ssh-into-vms"&gt;ssh into VMs&lt;/a&gt;). With VNC, the VM&amp;rsquo;s programs draw on a display of the VM&amp;rsquo;s own, and this machine only shows a picture of it, so nothing in the VM reaches this machine&amp;rsquo;s windows.&lt;/p&gt;</description></item><item><title>Network tiers</title><link>https://next.devvm.dev/docs/internals/network/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/network/</guid><description>
&lt;p&gt;This page explains how devvm confines a VM to its proxy on each tier, what the proxy does with each connection, and how your secrets get into the VM&amp;rsquo;s requests without the VM holding them. &lt;a href="https://next.devvm.dev/docs/safety/network/"&gt;Network tiers&lt;/a&gt; covers choosing a tier, the allowlists and their rules, the secrets and the logs as you use them.&lt;/p&gt;
&lt;h2 data-hextra-search-id="starting-a-vm-on-its-tier"&gt;Starting a VM on its tier&lt;span class="hx:absolute hx:-mt-20" id="starting-a-vm-on-its-tier"&gt;&lt;/span&gt;
&lt;a href="#starting-a-vm-on-its-tier" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A VM&amp;rsquo;s state records its tier in its &lt;code&gt;net&lt;/code&gt; section, as &lt;code&gt;&amp;quot;tier&amp;quot;&lt;/code&gt;: &lt;code&gt;open&lt;/code&gt;, &lt;code&gt;internet&lt;/code&gt;, &lt;code&gt;allowlist&lt;/code&gt; or &lt;code&gt;none&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/safety/network/#network-tiers"&gt;network tiers&lt;/a&gt;). A section without a tier reads as &lt;code&gt;allowlist&lt;/code&gt;, and one with a tier devvm doesn&amp;rsquo;t know can&amp;rsquo;t be read, so devvm refuses the VM rather than take it as open. The tier decides the VM&amp;rsquo;s confinement: on every tier but open, the VM starts confined to its proxy, and an open VM starts on its backend&amp;rsquo;s own network with its proxy&amp;rsquo;s port and password in its confinement, so its guest&amp;rsquo;s proxy settings name the proxy all the same (&lt;a href="https://next.devvm.dev/docs/contributing/extending/#how-a-backend-plugs-in"&gt;how a backend plugs in&lt;/a&gt;). A running VM keeps the confinement it started with until its next start.&lt;/p&gt;
&lt;p&gt;When devvm starts a VM on a confined tier, it takes these steps in order:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It readies the VM&amp;rsquo;s own CA and the next one (&lt;a href="#the-vms-ca"&gt;the VM&amp;rsquo;s CA&lt;/a&gt;), and on macOS it keeps them out of Time Machine.&lt;/li&gt;
&lt;li&gt;It writes the VM&amp;rsquo;s &lt;a href="#secrets"&gt;secrets&lt;/a&gt; as the VM&amp;rsquo;s proxy sees them.&lt;/li&gt;
&lt;li&gt;It starts the VM&amp;rsquo;s &lt;a href="#the-proxy"&gt;proxy&lt;/a&gt; on a free port on the host&amp;rsquo;s loopback, and waits for the proxy to say it&amp;rsquo;s listening.&lt;/li&gt;
&lt;li&gt;It starts the VM &lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;confined&lt;/a&gt;, with the VM&amp;rsquo;s proxy settings pointing at the proxy.&lt;/li&gt;
&lt;li&gt;It runs &lt;a href="#the-self-check"&gt;the self-check&lt;/a&gt; before the VM&amp;rsquo;s setup and before its shell.&lt;/li&gt;
&lt;li&gt;It sets the VM up, as &lt;a href="#the-vms-setup"&gt;the VM&amp;rsquo;s setup&lt;/a&gt; describes. The setup puts the VM&amp;rsquo;s CA and the next one in the VM, points the tools that don&amp;rsquo;t read the environment at the proxy, and writes the VM&amp;rsquo;s placeholders and its &lt;a href="#agents-logins-and-settings"&gt;agents&amp;rsquo; logins and settings&lt;/a&gt; with your keys taken out.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;An open VM&amp;rsquo;s start takes the same steps, but it starts the VM unconfined and runs &lt;a href="#the-self-check"&gt;the open self-check&lt;/a&gt;. Its proxy has the VM&amp;rsquo;s CAs and its secrets as any VM&amp;rsquo;s does, and applies no rules. Its setup installs both CAs in the VM, points the same tools at the proxy, and writes the same placeholders and copies of the agents&amp;rsquo; logins and settings, so an open VM holds no real secret either. The VM reaches its proxy directly, through the &lt;code&gt;HTTPS_PROXY&lt;/code&gt; that names it (&lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;Lima&lt;/a&gt;), and a request that goes around the proxy carries only the placeholder.&lt;/p&gt;
&lt;p&gt;So an open VM runs on its backend&amp;rsquo;s own network, and it reaches this machine and your LAN directly, as a VM without a proxy would. Its environment names its proxy all the same (&lt;code&gt;HTTP_PROXY&lt;/code&gt;, &lt;code&gt;HTTPS_PROXY&lt;/code&gt; and their lowercase forms), and the proxy reaches every host and address for it, this machine&amp;rsquo;s &lt;code&gt;localhost&lt;/code&gt; and your LAN included, so a tool behaves the same through the proxy as it does directly. Its &lt;code&gt;NO_PROXY&lt;/code&gt; names the VM itself and this machine as the VM reaches it, &lt;code&gt;host.lima.internal&lt;/code&gt;, so requests to those go directly. Every launch checks that an open VM&amp;rsquo;s proxy is set in the VM and answers it, and when it doesn&amp;rsquo;t, devvm warns you and opens the VM all the same. An open VM gets a placeholder for each secret it may use, as every VM does, and only its proxy puts the real value in, so a request that goes around the proxy, directly from the VM, carries only the placeholder, and the secret&amp;rsquo;s host refuses it.&lt;/p&gt;
&lt;h2 data-hextra-search-id="vms-that-cant-be-confined"&gt;VMs that can&amp;rsquo;t be confined&lt;span class="hx:absolute hx:-mt-20" id="vms-that-cant-be-confined"&gt;&lt;/span&gt;
&lt;a href="#vms-that-cant-be-confined" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A VM whose backend can&amp;rsquo;t confine it to its proxy (&lt;code&gt;egress-proxy&lt;/code&gt;) can only be open: devvm refuses to make it on any other tier, unasked, in one line that names the backend and &lt;code&gt;--network open&lt;/code&gt; (&lt;code&gt;net_tier_backend&lt;/code&gt;), and the registry&amp;rsquo;s check refuses &lt;code&gt;devvm network&lt;/code&gt; with a confined tier.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-proxy"&gt;The proxy&lt;span class="hx:absolute hx:-mt-20" id="the-proxy"&gt;&lt;/span&gt;
&lt;a href="#the-proxy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;One proxy runs for each VM. It runs on the host as &lt;code&gt;devvm _proxy&lt;/code&gt;, a hidden command, and listens on a loopback port. The VM reaches nothing else over its network, so every connection the VM makes goes through its proxy.&lt;/p&gt;
&lt;p&gt;The proxy is two processes. &lt;code&gt;devvm _proxy&lt;/code&gt;, the broker, does what only the host should do. It looks up each bound value, sends the token requests of logins made in the VM, connects to the VM&amp;rsquo;s links&amp;rsquo; sockets, reads the files that change while the proxy runs, relays the VM&amp;rsquo;s SSH agent, follows the VM&amp;rsquo;s lifeline, and looks up the names and opens the connections that the child asks for. Its child, &lt;code&gt;devvm _proxy-child&lt;/code&gt;, does everything this section describes with the VM&amp;rsquo;s requests, and asks the broker over a socketpair for each of those, by something the broker finds in its own config, so a child that a VM took over can&amp;rsquo;t make the broker act for another VM, another secret or another file. No byte of the VM&amp;rsquo;s requests crosses that socket, because the broker hands the child each connection, so the broker adds a hop to opening a connection but none to what it carries. On Linux, before it reads a byte of the VM&amp;rsquo;s, the child confines itself with Landlock and a seccomp filter to its logs and the Nix cache, with no connection of its own, no unix socket and no program to run, and on macOS a Seatbelt profile does the same (&lt;a href="#the-childs-sandbox"&gt;the child&amp;rsquo;s sandbox&lt;/a&gt;). So a child that a VM took over can&amp;rsquo;t read your files, reach an ssh master&amp;rsquo;s socket or connect to this machine&amp;rsquo;s loopback. &lt;a href="https://next.devvm.dev/docs/internals/processes/#a-vms-proxy"&gt;Processes&lt;/a&gt; has what each holds, reads and writes, and &lt;a href="https://next.devvm.dev/docs/contributing/design/#the-proxys-broker"&gt;the proxy&amp;rsquo;s broker&lt;/a&gt; has the protocol and its threat check. The one other way out of the VM is the &lt;a href="https://next.devvm.dev/docs/internals/ports/#links-between-vms"&gt;links&lt;/a&gt; you add to it, which this machine carries over ssh to the ports your other VMs publish, so they don&amp;rsquo;t use the VM&amp;rsquo;s network. The proxy is a second entrance to those links, for the VM&amp;rsquo;s HTTP clients (&lt;a href="#links-through-the-proxy"&gt;links through the proxy&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Other programs on the host can also reach that port, so the port alone doesn&amp;rsquo;t identify the VM. Every request must carry the VM&amp;rsquo;s password in &lt;code&gt;Proxy-Authorization&lt;/code&gt;, with the user &lt;code&gt;devvm&lt;/code&gt;, or it gets &lt;code&gt;407&lt;/code&gt;. Each VM has its own random password in its proxy settings. The proxy reads the password from its config, a file only you can read, never from its arguments, which other users can see, and it refuses to start without one (&lt;a href="#devvm-_proxy"&gt;devvm _proxy&lt;/a&gt;). The VM&amp;rsquo;s settings also get the password through files (&lt;a href="https://next.devvm.dev/docs/internals/lima/#a-lima-home-of-its-own"&gt;Lima&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;For each connection, the proxy does the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It sends a request for one of the VM&amp;rsquo;s own links to that link before any rule, and passes its bytes on as they are (&lt;a href="#links-through-the-proxy"&gt;links through the proxy&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;It checks &lt;code&gt;CONNECT host:port&lt;/code&gt; and absolute-form requests (&lt;code&gt;GET http://host/…&lt;/code&gt;) against the VM&amp;rsquo;s &lt;a href="#policy-files"&gt;policy files&lt;/a&gt;, and then tunnels or forwards the allowed ones untouched.&lt;/li&gt;
&lt;li&gt;It takes only host names, made of letters, digits, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;_&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt;, and addresses. It lowercases a name and drops one trailing dot, and the name that&amp;rsquo;s left may have no empty label, so &lt;code&gt;evil.test..&lt;/code&gt;, &lt;code&gt;evil..test&lt;/code&gt; and &lt;code&gt;.evil.test&lt;/code&gt; get &lt;code&gt;400&lt;/code&gt; too, because a company proxy that drops trailing dots would otherwise reach a host that a deny of &lt;code&gt;evil.test&lt;/code&gt; never matched. It lowercases only ASCII, so a name with any other character keeps that character and gets &lt;code&gt;400&lt;/code&gt;, because Unicode&amp;rsquo;s case folding turns some letters into ASCII ones, such as the Kelvin sign into &lt;code&gt;k&lt;/code&gt;, so the host it judged wouldn&amp;rsquo;t be the one the VM named. An address is bare, or an IPv6 address in one pair of brackets, so &lt;code&gt;[evil.com]:443&lt;/code&gt;, &lt;code&gt;[1.2.3.4]:443&lt;/code&gt; and a stray bracket get &lt;code&gt;400&lt;/code&gt; too. An IPv6 address with a zone, such as &lt;code&gt;[fe80::1%en0]&lt;/code&gt;, gets &lt;code&gt;400&lt;/code&gt;, and so does one with an empty zone. An address keeps its trailing dot, because the dot can only be its zone&amp;rsquo;s, and dropping it would leave an empty zone, which Go&amp;rsquo;s address parser reads as no address but a resolver may read as the address alone. Anything else gets &lt;code&gt;400&lt;/code&gt; before the policy or the log sees it. Everything else that reads a host reads it in the same form: a rule&amp;rsquo;s host, a secret&amp;rsquo;s hosts, &lt;code&gt;NO_PROXY&lt;/code&gt;, &lt;code&gt;devvm network lock&lt;/code&gt;&amp;rsquo;s risks and ticks, a secret&amp;rsquo;s &lt;code&gt;--host&lt;/code&gt;, an MCP server&amp;rsquo;s host, &lt;code&gt;--from&lt;/code&gt;&amp;rsquo;s registry and a partial clone&amp;rsquo;s remotes.&lt;/li&gt;
&lt;li&gt;It refuses &lt;code&gt;devvm.proxy&lt;/code&gt;, its own domain, and any name under it, in a &lt;code&gt;CONNECT&lt;/code&gt; and as a host, with &lt;code&gt;403&lt;/code&gt;, before the links, the policy or a company proxy see the name, on every tier. Only a request in absolute form for &lt;code&gt;http://devvm.proxy/&lt;/code&gt; itself reaches its endpoints, and &lt;code&gt;CONNECT transparent.devvm.proxy:PORT&lt;/code&gt; is &lt;a href="#tools-that-skip-the-proxy"&gt;transparent mode&lt;/a&gt;&amp;rsquo;s. It refuses the stand-in address, &lt;code&gt;198.18.0.1&lt;/code&gt;, with a reason that says the tool resolved the name itself.&lt;/li&gt;
&lt;li&gt;It resolves names itself and dials the addresses it checked, through its broker, which checks each address again before it connects (&lt;a href="#the-childs-sandbox"&gt;the child&amp;rsquo;s sandbox&lt;/a&gt;). It looks each name up absolute, with a trailing dot, so this machine&amp;rsquo;s resolver never adds its DNS search domain, which macOS takes from the network&amp;rsquo;s settings and Linux from &lt;code&gt;/etc/resolv.conf&lt;/code&gt;&amp;rsquo;s &lt;code&gt;search&lt;/code&gt;. Otherwise, with &lt;code&gt;api.corp.example.com&lt;/code&gt; denied and &lt;code&gt;**&lt;/code&gt; allowing the rest, &lt;code&gt;CONNECT api:443&lt;/code&gt; would reach &lt;code&gt;api.corp.example.com&lt;/code&gt;, a name that no rule judged, and so would &lt;code&gt;api.eu&lt;/code&gt; reach &lt;code&gt;api.eu.corp.example.com&lt;/code&gt; when &lt;code&gt;api.eu&lt;/code&gt; itself has no address. It refuses the host&amp;rsquo;s own addresses and internal ones unless a rule names the address. Internal addresses are loopback, private, link-local, multicast, unspecified, CGNAT &lt;code&gt;100.64.0.0/10&lt;/code&gt; and the other ranges that aren&amp;rsquo;t the public internet, among them IPv4&amp;rsquo;s documentation ranges &lt;code&gt;192.0.2.0/24&lt;/code&gt;, &lt;code&gt;198.51.100.0/24&lt;/code&gt; and &lt;code&gt;203.0.113.0/24&lt;/code&gt; and the old 6to4 relays&amp;rsquo; &lt;code&gt;192.88.99.0/24&lt;/code&gt;, and IPv6&amp;rsquo;s Teredo &lt;code&gt;2001::/32&lt;/code&gt;, documentation &lt;code&gt;2001:db8::/32&lt;/code&gt; and &lt;code&gt;3fff::/20&lt;/code&gt;, discard-only &lt;code&gt;100::/64&lt;/code&gt;, benchmarking &lt;code&gt;2001:2::/48&lt;/code&gt;, ORCHID &lt;code&gt;2001:10::/28&lt;/code&gt; and ORCHIDv2 &lt;code&gt;2001:20::/28&lt;/code&gt;, SRv6 &lt;code&gt;5f00::/16&lt;/code&gt; and IPv4-translated &lt;code&gt;::ffff:0:a.b.c.d&lt;/code&gt;. An address with an IPv6 zone is also internal, whatever its address, because a zone ties it to one of this machine&amp;rsquo;s links. An address with an IPv4 address in it counts as that IPv4 address, both a NAT64 address &lt;code&gt;64:ff9b::a.b.c.d&lt;/code&gt; and a 6to4 address in &lt;code&gt;2002::/16&lt;/code&gt;, such as &lt;code&gt;2002:a00:1::1&lt;/code&gt; for &lt;code&gt;10.0.0.1&lt;/code&gt;, and the 6to4 network, a &lt;code&gt;/48&lt;/code&gt;, of one of the host&amp;rsquo;s own 6to4 addresses counts as the host&amp;rsquo;s, because the machines on its LAN share it. A deny for an IPv4 address covers both forms. An allow for an IPv4 address covers its NAT64 form, which this network&amp;rsquo;s own translator carries, but not its 6to4 form, because 6to4 traffic goes through relays that anyone may run, so a 6to4 address is allowed only by a rule that names it. A Teredo address holds its IPv4 addresses scrambled, and the proxy doesn&amp;rsquo;t read them, so a broad IPv6 allow such as &lt;code&gt;::/0&lt;/code&gt; lets in the Teredo form of a denied IPv4 address.&lt;/li&gt;
&lt;li&gt;It requires a TLS ClientHello in a tunnel to name the &lt;code&gt;CONNECT&lt;/code&gt; host in its SNI, in ASCII, letters&amp;rsquo; case aside. The proxy doesn&amp;rsquo;t see the &lt;code&gt;Host&lt;/code&gt; inside the encrypted traffic, so a CDN that routes by it can reach other sites it serves.&lt;/li&gt;
&lt;li&gt;For a host with a bound secret, it replaces the placeholder in one header with the real value, as &lt;a href="#how-the-proxy-puts-them-in"&gt;how the proxy puts them in&lt;/a&gt; describes.&lt;/li&gt;
&lt;li&gt;For a host whose rules narrow it to some methods or paths, it decrypts the host&amp;rsquo;s HTTPS and checks each request, as &lt;a href="#requests-by-method-and-path"&gt;requests by method and path&lt;/a&gt; describes. Everything else passes unread.&lt;/li&gt;
&lt;li&gt;It carries at most 1024 &lt;code&gt;CONNECT&lt;/code&gt; tunnels, holds at most 2048 connections of every kind and has at most 2048 requests to hosts under way at once for the VM, as described below.&lt;/li&gt;
&lt;li&gt;It logs every decision (&lt;a href="#log-files"&gt;log files&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A &lt;code&gt;CONNECT&lt;/code&gt; tunnel meets the proxy&amp;rsquo;s checks in this order:&lt;/p&gt;
&lt;div class="devvm-diagram" style="contain-intrinsic-block-size: auto 1778px; --devvm-diagram-width: 751px"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" class="pele pele-flowchart" viewBox="0 0 751 1778" width="751" height="1778" style="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,&amp;quot;Departure Mono&amp;quot;, monospace);font:14px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,&amp;quot;Departure Mono&amp;quot;, monospace)" fill="var(--_fg)" role="graphics-document document" aria-roledescription="flowchart" aria-labelledby="d7e25dc882f151683--title" aria-describedby="d7e25dc882f151683--desc"&gt;&lt;title id="d7e25dc882f151683--title"&gt;The proxy's checks on a CONNECT tunnel&lt;/title&gt;&lt;desc id="d7e25dc882f151683--desc"&gt;The proxy checks a CONNECT tunnel from the VM in order: the VM's password, else 407, a host name or an address, else 400, and fewer than 1024 tunnels open, else 503. transparent.devvm.proxy takes the host from its first bytes, TLS's SNI or each HTTP Host, and closes the tunnel when there's none, and devvm.proxy, its names and 198.18.0.1 get 403. One of the VM's links goes to the link's socket untouched, and a transparent connection to one is refused. Any other host must be on the allowlist and not denied, else 403, which a transparent TLS connection gets over the VM's CA, and it must be public and not this machine's or an address a rule names, and on port 443 when rules judge its requests, else 403. A bound host, on port 443, or one whose requests are judged, is intercepted with the VM's CA, where each request must name the host, else 421, and be allowed by the rules, else 403, before its placeholder is swapped for the real value. Any other tunnel passes untouched when its TLS SNI names the CONNECT host, or it isn't TLS.&lt;/desc&gt;&lt;g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round"&gt;&lt;g class="pele-edge" data-id="L_conn_pw_0"&gt;&lt;path d="M307.05,53L307.05,91"/&gt;&lt;path class="pele-marker" d="M307.05,98L303.69,90L310.41,90Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_pw_name_0"&gt;&lt;path d="M307.05,158L307.05,196"/&gt;&lt;path class="pele-marker" d="M307.05,203L303.69,195L310.41,195Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_name_room_0"&gt;&lt;path d="M307.05,263L307.05,301"/&gt;&lt;path class="pele-marker" d="M307.05,308L303.69,300L310.41,300Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_room_reserved_0"&gt;&lt;path d="M307.05,368L307.05,406"/&gt;&lt;path class="pele-marker" d="M307.05,413L303.69,405L310.41,405Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_reserved_named0_0"&gt;&lt;path d="M228.14,458L228.14,464Q228.14,476 216.14,476L162.73,476Q150.73,476 150.73,488L150.73,531.5"/&gt;&lt;path class="pele-marker" d="M150.73,538.5L147.37,530.5L154.09,530.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_named0_link_0"&gt;&lt;path d="M150.73,616.5L150.73,627Q150.73,639 162.73,639L225.42,639Q237.05,639 237.05,650.63L237.05,654.5"/&gt;&lt;path class="pele-marker" d="M237.05,661.5L233.69,653.5L240.41,653.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_reserved_own_0"&gt;&lt;path d="M385.95,458L385.95,464Q385.95,476 397.95,476L451.36,476Q463.36,476 463.36,488L463.36,531.5"/&gt;&lt;path class="pele-marker" d="M463.36,538.5L460,530.5L466.72,530.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_own_link_0"&gt;&lt;path d="M463.36,616.5L463.36,627Q463.36,639 451.36,639L388.67,639Q377.05,639 377.05,650.63L377.05,654.5"/&gt;&lt;path class="pele-marker" d="M377.05,661.5L373.69,653.5L380.41,653.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_link_linked_0"&gt;&lt;path d="M237.05,706.5L237.05,712.5Q237.05,724.5 225.05,724.5L156.05,724.5Q144.05,724.5 144.05,736.5L144.05,789"/&gt;&lt;path class="pele-marker" d="M144.05,796L140.69,788L147.41,788Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_link_allow_0"&gt;&lt;path d="M377.05,706.5L377.05,712.5Q377.05,724.5 389.05,724.5L458.05,724.5Q470.05,724.5 470.05,736.5L470.05,780"/&gt;&lt;path class="pele-marker" d="M470.05,787L466.69,779L473.41,779Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_allow_floor_0"&gt;&lt;path d="M470.05,883L470.05,921"/&gt;&lt;path class="pele-marker" d="M470.05,928L466.69,920L473.41,920Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_floor_narrowed_0"&gt;&lt;path d="M470.05,1006L470.05,1044"/&gt;&lt;path class="pele-marker" d="M470.05,1051L466.69,1043L473.41,1043Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_narrowed_bound_0"&gt;&lt;path d="M470.05,1147L470.05,1185"/&gt;&lt;path class="pele-marker" d="M470.05,1192L466.69,1184L473.41,1184Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_bound_sni_0"&gt;&lt;path d="M349.36,1252L349.36,1312"/&gt;&lt;path class="pele-marker" d="M349.36,1319L346,1311L352.72,1311Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_sni_tunnel_0"&gt;&lt;path d="M349.36,1397L349.36,1473.5"/&gt;&lt;path class="pele-marker" d="M349.36,1480.5L346,1472.5L352.72,1472.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_bound_intercept_0"&gt;&lt;path d="M590.73,1252L590.73,1321"/&gt;&lt;path class="pele-marker" d="M590.73,1328L587.37,1320L594.09,1320Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_intercept_named_0"&gt;&lt;path d="M590.73,1388L590.73,1457"/&gt;&lt;path class="pele-marker" d="M590.73,1464L587.37,1456L594.09,1456Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_named_rules_0"&gt;&lt;path d="M590.73,1542L590.73,1580"/&gt;&lt;path class="pele-marker" d="M590.73,1587L587.37,1579L594.09,1579Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_rules_swap_0"&gt;&lt;path d="M590.73,1665L590.73,1703"/&gt;&lt;path class="pele-marker" d="M590.73,1710L587.37,1702L594.09,1702Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edge-labels" font-size="14"&gt;&lt;g class="pele-edge-label" data-id="L_reserved_named0_0"&gt;&lt;rect x="133.36" y="496" width="34.73" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="150.73" y="509.2" text-anchor="middle"&gt;yes&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_reserved_own_0"&gt;&lt;rect x="450.45" y="496" width="25.82" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="463.36" y="509.2" text-anchor="middle"&gt;no&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_link_linked_0"&gt;&lt;rect x="126.68" y="744.5" width="34.73" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="144.05" y="757.7" text-anchor="middle"&gt;yes&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_link_allow_0"&gt;&lt;rect x="457.14" y="744.5" width="25.82" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="470.05" y="757.7" text-anchor="middle"&gt;no&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_bound_sni_0"&gt;&lt;rect x="336.45" y="1276.5" width="25.82" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="349.36" y="1289.7" text-anchor="middle"&gt;no&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_sni_tunnel_0"&gt;&lt;rect x="278.55" y="1421.5" width="141.64" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="349.36" y="1434.7" text-anchor="middle"&gt;yes, or not TLS&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_bound_intercept_0"&gt;&lt;rect x="573.36" y="1276.5" width="34.73" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="590.73" y="1289.7" text-anchor="middle"&gt;yes&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-nodes"&gt;&lt;g class="pele-node pele-shape-rect" data-id="conn" transform="translate(307.05,30.5)"&gt;&lt;rect x="-147.18" y="-22.5" width="294.36" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;CONNECT host:port from the VM&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="pw" transform="translate(307.05,128)"&gt;&lt;rect x="-98.18" y="-30" width="196.36" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;the VM's password?&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;no: 407&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="name" transform="translate(307.05,233)"&gt;&lt;rect x="-133.82" y="-30" width="267.64" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;a host name or an address?&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;no: 400&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="room" transform="translate(307.05,338)"&gt;&lt;rect x="-147.18" y="-30" width="294.36" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;fewer than 1024 tunnels open?&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;no: 503&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-hex" data-id="reserved" transform="translate(307.05,435.5)"&gt;&lt;polygon points="-124.91,-22.5 124.91,-22.5 136.16,0 124.91,22.5 -124.91,22.5 -136.16,0" fill="var(--_s)" stroke="var(--_b)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;transparent.devvm.proxy?&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="named0" transform="translate(150.73,577.5)"&gt;&lt;rect x="-142.73" y="-39" width="285.45" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;the host in its first bytes:&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;TLS's SNI, or each HTTP Host&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;none: closed&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-hex" data-id="link" transform="translate(307.05,684)"&gt;&lt;polygon points="-116,-22.5 116,-22.5 127.25,0 116,22.5 -116,22.5 -127.25,0" fill="var(--_s)" stroke="var(--_b)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;one of the VM's links?&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="own" transform="translate(463.36,577.5)"&gt;&lt;rect x="-124.91" y="-39" width="249.82" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;devvm.proxy or under it,&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;or 198.18.0.1?&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;yes: 403&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="linked" transform="translate(144.05,835)"&gt;&lt;rect x="-116" y="-39" width="232" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;the link's socket,&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;tunneled untouched&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;(transparent: refused)&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="allow" transform="translate(470.05,835)"&gt;&lt;rect x="-165" y="-48" width="330" height="96" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-22.1"&gt;on the allowlist, and not denied?&lt;/tspan&gt;&lt;tspan x="0" y="-4.1"&gt;no: 403&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;(transparent TLS: 403&lt;/tspan&gt;&lt;tspan x="0" y="31.9"&gt;over the VM's CA)&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="floor" transform="translate(470.05,967)"&gt;&lt;rect x="-151.64" y="-39" width="303.27" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;public and not this machine's,&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;or an address a rule names?&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;no: 403&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="narrowed" transform="translate(470.05,1099)"&gt;&lt;rect x="-124.91" y="-48" width="249.82" height="96" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-22.1"&gt;rules by method and path&lt;/tspan&gt;&lt;tspan x="0" y="-4.1"&gt;judge its requests:&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;on port 443?&lt;/tspan&gt;&lt;tspan x="0" y="31.9"&gt;no: 403&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-hex" data-id="bound" transform="translate(470.05,1222)"&gt;&lt;polygon points="-133.82,-30 133.82,-30 148.82,0 133.82,30 -133.82,30 -148.82,0" fill="var(--_s)" stroke="var(--_b)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;a bound host, on port 443,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;or its requests judged?&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="sni" transform="translate(349.36,1358)"&gt;&lt;rect x="-93.73" y="-39" width="187.45" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;its TLS SNI names&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;the CONNECT host?&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;no: closed&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="tunnel" transform="translate(349.36,1503)"&gt;&lt;rect x="-98.18" y="-22.5" width="196.36" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;tunneled untouched&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="intercept" transform="translate(590.73,1358)"&gt;&lt;rect x="-93.73" y="-30" width="187.45" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;intercepted, with&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;the VM's CA&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="named" transform="translate(590.73,1503)"&gt;&lt;rect x="-98.18" y="-39" width="196.36" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;each request names&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;the host?&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;no: 421&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="rules" transform="translate(590.73,1626)"&gt;&lt;rect x="-151.64" y="-39" width="303.27" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;each request allowed by&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;the rules, by method and path?&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;no: 403&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="swap" transform="translate(590.73,1740)"&gt;&lt;rect x="-120.45" y="-30" width="240.91" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;the placeholder swapped&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;for the real value&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/div&gt;&lt;p&gt;A tunnel that the proxy doesn&amp;rsquo;t intercept carries the bytes both ways as they are. When the VM finishes sending, the proxy closes its side of the connection to the far end, so the far end sees the end of what the VM sent and can still answer. The tunnel ends when the far end&amp;rsquo;s bytes end, or when the proxy can&amp;rsquo;t pass them on because the VM&amp;rsquo;s connection has gone, and then the proxy closes both connections. In a tunnel to a host the policy allows, the far end&amp;rsquo;s bytes reach the VM at once, so a protocol whose server speaks first, such as SMTP, gets its greeting before the VM sends anything. The VM&amp;rsquo;s bytes wait until the proxy has checked them: when the first one starts a TLS record, the proxy reads the whole ClientHello and checks its SNI before any of it reaches the far end, and any other first byte passes at once. The VM may wait as long as it likes before its first byte, as on any open tunnel, but once a ClientHello starts, it must arrive whole, in one record of at most 16 KiB and 256 bytes, within 10 seconds, or the proxy closes the tunnel and logs why. The proxy reads no record past that length, so a VM can&amp;rsquo;t make it hold 64 KiB for each of its tunnels, nor hold a slot by sending its ClientHello a byte at a time.&lt;/p&gt;
&lt;p&gt;The proxy carries at most 1024 &lt;code&gt;CONNECT&lt;/code&gt; tunnels for the VM at once, including tunnels to links and intercepted ones, from the request until the tunnel ends. That&amp;rsquo;s four times the 256 connections a browser such as Chrome keeps open at most, and many times what a package manager opens, such as npm&amp;rsquo;s 15 sockets or uv&amp;rsquo;s 50 downloads, so several installs and builds at once fit. Each tunnel holds two of the proxy&amp;rsquo;s file descriptors, so the limit keeps a VM that opens tunnels without end from taking them all. A &lt;code&gt;CONNECT&lt;/code&gt; past the limit gets &lt;code&gt;503&lt;/code&gt;, which a client may retry, and the reason &lt;code&gt;1024 tunnels open already&lt;/code&gt;, logged as a refused block, so neither the VM&amp;rsquo;s prompt nor &lt;code&gt;devvm network log&lt;/code&gt; suggests an allow rule. The proxy&amp;rsquo;s own log, &lt;code&gt;proxy.log&lt;/code&gt;, says when the VM reaches the limit, once until a tunnel ends.&lt;/p&gt;
&lt;p&gt;The proxy also holds at most 2048 of the VM&amp;rsquo;s connections at once, of every kind, which counts plain HTTP requests in absolute form, idle kept-alive connections and a request that goes on after its client has gone, as well as tunnels. That&amp;rsquo;s twice the tunnels&amp;rsquo; limit, so a &lt;code&gt;CONNECT&lt;/code&gt; past the tunnels&amp;rsquo; limit still gets its &lt;code&gt;503&lt;/code&gt; first. A connection counts from its first request with the VM&amp;rsquo;s password, and a request on a connection past the limit gets &lt;code&gt;503&lt;/code&gt;, after which the proxy closes the connection. On a Linux host, the limit of 256 connections that QEMU carries to the proxy at once comes first, and a connection past it gets a &lt;code&gt;503&lt;/code&gt; before it reaches the proxy (&lt;a href="https://next.devvm.dev/docs/internals/processes/#the-qemu-wrapper-and-its-keeper"&gt;the QEMU wrapper&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Every program on this machine can reach the proxy&amp;rsquo;s port, an open VM&amp;rsquo;s included, so a connection that hasn&amp;rsquo;t sent the VM&amp;rsquo;s password yet never takes the VM&amp;rsquo;s room. Such connections wait in a pool of their own, at most 128 at once, and one more closes the one that has waited longest, which a real client rarely is, because it sends its request at once. Holding connections open can&amp;rsquo;t take the VM&amp;rsquo;s room, but a program that opens connections as fast as this machine accepts them still slows the proxy for the VM, through the system&amp;rsquo;s queue of connections waiting to be accepted (&lt;a href="https://next.devvm.dev/docs/contributing/design/#transparent-mode"&gt;design&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The proxy also has at most 2048 requests to hosts under way at once, plain HTTP&amp;rsquo;s and those inside intercepted tunnels together. Each is a connection of its own to the host, so the tunnels&amp;rsquo; HTTP/2 requests, 100 at once in each, can&amp;rsquo;t add up to more connections than the proxy can open. A request past the limit gets &lt;code&gt;503&lt;/code&gt;, which a client may retry.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;proxy.log&lt;/code&gt; says when the VM reaches either limit, once a minute at most (&lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#rogue-agents"&gt;attack vectors&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Nothing bounds how long a request or a tunnel lasts, so a long download, a WebSocket, a model&amp;rsquo;s slow stream and server-sent events go on for as long as they take. The proxy bounds what a connection makes it hold instead:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A connection to the proxy waits at most 10 minutes for its next request, as the HTTP inside an intercepted tunnel or a transparent connection does, which is longer than a client keeps one idle.&lt;/li&gt;
&lt;li&gt;A request without the VM&amp;rsquo;s password gets &lt;code&gt;407&lt;/code&gt;, and the proxy closes its connection after it, so nothing without the password keeps a connection open.&lt;/li&gt;
&lt;li&gt;A request takes at most 64 KiB of headers, including in an intercepted tunnel, a transparent connection and the &lt;code&gt;403&lt;/code&gt; page&amp;rsquo;s TLS connection.&lt;/li&gt;
&lt;li&gt;HTTP/2 inside an intercepted tunnel or a transparent connection carries at most 100 requests at once, which is what most servers allow, and each is a request the proxy makes to the host.&lt;/li&gt;
&lt;li&gt;A plain HTTP request in absolute form goes on when its client half-closes after sending, because some clients do, so the proxy can&amp;rsquo;t tell from that alone that the client has gone. The request goes on while its answer keeps coming, and once its client has stopped sending and a minute passes with nothing to pass on, the proxy ends it, so a client that went away doesn&amp;rsquo;t leave a request waiting on a host that never answers.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-hextra-search-id="links-through-the-proxy"&gt;Links through the proxy&lt;span class="hx:absolute hx:-mt-20" id="links-through-the-proxy"&gt;&lt;/span&gt;
&lt;a href="#links-through-the-proxy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A VM&amp;rsquo;s &lt;code&gt;NO_PROXY&lt;/code&gt; names only the VM itself, so an HTTP client that uses the VM&amp;rsquo;s proxy settings sends a request for a link, such as &lt;code&gt;http://db:5432/&lt;/code&gt;, to the proxy. A running VM can&amp;rsquo;t take a new environment, so the proxy carries those requests itself, and a link added while the VM runs works for every HTTP client at once.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm _links&lt;/code&gt; writes every link the VM has, carried or not, to a list, &lt;code&gt;links.json&lt;/code&gt; in the VM&amp;rsquo;s run folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/&lt;/code&gt;, mode 600 in a folder of mode 700, whenever they change or the file is gone. Each entry has the link&amp;rsquo;s names (&lt;code&gt;NAME&lt;/code&gt; and &lt;code&gt;NAME.devvm.internal&lt;/code&gt;), its address and port in the VM, its target, and its socket on this machine. The list stays when &lt;code&gt;devvm _links&lt;/code&gt; ends, and devvm removes it with the VM, so a link that isn&amp;rsquo;t carried, which has no socket, is refused rather than asked of the rules. devvm puts the list&amp;rsquo;s path in the proxy&amp;rsquo;s config as &lt;code&gt;links&lt;/code&gt;, and its run folder, where the links&amp;rsquo; sockets are, as &lt;code&gt;link_sockets&lt;/code&gt;. The proxy checks the list for every request and reads it again when it has changed, as it does the policy files. A list it can&amp;rsquo;t read has no links, which its log says once. The list must be a regular file, not a symbolic link, that only you can write, and at most 1 MiB.&lt;/p&gt;
&lt;p&gt;The proxy checks a request&amp;rsquo;s host against the list after the VM&amp;rsquo;s password and before any rule, as it does for &lt;code&gt;devvm.proxy&lt;/code&gt;. It lowercases the host and drops one trailing dot, and then a host and port match only an entry that names them exactly, so &lt;code&gt;DB.:5432&lt;/code&gt; matches &lt;code&gt;db:5432&lt;/code&gt;, while &lt;code&gt;db..:5432&lt;/code&gt;, &lt;code&gt;db.devvm:5432&lt;/code&gt; and &lt;code&gt;127.77.0.1:5432&lt;/code&gt; don&amp;rsquo;t. The request names a host and a port, never a socket. An entry counts only when its socket is the one that &lt;code&gt;devvm _links&lt;/code&gt; names for this VM&amp;rsquo;s link at that address and port, in the run folder of devvm&amp;rsquo;s data folder, so the proxy never connects to another VM&amp;rsquo;s link or to any other socket, whatever the list holds. Its address must also be in &lt;code&gt;127.77.0.0/16&lt;/code&gt;. Any other name under &lt;code&gt;devvm.internal&lt;/code&gt; is refused with &lt;code&gt;403&lt;/code&gt; and logged as a refused block, whatever the rules allow, so the rules, the host&amp;rsquo;s resolver and a company proxy never see one. A host and port on no entry are otherwise the policy&amp;rsquo;s, as before.&lt;/p&gt;
&lt;p&gt;For a match, the proxy&amp;rsquo;s broker finds the host and port in its own read of the list again, connects to that link&amp;rsquo;s socket and hands the connection to the child, so the child never reaches devvm&amp;rsquo;s run folder, where every VM&amp;rsquo;s link sockets are. It&amp;rsquo;s the same socket that the link&amp;rsquo;s remote forward reaches, so &lt;code&gt;devvm _links&lt;/code&gt; checks the connection as it checks every other (&lt;a href="https://next.devvm.dev/docs/internals/ports/#links-between-vms"&gt;each connection&lt;/a&gt;), and the 256-connection cap counts both. A &lt;code&gt;CONNECT&lt;/code&gt; is tunneled as it is, with no SNI check and no interception, and an absolute-form request, such as &lt;code&gt;GET http://db:5432/&lt;/code&gt;, goes to the socket in origin form, without &lt;code&gt;Proxy-Authorization&lt;/code&gt; or &lt;code&gt;Proxy-Connection&lt;/code&gt;, over a new connection for each request, which ends when the client gives up the request. A kept-alive connection to the proxy that asks for a link and then for another host has each request handled on its own. HTTPS in absolute form gets &lt;code&gt;400&lt;/code&gt;, because &lt;code&gt;CONNECT&lt;/code&gt; carries it. The proxy puts no secret into a link&amp;rsquo;s connection, even when a secret&amp;rsquo;s hosts would match the link&amp;rsquo;s name, and its rules don&amp;rsquo;t apply, so &lt;code&gt;devvm network deny db&lt;/code&gt; doesn&amp;rsquo;t stop the link &lt;code&gt;db&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The proxy logs nothing for a link&amp;rsquo;s connection that it passes on, because &lt;code&gt;devvm _links&lt;/code&gt; logs it as &lt;code&gt;link&lt;/code&gt;, once. When the socket doesn&amp;rsquo;t answer, because the link was removed since the proxy read the list or &lt;code&gt;devvm _links&lt;/code&gt; isn&amp;rsquo;t running, the proxy answers &lt;code&gt;502&lt;/code&gt; and logs &lt;code&gt;link_refused&lt;/code&gt; with the reason &lt;code&gt;not carried&lt;/code&gt;. A socket whose backlog is full refuses a connection, so the proxy tries again for under a second.&lt;/p&gt;
&lt;h3 data-hextra-search-id="through-a-company-proxy"&gt;Through a company proxy&lt;span class="hx:absolute hx:-mt-20" id="through-a-company-proxy"&gt;&lt;/span&gt;
&lt;a href="#through-a-company-proxy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;When devvm starts a VM&amp;rsquo;s proxy, it reads &lt;code&gt;HTTPS_PROXY&lt;/code&gt;, &lt;code&gt;HTTP_PROXY&lt;/code&gt; and &lt;code&gt;NO_PROXY&lt;/code&gt; from its own environment, each in capitals first and then in lowercase, as Go&amp;rsquo;s clients do. When its environment sets neither &lt;code&gt;HTTPS_PROXY&lt;/code&gt; nor &lt;code&gt;HTTP_PROXY&lt;/code&gt;, it reads &lt;code&gt;config.toml&lt;/code&gt;&amp;rsquo;s &lt;code&gt;[proxy]&lt;/code&gt; table instead, its &lt;code&gt;https&lt;/code&gt;, &lt;code&gt;http&lt;/code&gt; and &lt;code&gt;no-proxy&lt;/code&gt;, and never a mix of the two. It writes them into the proxy&amp;rsquo;s config, &lt;code&gt;proxy.json&lt;/code&gt; in the VM&amp;rsquo;s run folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/&lt;/code&gt;, as &lt;code&gt;upstream&lt;/code&gt;, so a password in the environment&amp;rsquo;s URL is in a file only you can read and in no process&amp;rsquo;s arguments. devvm checks the settings first: a proxy URL is &lt;code&gt;http://user:password@host:port&lt;/code&gt;, or &lt;code&gt;host:port&lt;/code&gt; alone, and a proxy without a port is on port 80. devvm refuses an &lt;code&gt;https://&lt;/code&gt; or &lt;code&gt;socks5://&lt;/code&gt; proxy (&lt;code&gt;upstream_proxy_scheme&lt;/code&gt;) and a setting it can&amp;rsquo;t read (&lt;code&gt;upstream_proxy_invalid&lt;/code&gt;), so a VM doesn&amp;rsquo;t start until you change it.&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;config.toml&lt;/code&gt; URL never holds a password (&lt;code&gt;proxy_password_in_config&lt;/code&gt;, as it&amp;rsquo;s read), because people copy that file between machines and keep it with their dotfiles. When its URL names a user, &lt;code&gt;upstream&lt;/code&gt; gets &lt;code&gt;&amp;quot;secret&amp;quot;: &amp;quot;proxy&amp;quot;&lt;/code&gt;, and the proxy looks the &lt;code&gt;proxy&lt;/code&gt; secret up as it starts, through the same lookup as the &lt;a href="#where-secrets-are-saved"&gt;secrets it puts in&lt;/a&gt;, the Keychain or &lt;code&gt;~/.local/share/devvm/secrets/proxy&lt;/code&gt;, and uses it as the password of each URL that names a user and none of its own. So &lt;code&gt;proxy.json&lt;/code&gt; never holds that password. A proxy whose lookup fails doesn&amp;rsquo;t start, and devvm checks that the secret is saved before it makes a new VM, starts a VM&amp;rsquo;s proxy, or builds an image or the shared tools (&lt;code&gt;proxy_password_missing&lt;/code&gt;), and before it stops a running VM to start it again, as &lt;code&gt;devvm restart&lt;/code&gt; does, so a refused restart leaves the VM running. It also checks before it changes a running VM&amp;rsquo;s tier between &lt;code&gt;internet&lt;/code&gt;, &lt;code&gt;allowlist&lt;/code&gt; and &lt;code&gt;none&lt;/code&gt;, which the VM&amp;rsquo;s proxy applies at once, so the VM&amp;rsquo;s state never names a tier that its proxy doesn&amp;rsquo;t enforce. Each of these is one check of the company proxy&amp;rsquo;s settings, which devvm runs with the check of your CAs before a VM is made, stopped to start again, or given another confined tier while it runs (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;devvm&amp;rsquo;s own requests on this machine go through the same company proxy. They are the download of its own mise, the list of Ubuntu&amp;rsquo;s cloud images, and the registries &lt;code&gt;--from&lt;/code&gt; asks for digests. When the environment sets the proxy, their clients use Go&amp;rsquo;s own environment proxy. When &lt;code&gt;config.toml&lt;/code&gt; sets it, devvm&amp;rsquo;s route to the company proxy is their transport&amp;rsquo;s proxy. At the first request, the route looks the &lt;code&gt;proxy&lt;/code&gt; secret up and puts it in each URL that names a user and none of its own. It routes each request as a VM&amp;rsquo;s proxy does: &lt;code&gt;HTTPS_PROXY&lt;/code&gt;&amp;rsquo;s for HTTPS, &lt;code&gt;HTTP_PROXY&lt;/code&gt;&amp;rsquo;s for plain HTTP, and directly for &lt;code&gt;NO_PROXY&lt;/code&gt;&amp;rsquo;s hosts, &lt;code&gt;localhost&lt;/code&gt; and loopback addresses. Go sends the user and password only to the company proxy, in &lt;code&gt;Proxy-Authorization&lt;/code&gt;. A missing password fails the request without a retry. The mise that devvm runs on this machine inherits devvm&amp;rsquo;s environment, so it uses the environment&amp;rsquo;s proxy as it is. With &lt;code&gt;config.toml&lt;/code&gt;&amp;rsquo;s proxy, devvm adds &lt;code&gt;HTTPS_PROXY&lt;/code&gt;, &lt;code&gt;HTTP_PROXY&lt;/code&gt; and &lt;code&gt;NO_PROXY&lt;/code&gt; to mise&amp;rsquo;s environment, in capitals and in lowercase, with the password in each URL that names a user. mise takes a proxy&amp;rsquo;s password only in its URL, so its environment is the one place it can go. It&amp;rsquo;s never in mise&amp;rsquo;s arguments or in a file.&lt;/p&gt;
&lt;p&gt;A VM&amp;rsquo;s proxy refreshes Codex&amp;rsquo;s and opencode&amp;rsquo;s OAuth logins through the company proxy it sends the VM&amp;rsquo;s requests through, its &lt;code&gt;upstream&lt;/code&gt;, whether that came from the environment or from &lt;code&gt;config.toml&lt;/code&gt;. As it starts, it makes that upstream&amp;rsquo;s route for its own requests, with the &lt;code&gt;proxy&lt;/code&gt; secret it looked up as the password, as devvm makes the route for its own requests. It carries the route in each lookup&amp;rsquo;s context, and the login&amp;rsquo;s refresh takes it from there as its transport&amp;rsquo;s proxy. A VM&amp;rsquo;s proxy without an upstream sends the refresh directly, as it does the VM&amp;rsquo;s requests.&lt;/p&gt;
&lt;p&gt;An open VM&amp;rsquo;s proxy goes through the company proxy as a confined VM&amp;rsquo;s does. Its guest gets no proxy settings of devvm&amp;rsquo;s environment: Lima&amp;rsquo;s &lt;code&gt;propagateProxyEnv&lt;/code&gt; is off for every VM whose guest names devvm&amp;rsquo;s proxy, so neither the shell&amp;rsquo;s nor &lt;code&gt;config.toml&lt;/code&gt;&amp;rsquo;s password reaches the guest.&lt;/p&gt;
&lt;p&gt;devvm warns (&lt;code&gt;upstream_proxy_gone&lt;/code&gt;) when the config the VM&amp;rsquo;s proxy last started with has an &lt;code&gt;upstream&lt;/code&gt; and the one it starts it with now has none, as happens when a shell without the settings starts it.&lt;/p&gt;
&lt;p&gt;The proxy decides each request as it does without a company proxy, by the host name the VM asked for, and only then picks the way out:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A host that &lt;code&gt;NO_PROXY&lt;/code&gt; names, &lt;code&gt;localhost&lt;/code&gt;, a name under &lt;code&gt;.localhost&lt;/code&gt; and a loopback or unspecified address go directly, through the checks above.&lt;/li&gt;
&lt;li&gt;A tunnel, and the connection the proxy makes to a bound host to put a secret in, go through &lt;code&gt;HTTPS_PROXY&lt;/code&gt;&amp;rsquo;s proxy. The proxy sends &lt;code&gt;CONNECT host:port&lt;/code&gt; with the name the VM asked for, and &lt;code&gt;Proxy-Authorization: Basic&lt;/code&gt; from the URL&amp;rsquo;s user and password, and it reads the answer. Anything but &lt;code&gt;200&lt;/code&gt; refuses the VM&amp;rsquo;s request, naming the company proxy by its host and port. Over that tunnel, the proxy&amp;rsquo;s TLS connection to a bound host checks the server&amp;rsquo;s certificate against the system&amp;rsquo;s roots and the &lt;a href="#a-companys-ca"&gt;CAs in your CA folder&lt;/a&gt;, as it does directly.&lt;/li&gt;
&lt;li&gt;A plain HTTP request goes to &lt;code&gt;HTTP_PROXY&lt;/code&gt;&amp;rsquo;s proxy in absolute form, with its &lt;code&gt;Proxy-Authorization&lt;/code&gt; in place of the VM&amp;rsquo;s. The company proxy&amp;rsquo;s address in the request has no password, so no error the proxy logs holds one.&lt;/li&gt;
&lt;li&gt;Without &lt;code&gt;HTTPS_PROXY&lt;/code&gt; or &lt;code&gt;HTTP_PROXY&lt;/code&gt;, those requests go directly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;NO_PROXY&lt;/code&gt; is a comma-separated list, which the proxy reads as Go&amp;rsquo;s clients read it. In it, &lt;code&gt;*&lt;/code&gt; matches every host, and an address or a CIDR matches addresses. A name matches itself and its subdomains, while a name with a leading &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;*.&lt;/code&gt; matches only its subdomains. Any entry can end in a port, which limits it to that port, and an entry whose port no request has, such as &lt;code&gt;git.test:0&lt;/code&gt;, or whose port isn&amp;rsquo;t in plain decimal, such as &lt;code&gt;git.test:080&lt;/code&gt;, matches nothing. The proxy reads a name in &lt;code&gt;NO_PROXY&lt;/code&gt; as it reads the host of every request, lowercased in ASCII alone and without one trailing dot, so a name with a character that isn&amp;rsquo;t printable ASCII matches no host, because Unicode&amp;rsquo;s case folding would turn the Kelvin sign into &lt;code&gt;k&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The company proxy resolves the names it&amp;rsquo;s sent, so the proxy can&amp;rsquo;t hold it to the addresses it checked, and the floor changes for those requests. An address in the VM&amp;rsquo;s request is checked as before, and a host whose last label is all digits or starts with &lt;code&gt;0x&lt;/code&gt;, such as &lt;code&gt;127.1&lt;/code&gt;, gets &lt;code&gt;400&lt;/code&gt;, because a company proxy may read it as an address. For a name, the proxy asks this machine&amp;rsquo;s resolver, for at most three seconds, and refuses the request when any answer is internal or denied, unless a rule names the address. A name this machine can&amp;rsquo;t resolve, which is common behind a company proxy, goes to the company proxy unchecked when a rule names it, as itself or under &lt;code&gt;*.domain&lt;/code&gt;. When only &lt;code&gt;**&lt;/code&gt; allows it, the proxy refuses it with &lt;code&gt;403&lt;/code&gt;, and the event log says that this machine can&amp;rsquo;t resolve it and only &lt;code&gt;**&lt;/code&gt; allows it. The proxy reads at most 64 KiB of the company proxy&amp;rsquo;s answer to &lt;code&gt;CONNECT&lt;/code&gt;. &lt;a href="https://next.devvm.dev/docs/contributing/design/#a-company-proxy"&gt;The design note&lt;/a&gt; explains what that leaves open, which &lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#network"&gt;Attack vectors&lt;/a&gt; lists, and how builds reach the company proxy through a proxy of their own.&lt;/p&gt;
&lt;p&gt;The event log&amp;rsquo;s &lt;code&gt;upstream&lt;/code&gt; field names the company proxy, by host and port, for each tunnel and request that went through it, and &lt;code&gt;devvm network log&lt;/code&gt; adds &lt;code&gt;through host:port&lt;/code&gt; to the line. The proxy&amp;rsquo;s own log names both company proxies by host and port when it starts. Neither holds the user or the password.&lt;/p&gt;
&lt;h3 data-hextra-search-id="how-long-a-proxy-runs"&gt;How long a proxy runs&lt;span class="hx:absolute hx:-mt-20" id="how-long-a-proxy-runs"&gt;&lt;/span&gt;
&lt;a href="#how-long-a-proxy-runs" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The proxy exits when the VM&amp;rsquo;s Lima hostagent does, which it learns from the hostagent&amp;rsquo;s pid file, the VM&amp;rsquo;s lifeline (&lt;code&gt;lifeline&lt;/code&gt; in its config). The proxy starts before the VM, so it waits for the lifeline to name a process that runs. What the file held when the proxy started is an earlier start&amp;rsquo;s, and the proxy waits past it, but when a new start writes the file and its process is already gone, the proxy exits. Once it follows a start, it runs while the file holds what it held then and that process runs, so a VM started again gets a new proxy. If the hostagent never appears, the proxy exits 15 minutes after it started, and &lt;code&gt;devvm stop&lt;/code&gt; stops it at once. It&amp;rsquo;s the broker that follows the lifeline, and its child ends with it, as &lt;a href="https://next.devvm.dev/docs/internals/processes/#a-vms-proxy"&gt;processes&lt;/a&gt; describes. The broker closes the socket between them, the child stops listening, closes its connections and exits, and the broker kills a child that hasn&amp;rsquo;t ended 6 seconds later. A child that ends ends its broker, and neither starts the other again, so the VM has no network until devvm&amp;rsquo;s next command starts its proxy again, as after any proxy&amp;rsquo;s crash. &lt;code&gt;devvm stop&lt;/code&gt;, &lt;code&gt;devvm rm&lt;/code&gt; and &lt;code&gt;devvm gc --orphans&lt;/code&gt; also stop a child that outlived its broker, by &lt;code&gt;run/proxy-child.pid&lt;/code&gt; and its arguments.&lt;/p&gt;
&lt;p&gt;A VM that starts again gets a new proxy on the same port. A running VM also gets a new proxy when the config devvm would start it with differs from the one it started with, which devvm tells by the SHA-256 of each. The config holds everything that, changed, starts the proxy again: the VM&amp;rsquo;s list of policies, the VM&amp;rsquo;s CA and the next one, by the SHA-256 of each certificate, so a CA that was replaced counts, the SHA-256 of devvm&amp;rsquo;s binary, so a proxy from another devvm binary counts, the &lt;a href="#a-companys-ca"&gt;CAs in your CA folder&lt;/a&gt;, the &lt;a href="#through-a-company-proxy"&gt;company proxy&lt;/a&gt; settings in devvm&amp;rsquo;s environment and the &lt;a href="#the-shared-nix-cache"&gt;shared Nix cache&lt;/a&gt;&amp;rsquo;s cap. A config that&amp;rsquo;s gone, or that the proxy wouldn&amp;rsquo;t read, counts as one that differs. To start a new proxy, devvm stops the old one with &lt;code&gt;SIGTERM&lt;/code&gt;, and with &lt;code&gt;SIGKILL&lt;/code&gt; when it&amp;rsquo;s still running two seconds later. The old proxy counts as stopped only once its process is gone, not once its arguments can no longer be read, because an ending process loses its memory before its files, and for that moment its port still looks taken by another program, which would fail the launch with &lt;code&gt;proxy_port_taken&lt;/code&gt;. &lt;code&gt;SIGKILL&lt;/code&gt; goes only to a process whose arguments devvm can still read as the proxy&amp;rsquo;s, so a proxy still ending gets none, and neither does another process given its pid since, even one whose arguments devvm can&amp;rsquo;t read. If it still runs two seconds after that, devvm stops with &lt;code&gt;proxy_stop_failed&lt;/code&gt; and starts nothing, because the old proxy would go on with its old settings.&lt;/p&gt;
&lt;p&gt;devvm counts a proxy as started only once the proxy says it&amp;rsquo;s listening on the VM&amp;rsquo;s port and is still running, because a program that took the port first would otherwise get the VM&amp;rsquo;s traffic. The proxy says so in a status file of its own in the VM&amp;rsquo;s run folder (&lt;code&gt;vms/&amp;lt;hash&amp;gt;/run/proxy.status&lt;/code&gt;), which devvm names to it when it starts it and removes before each start. The file holds the proxy&amp;rsquo;s pid and the address it listens on, so a status that an earlier proxy left, or that another program wrote, never counts. While devvm waits, the proxy counts as running as long as its pid file still names it, it hasn&amp;rsquo;t ended, and its arguments are the VM&amp;rsquo;s proxy&amp;rsquo;s, &lt;code&gt;_proxy -config&lt;/code&gt; with the VM&amp;rsquo;s &lt;code&gt;proxy.json&lt;/code&gt;, or still devvm&amp;rsquo;s own, or can&amp;rsquo;t be read yet. On Linux, a process that has just started shows devvm&amp;rsquo;s own arguments for a moment, then none, because the kernel lets devvm go on as the new program begins to replace devvm&amp;rsquo;s copy, and shows the program&amp;rsquo;s arguments only once it has loaded. If the proxy doesn&amp;rsquo;t start, devvm stops and names the proxy&amp;rsquo;s log (&lt;code&gt;proxy_start_failed&lt;/code&gt;). When a stopped VM&amp;rsquo;s port was taken by another program, devvm chooses a new free port. A running VM&amp;rsquo;s backend holds the port it started with, so when a running VM&amp;rsquo;s proxy is gone and another program took its port, devvm can&amp;rsquo;t start the proxy again (&lt;code&gt;proxy_port_taken&lt;/code&gt;). devvm then stops the VM (&lt;code&gt;net_proxy_down_stopped&lt;/code&gt;), and it does the same when the proxy fails to start for any other reason once the old one was stopped, or when none of the VM&amp;rsquo;s runs, because a confined VM never runs on without its proxy. The next &lt;code&gt;devvm&lt;/code&gt; starts both. A running VM&amp;rsquo;s old proxy has the VM&amp;rsquo;s port, so it can&amp;rsquo;t be kept while the new one starts. On a launch, a link&amp;rsquo;s change or a &lt;code&gt;devvm network&lt;/code&gt; change, what can refuse the proxy&amp;rsquo;s start is checked before the old one stops: the company proxy and its password, your CAs, and the VM&amp;rsquo;s CA and secret files. A refusal there leaves the VM and its old proxy running as they were, and devvm says so (&lt;code&gt;net_proxy_kept&lt;/code&gt;), but only while the old proxy enforces what the VM&amp;rsquo;s state asks for now: the same built-in policies, policy files and deny files for the VM&amp;rsquo;s tier, open or not, from the same devvm binary. An old proxy with a looser tier than the state&amp;rsquo;s, or from another devvm binary, whose built-in policies&amp;rsquo; rules may differ, is stopped with the VM, because it would fail open. The comparison leaves out the company proxy and your CAs that the old proxy started with, so an old proxy kept this way still goes through the company proxy, and trusts the CAs, of its own start. &lt;code&gt;devvm restart&lt;/code&gt; checks only the company proxy and your CAs before it stops the VM, and its start checks the rest. An interrupt during the start of a confined VM stops the VM and its proxy too (&lt;code&gt;interrupted_start&lt;/code&gt;, a cleanup that the start registers around the backend&amp;rsquo;s start), because a backend can leave the VM running while its start still waits for it. Lima&amp;rsquo;s hostagent keeps running the VM after &lt;code&gt;limactl start&lt;/code&gt; ends, and devvm records the confined start only once &lt;code&gt;limactl start&lt;/code&gt; returns. Without the stop, the VM would run with no record of its confined start, so &lt;code&gt;devvm ls&lt;/code&gt; would show it as &lt;code&gt;unenforced&lt;/code&gt; and its next launch would offer to restart it.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-childs-sandbox"&gt;The child&amp;rsquo;s sandbox&lt;span class="hx:absolute hx:-mt-20" id="the-childs-sandbox"&gt;&lt;/span&gt;
&lt;a href="#the-childs-sandbox" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The child makes no connection of its own, on either system. It asks its broker to look up each name the floor judges, and to open each connection, to an address the child&amp;rsquo;s floor kept or to a company proxy, and the broker hands it the connection, as it hands it a link&amp;rsquo;s. The broker connects to an address only once its own read of the VM&amp;rsquo;s policy files and of this machine&amp;rsquo;s addresses allows it, as the floor does, and it looks at the policy files at each connection, so a rule such as &lt;code&gt;devvm network allow 127.0.0.1:5432&lt;/code&gt; applies from the next connection. So even a child that a VM took over reaches this machine&amp;rsquo;s loopback, its own addresses and the private and link-local ranges only where a rule names the address, as the VM does. It still reaches the internet, a host on this machine&amp;rsquo;s network whose address is public, such as a printer&amp;rsquo;s global IPv6 address, and whatever a company proxy reaches, which it speaks to with its password, this machine&amp;rsquo;s loopback included when the company proxy runs here. The broker connects to the company proxy at the address in its own config, so one on this machine&amp;rsquo;s loopback, such as a VPN client&amp;rsquo;s, works. It looks names up through this machine&amp;rsquo;s resolver, whatever its address, so the child sends no DNS. The broker carries at most 256 lookups and 1024 connections at once for the child, each lookup within 20 seconds and each connection within 15, and the child cancels one whose request has gone. The child also holds at most 8448 open files, a limit it sets on itself before it&amp;rsquo;s confined, so it can&amp;rsquo;t keep every connection the broker hands it (&lt;a href="https://next.devvm.dev/docs/contributing/design/#the-proxys-broker"&gt;the design note&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;On macOS, the broker starts its child through &lt;code&gt;/usr/bin/sandbox-exec&lt;/code&gt;, with a Seatbelt profile that denies everything the child doesn&amp;rsquo;t need, so the child is confined from its first instruction, before it reads a byte of the VM&amp;rsquo;s. The broker writes the profile for each start from what the child needs, and passes it to &lt;code&gt;sandbox-exec&lt;/code&gt; as an argument, so it&amp;rsquo;s never a file on disk. It runs devvm&amp;rsquo;s binary by its real path, with its links resolved, because Seatbelt matches real paths. The profile allows the child the following, and nothing else:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;devvm&amp;rsquo;s binary:&lt;/strong&gt; running it and reading it, for its SHA-256, and the metadata of its folder, which CoreFoundation looks at for the program&amp;rsquo;s bundle before Security checks a certificate.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The system:&lt;/strong&gt; the rules that the system&amp;rsquo;s own &lt;code&gt;dyld-support.sb&lt;/code&gt; profile gives a program to start, reading the system&amp;rsquo;s libraries in &lt;code&gt;/usr/lib&lt;/code&gt; and &lt;code&gt;/System/Library&lt;/code&gt; and the time zone, the metadata of the links &lt;code&gt;/etc&lt;/code&gt;, &lt;code&gt;/var&lt;/code&gt; and &lt;code&gt;/tmp&lt;/code&gt;, through which those paths lead, and reading &lt;code&gt;sysctl&lt;/code&gt;, which the floor reads the host&amp;rsquo;s addresses with, except the process table&amp;rsquo;s &lt;code&gt;kern.proc&lt;/code&gt; names.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Its folders:&lt;/strong&gt; reading and writing in the VM&amp;rsquo;s logs folder and the shared Nix cache, where it can make only regular files, and change their mode and times, but not their flags, ACLs, owner, set-id bits or extended attributes, and can remove no folder. It makes no hard link anywhere. The broker makes the cache&amp;rsquo;s folders before the child starts, as the child can&amp;rsquo;t make a folder. A build&amp;rsquo;s child gets its own &lt;code&gt;logs/&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The files that change:&lt;/strong&gt; the metadata of your policy files, the VM&amp;rsquo;s bindings and the links&amp;rsquo; list, which the child looks at with &lt;code&gt;stat&lt;/code&gt; alone, and of their targets when they&amp;rsquo;re links, and of every link on the way to any of those files or folders.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Checking certificates:&lt;/strong&gt; the mach services &lt;code&gt;com.apple.trustd&lt;/code&gt; and &lt;code&gt;com.apple.trustd.agent&lt;/code&gt;, which check certificates for Go&amp;rsquo;s &lt;code&gt;crypto/x509&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The network:&lt;/strong&gt; accepting on the listener the broker gave it, and reading and writing the connections it accepted and those the broker handed it, which need no rule of their own. The profile allows no network out at all, so the child connects nowhere and sends no datagram itself, because Seatbelt checks every &lt;code&gt;connect&lt;/code&gt; and every send with an address.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Signals and processes:&lt;/strong&gt; signals to itself, and looking only at itself.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So the child can&amp;rsquo;t read your home folder or devvm&amp;rsquo;s other folders, its run folder, its config and the other VMs&amp;rsquo; among them, and can&amp;rsquo;t reach the Keychain, whose service &lt;code&gt;com.apple.SecurityServer&lt;/code&gt; the profile never allows, nor any unix socket, such as an ssh master&amp;rsquo;s control socket or an SSH agent&amp;rsquo;s. It can&amp;rsquo;t bind a port, fork or run a program, signal another process, list the processes, or read another process&amp;rsquo;s path, details or arguments (&lt;code&gt;process-info&lt;/code&gt;, &lt;code&gt;kern.proc&lt;/code&gt;). macOS answers a process&amp;rsquo;s arguments (&lt;code&gt;kern.procargs2&lt;/code&gt;) to a sandboxed process only within its own process group, and the child runs alone in a session of its own, so it can read only its own. A policy file that&amp;rsquo;s a link to another file is looked at where it pointed as the proxy started, and when it points elsewhere later, the child&amp;rsquo;s &lt;code&gt;stat&lt;/code&gt; is refused, so the child asks the broker for the file at every request instead, which reads it as before.&lt;/p&gt;
&lt;p&gt;On Linux, the child confines itself once it has opened its logs and the Nix cache and loaded the system&amp;rsquo;s roots and its time zone. It does so before it says it&amp;rsquo;s ready, so before it reads a byte of the VM&amp;rsquo;s. It sets &lt;code&gt;no_new_privs&lt;/code&gt; on every thread, restricts every thread with Landlock, and installs a seccomp filter on every thread. Landlock and &lt;code&gt;prctl&lt;/code&gt; change only the thread that calls them, and Go&amp;rsquo;s runtime runs the child on several threads, so the child makes each call on every thread at once through Go&amp;rsquo;s call for all of a process&amp;rsquo;s threads, which works only in a binary without cgo, as devvm&amp;rsquo;s releases are. From Landlock&amp;rsquo;s ABI 8 it restricts every thread in one call instead (&lt;code&gt;LANDLOCK_RESTRICT_SELF_TSYNC&lt;/code&gt;), and the filter goes on every thread in one call (&lt;code&gt;SECCOMP_FILTER_FLAG_TSYNC&lt;/code&gt;). Landlock holds the child to these files, whatever their permissions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Its folders:&lt;/strong&gt; the VM&amp;rsquo;s logs folder, and for a VM with the nix layer the shared Nix cache, where it reads, writes, lists, makes, deletes, renames and empties regular files, from Landlock&amp;rsquo;s ABI 2, which lets the cache rename a file from its top folder into &lt;code&gt;nar/&lt;/code&gt;. It makes no folder, link, FIFO, socket or device there, and nothing in them runs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nothing else:&lt;/strong&gt; it can&amp;rsquo;t read, write or list any other file, your home folder, devvm&amp;rsquo;s folders and &lt;code&gt;/etc&lt;/code&gt; included, or run a program. Landlock doesn&amp;rsquo;t restrict &lt;code&gt;stat&lt;/code&gt;, so the child still looks at the changing files, and learns whether a file of yours exists, its size and when it changed, but not what it holds. Landlock also doesn&amp;rsquo;t restrict a file&amp;rsquo;s mode, owner, extended attributes or times, or, below ABI 3, a truncation by path, so the seccomp filter refuses those.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;From ABI 4 Landlock also refuses the child a TCP port&amp;rsquo;s bind and every TCP connection, from ABI 6 a signal to any process outside it and a connection to an abstract unix socket that isn&amp;rsquo;t its own, from ABI 9 a connection to a named unix socket, and from ABI 10 every UDP bind and datagram. On a kernel at ABI 6 or 7 without Landlock&amp;rsquo;s fix for signals between a process&amp;rsquo;s threads, the child leaves its signals unscoped, because Go&amp;rsquo;s runtime signals each of its threads to restrict itself in turn, and those signals would be refused and hang the start. Landlock&amp;rsquo;s network rules match only ports, so they can&amp;rsquo;t refuse an address alone, and the seccomp filter refuses the child every connection of its own on every kernel.&lt;/p&gt;
&lt;p&gt;The seccomp filter refuses the child, with &lt;code&gt;EPERM&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Sockets:&lt;/strong&gt; every socket but a netlink route socket (&lt;code&gt;AF_NETLINK&lt;/code&gt; with &lt;code&gt;NETLINK_ROUTE&lt;/code&gt;), which the floor reads the host&amp;rsquo;s addresses through and which reaches the kernel alone, a socketpair, &lt;code&gt;connect&lt;/code&gt;, &lt;code&gt;listen&lt;/code&gt;, and &lt;code&gt;sendto&lt;/code&gt;, &lt;code&gt;sendmsg&lt;/code&gt; and &lt;code&gt;sendmmsg&lt;/code&gt; with &lt;code&gt;MSG_FASTOPEN&lt;/code&gt;, which would connect a TCP socket as it sends, such as its listener once a &lt;code&gt;shutdown&lt;/code&gt; has closed it. So the child has no socket of its own to connect, and can&amp;rsquo;t connect one it holds again. Below Landlock&amp;rsquo;s ABI 9, the filter is also what keeps it from the ssh masters&amp;rsquo; control sockets, &lt;code&gt;docker.sock&lt;/code&gt; and your SSH agent&amp;rsquo;s socket.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Calls around the filter:&lt;/strong&gt; the three &lt;code&gt;io_uring&lt;/code&gt; calls, whose operations wouldn&amp;rsquo;t pass it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Other processes:&lt;/strong&gt; &lt;code&gt;ptrace&lt;/code&gt;, &lt;code&gt;process_vm_readv&lt;/code&gt;, &lt;code&gt;process_vm_writev&lt;/code&gt; and &lt;code&gt;pidfd_getfd&lt;/code&gt;, which reach another process&amp;rsquo;s memory or descriptors, and what changes how another process runs, which Landlock&amp;rsquo;s scope of signals doesn&amp;rsquo;t cover: &lt;code&gt;prlimit64&lt;/code&gt; other than on the child itself, as a limit such as &lt;code&gt;RLIMIT_CPU&lt;/code&gt; can kill a process, &lt;code&gt;setpriority&lt;/code&gt;, &lt;code&gt;ioprio_set&lt;/code&gt;, &lt;code&gt;sched_setaffinity&lt;/code&gt;, &lt;code&gt;sched_setscheduler&lt;/code&gt;, &lt;code&gt;sched_setparam&lt;/code&gt; and &lt;code&gt;sched_setattr&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Watching files:&lt;/strong&gt; &lt;code&gt;inotify_init&lt;/code&gt;, &lt;code&gt;inotify_init1&lt;/code&gt;, &lt;code&gt;inotify_add_watch&lt;/code&gt;, &lt;code&gt;fanotify_init&lt;/code&gt; and &lt;code&gt;fanotify_mark&lt;/code&gt;, which would tell it the names of files outside its folders as they change.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A file&amp;rsquo;s metadata by its path:&lt;/strong&gt; &lt;code&gt;chmod&lt;/code&gt;, &lt;code&gt;fchmodat&lt;/code&gt; and &lt;code&gt;fchmodat2&lt;/code&gt;, &lt;code&gt;chown&lt;/code&gt;, &lt;code&gt;lchown&lt;/code&gt; and &lt;code&gt;fchownat&lt;/code&gt;, the extended attributes&amp;rsquo; &lt;code&gt;setxattr&lt;/code&gt;, &lt;code&gt;lsetxattr&lt;/code&gt;, &lt;code&gt;removexattr&lt;/code&gt;, &lt;code&gt;lremovexattr&lt;/code&gt;, &lt;code&gt;setxattrat&lt;/code&gt; and &lt;code&gt;removexattrat&lt;/code&gt;, &lt;code&gt;truncate&lt;/code&gt;, and the times&amp;rsquo; &lt;code&gt;utime&lt;/code&gt;, &lt;code&gt;utimes&lt;/code&gt;, &lt;code&gt;futimesat&lt;/code&gt;, and &lt;code&gt;utimensat&lt;/code&gt; with a path. The calls on a descriptor that the child opened, which Landlock checked as it opened it, stay: &lt;code&gt;fchmod&lt;/code&gt;, &lt;code&gt;fchown&lt;/code&gt;, &lt;code&gt;ftruncate&lt;/code&gt; and &lt;code&gt;utimensat&lt;/code&gt; on a descriptor, which its logs and the Nix cache use.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The kernel&amp;rsquo;s keyrings:&lt;/strong&gt; &lt;code&gt;add_key&lt;/code&gt;, &lt;code&gt;request_key&lt;/code&gt; and &lt;code&gt;keyctl&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What it never does:&lt;/strong&gt; running a program (&lt;code&gt;execve&lt;/code&gt;, &lt;code&gt;execveat&lt;/code&gt;), a process of its own (&lt;code&gt;fork&lt;/code&gt; and &lt;code&gt;vfork&lt;/code&gt;, and &lt;code&gt;clone&lt;/code&gt; for anything but a thread), a namespace (&lt;code&gt;unshare&lt;/code&gt;, &lt;code&gt;setns&lt;/code&gt;, and &lt;code&gt;clone&lt;/code&gt; with a namespace&amp;rsquo;s flag), &lt;code&gt;bpf&lt;/code&gt;, &lt;code&gt;userfaultfd&lt;/code&gt; and &lt;code&gt;perf_event_open&lt;/code&gt;. &lt;code&gt;clone3&lt;/code&gt; gets &lt;code&gt;ENOSYS&lt;/code&gt;, as a kernel without it answers, because its flags are behind a pointer that the filter can&amp;rsquo;t read, so a caller falls back to &lt;code&gt;clone&lt;/code&gt;, whose flags it can.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It kills the child for a system call of any architecture but its own, and on amd64 for the x32 numbers, so the 32-bit calls, &lt;code&gt;socketcall&lt;/code&gt; among them, can&amp;rsquo;t get around it. The child needs none of these, because the broker looks up its names, the listener and the socket to the broker were open before, every connection it opens comes from the broker, and Go&amp;rsquo;s runtime starts its threads with &lt;code&gt;clone&lt;/code&gt; and the thread&amp;rsquo;s flag. The broker sets itself undumpable (&lt;code&gt;PR_SET_DUMPABLE&lt;/code&gt;), so on a kernel without Landlock, where nothing else would, the child can&amp;rsquo;t read the broker&amp;rsquo;s memory or open its descriptors through &lt;code&gt;/proc&lt;/code&gt;. Other processes of yours stay readable through &lt;code&gt;/proc&lt;/code&gt; there, unless the kernel&amp;rsquo;s Yama restricts &lt;code&gt;ptrace&lt;/code&gt;, as Ubuntu&amp;rsquo;s does. Once confined, the child checks that it lists its own folders, that it fails to list &lt;code&gt;/&lt;/code&gt; and to read &lt;code&gt;/etc/hosts&lt;/code&gt; with Landlock, and that it fails to make a unix or an IPv4 socket, to connect, to listen and to send with &lt;code&gt;MSG_FASTOPEN&lt;/code&gt; with the filter. It also reads the host&amp;rsquo;s own addresses again, through a netlink socket, and a read that fails or finds none fails the start, because the floor would refuse none of them without it. The confinement takes at most 2 seconds, within the broker&amp;rsquo;s 4, and a confinement or a check that fails fails the start, which devvm reports as the proxy failing to start (&lt;code&gt;proxy_start_failed&lt;/code&gt;). A kernel without Landlock, below ABI 2, or without seccomp filters, leaves that part out, and the child runs with what there is, which it says.&lt;/p&gt;
&lt;p&gt;On both systems, the child checks that what confines its files holds before it says it&amp;rsquo;s ready. It opens its broker&amp;rsquo;s config, the file named in its arguments, which the profile or Landlock must refuse it, and closes it unread if it opens. Its ready message says how it&amp;rsquo;s confined, and the broker writes that to &lt;code&gt;run/proxy.confined&lt;/code&gt; as one line of a level, &lt;code&gt;full&lt;/code&gt;, &lt;code&gt;partial&lt;/code&gt; or &lt;code&gt;none&lt;/code&gt;, then what confines it and, for a child that isn&amp;rsquo;t fully confined, why, from a fixed set of words, so devvm never prints what a child wrote:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;code&gt;run/proxy.confined&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;What&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;full seatbelt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the profile confines the child, and its check held&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;none seatbelt check-failed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the child ran under the profile, but could open its broker&amp;rsquo;s config&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;none sandbox-exec-missing&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;there&amp;rsquo;s no &lt;code&gt;/usr/bin/sandbox-exec&lt;/code&gt;, so the broker started the child unconfined&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;none sandbox-exec-failed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sandbox-exec&lt;/code&gt; failed to start the child under its profile, so the broker started it again unconfined&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;none unsupported&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;devvm doesn&amp;rsquo;t confine the child on this system, or this devvm, built with cgo as the tests&amp;rsquo; race detector is, can&amp;rsquo;t reach its threads&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;full landlock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;on Linux, Landlock from ABI 6 with its signals scoped, and the seccomp filter, confine the child, and its check held. Below ABI 9 the filter alone refuses it a unix socket, and below ABI 10 a UDP socket&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;partial landlock landlock-signals&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;this kernel&amp;rsquo;s Landlock is ABI 4 or 5, or 6 or 7 without its fix for signals between threads, so the child can also signal your other processes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;partial landlock landlock-below-abi4&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;this kernel&amp;rsquo;s Landlock is ABI 2 or 3, which refuses no TCP of the child&amp;rsquo;s, though the filter refuses it every socket and connection of its own&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;partial landlock no-seccomp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;this kernel has no seccomp filters, so only Landlock confines the child, which below ABI 4 can connect anywhere itself, this machine&amp;rsquo;s loopback included&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;partial seccomp no-landlock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;this kernel has no Landlock, or only ABI 1, so only the filter confines the child, which can read and write your files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;none no-landlock-or-seccomp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;this kernel has neither, so the child runs with the broker&amp;rsquo;s access, and can connect anywhere itself&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;none landlock check-failed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the child confined itself, but could open its broker&amp;rsquo;s config&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The broker starts the child again unconfined only when &lt;code&gt;sandbox-exec&lt;/code&gt; failed before devvm&amp;rsquo;s code ran. That&amp;rsquo;s when the child had already ended before it answered, either with &lt;code&gt;sandbox-exec&lt;/code&gt;&amp;rsquo;s own exit status, 65 for a profile it refused or 71 for a program it couldn&amp;rsquo;t run, or killed by &lt;code&gt;SIGABRT&lt;/code&gt; or &lt;code&gt;SIGKILL&lt;/code&gt;, as the system kills a program that a profile refuses what it needs to load. The broker decides that before it stops the child itself, so a child that its own stop ended never counts. Nothing of a VM&amp;rsquo;s can cause those failures, so the second start, which has what&amp;rsquo;s left of the broker&amp;rsquo;s 4 seconds, never trades a confined child for an unconfined one at a VM&amp;rsquo;s request. A program of yours that sent the child one of those signals in that moment could, and the proxy&amp;rsquo;s log and devvm doctor then say the child runs unconfined. A child that answers &lt;code&gt;failed&lt;/code&gt;, ends any other way, or doesn&amp;rsquo;t answer in time fails the start, as it would unconfined, because what it read by then could be a VM&amp;rsquo;s. A ready that names a sandbox the broker didn&amp;rsquo;t start the child under, or another than the one it did, breaks the protocol&amp;rsquo;s rules, so a child can&amp;rsquo;t claim more than it was given. The broker writes a warning in &lt;code&gt;proxy.log&lt;/code&gt; for each child that isn&amp;rsquo;t fully confined, and devvm doctor warns of each running VM whose proxy says so (&lt;a href="https://next.devvm.dev/docs/using/troubleshooting/#the-proxy-runs-without-a-sandbox"&gt;the proxy runs without a sandbox&lt;/a&gt;). A proxy that hasn&amp;rsquo;t written &lt;code&gt;run/proxy.confined&lt;/code&gt; yet, such as one still starting or one that a devvm from before the broker started, gets no warning.&lt;/p&gt;
&lt;h2 data-hextra-search-id="policy-files"&gt;Policy files&lt;span class="hx:absolute hx:-mt-20" id="policy-files"&gt;&lt;/span&gt;
&lt;a href="#policy-files" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;On the allowlist tier, a VM&amp;rsquo;s proxy reads these policies, in this order, as one list. &lt;a href="https://next.devvm.dev/docs/safety/network/#allowlists"&gt;Allowlists&lt;/a&gt; describes what they allow and the rules they hold. The other tiers read fewer, and one list of devvm&amp;rsquo;s makes each tier&amp;rsquo;s:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;internet:&lt;/strong&gt; one built-in policy, &lt;code&gt;network/internet.policy&lt;/code&gt;, which holds &lt;code&gt;**:*&lt;/code&gt;, every host and address on any port, then &lt;code&gt;secrets.policy&lt;/code&gt;, then your files below, whose denies alone apply. The proxy&amp;rsquo;s config lists those files in &lt;code&gt;deny_policies&lt;/code&gt;, and the proxy drops their allows as it reads them, keeping their denies and a broken deny. &lt;code&gt;**&lt;/code&gt; lifts no floor, so internal addresses and this machine&amp;rsquo;s stay refused.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;none:&lt;/strong&gt; the built-in policies of the VM&amp;rsquo;s agents, each agent&amp;rsquo;s &lt;code&gt;shared-tools/&amp;lt;agent&amp;gt;.policy&lt;/code&gt;, such as &lt;code&gt;shared-tools/claude.policy&lt;/code&gt;, and no other built-in one, then &lt;code&gt;secrets.policy&lt;/code&gt;, then your files as denies alone. The VM&amp;rsquo;s links come before every rule, as on every tier.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;open:&lt;/strong&gt; no policy at all. The proxy&amp;rsquo;s config has &lt;code&gt;&amp;quot;open&amp;quot;: true&lt;/code&gt;, which allows every host and address on every port, internal ones and this machine&amp;rsquo;s included, and a config with &lt;code&gt;open&lt;/code&gt; and any policy is refused. The floor doesn&amp;rsquo;t apply, and a name that the host can&amp;rsquo;t resolve goes to the company proxy unjudged, as it does for a build.&lt;/li&gt;
&lt;/ul&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Policy&lt;/th&gt;
&lt;th&gt;Read for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;layers/base.policy&lt;/code&gt; (built in)&lt;/td&gt;
&lt;td&gt;every VM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;shared-tools/&amp;lt;name&amp;gt;.policy&lt;/code&gt; (built in)&lt;/td&gt;
&lt;td&gt;each shared tool in the VM&amp;rsquo;s image&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;layers/&amp;lt;name&amp;gt;.policy&lt;/code&gt; (built in)&lt;/td&gt;
&lt;td&gt;each built-in layer in the VM&amp;rsquo;s image&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;~/.config/devvm/layers/&amp;lt;name&amp;gt;.policy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;each of your layers in the VM&amp;rsquo;s image&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;~/.config/devvm/policy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;every VM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/policy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;that VM only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/secrets.policy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;every VM, which devvm writes with the hosts of the VM&amp;rsquo;s secrets and logins and of its agents&amp;rsquo; &lt;a href="#logins-made-in-a-vm"&gt;token endpoints&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The built-in policies are paths in devvm&amp;rsquo;s own files, which are &lt;a href="https://next.devvm.dev/docs/internals/install/#devvms-own-files"&gt;built into the binary&lt;/a&gt;, and no copy of them is ever on disk. The same list holds both kinds for a VM: the built-in ones go in the proxy&amp;rsquo;s config as names in &lt;code&gt;builtin_policies&lt;/code&gt;, and your files as paths in &lt;code&gt;policies&lt;/code&gt;. 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&amp;rsquo;s proxy again because the binary changed. A built-in policy that&amp;rsquo;s missing, or that holds a line that isn&amp;rsquo;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&amp;rsquo;t start. A missing file of yours, on the other hand, has no rules. &lt;code&gt;devvm network&lt;/code&gt; reads the built-in policies from the binary too, and it labels each with its name (&lt;code&gt;# devvm: layers/base.policy&lt;/code&gt;, and &lt;code&gt;&amp;quot;builtin&amp;quot;&lt;/code&gt; with &lt;code&gt;--json&lt;/code&gt;) where it shows your files&amp;rsquo; paths. Both lists are in the config that a proxy started with, so a change to either starts the proxy again.&lt;/p&gt;
&lt;p&gt;The proxy, &lt;code&gt;devvm network&lt;/code&gt; and &lt;code&gt;devvm doctor&lt;/code&gt; read every policy with one parser, which returns each line that holds more than a comment, with its number and whether it&amp;rsquo;s a rule. A line is a rule only when one check takes it, which is exactly what &lt;code&gt;devvm network allow&lt;/code&gt; and &lt;code&gt;deny&lt;/code&gt; take (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt;). Each time the proxy reads a file, it logs each line that isn&amp;rsquo;t a rule, with its file, number and text, quoted, to its own log, &lt;code&gt;proxy.log&lt;/code&gt; in the VM&amp;rsquo;s &lt;code&gt;logs/&lt;/code&gt; folder. It skips such a line, unless the line starts with &lt;code&gt;!&lt;/code&gt;, which makes it a broken deny. A broken deny fails closed: while any of the VM&amp;rsquo;s policy files has one, the proxy&amp;rsquo;s policy denies every name and every address, and each request gets &lt;code&gt;403&lt;/code&gt; and a refused block whose reason names the file and the line, so neither the VM&amp;rsquo;s prompt nor &lt;code&gt;devvm network log&lt;/code&gt; suggests an allow rule. The VM&amp;rsquo;s links and the proxy&amp;rsquo;s own answers at &lt;code&gt;devvm.proxy&lt;/code&gt; come before the rules, so they still work, and tunnels already open stay open, as they do for any new deny. Fixing the line lifts it at the proxy&amp;rsquo;s next read of the file, which is the next connection. The proxy reads a file again when its mtime, size or inode changes, or when it comes back after it was missing, whatever its mtime. It also reads a file again at every connection while its mtime is less than 2 seconds old, because some filesystems keep mtimes only to the second or two, so a second write within that time could leave the stamp as it was. A change of a file&amp;rsquo;s mode or owner alone, with &lt;code&gt;chmod&lt;/code&gt; or &lt;code&gt;chown&lt;/code&gt;, changes none of the three, so the proxy doesn&amp;rsquo;t see it until the file&amp;rsquo;s next write. The same goes for the bindings file and the links list, so one that you make readable or writable by others after the proxy read it keeps its last contents until it changes, and the proxy refuses it then. A file the proxy refused is read again at the next connection, so fixing its mode works at once. An error other than a missing file keeps its last rules and its broken deny, which the proxy&amp;rsquo;s log says once. The proxy, &lt;code&gt;devvm network&lt;/code&gt; and &lt;code&gt;devvm doctor&lt;/code&gt; read a policy file only when it&amp;rsquo;s a regular file, through a symbolic link if it&amp;rsquo;s one, of at most 1 MiB, through devvm&amp;rsquo;s one reader of files a VM can write or swap. They open it without blocking and check the file they opened, so a FIFO or a link to &lt;code&gt;/dev/zero&lt;/code&gt; in a policy file&amp;rsquo;s place can&amp;rsquo;t hang them, and each refuses it with a named error, one for a file that isn&amp;rsquo;t regular and one for a file that&amp;rsquo;s too long. A leading byte-order mark isn&amp;rsquo;t part of the first line. devvm warns about each line that isn&amp;rsquo;t a rule, with &lt;code&gt;policy_broken_deny&lt;/code&gt; for a broken deny and &lt;code&gt;policy_not_rule&lt;/code&gt; for the others. A launch of a confined VM warns about the VM&amp;rsquo;s policy files as it readies the VM&amp;rsquo;s proxy, &lt;code&gt;devvm network allow&lt;/code&gt;, &lt;code&gt;deny&lt;/code&gt; and &lt;code&gt;rm&lt;/code&gt; about the file they change, and &lt;code&gt;devvm doctor&lt;/code&gt; about the files you edit: &lt;code&gt;~/.config/devvm/policy&lt;/code&gt;, your layers&amp;rsquo; and each VM&amp;rsquo;s own. &lt;code&gt;devvm network&lt;/code&gt; also marks the line, and &lt;code&gt;--json&lt;/code&gt; lists it in &lt;code&gt;not_rules&lt;/code&gt;. A unit test parses every policy file that devvm ships and fails on any line that isn&amp;rsquo;t a rule.&lt;/p&gt;
&lt;p&gt;Each change that &lt;code&gt;devvm network allow&lt;/code&gt;, &lt;code&gt;deny&lt;/code&gt; or &lt;code&gt;rm&lt;/code&gt; makes rewrites the file whole, through a link if the file is one, so a proxy never reads half of it.&lt;/p&gt;
&lt;h3 data-hextra-search-id="quiet-hosts"&gt;Quiet hosts&lt;span class="hx:absolute hx:-mt-20" id="quiet-hosts"&gt;&lt;/span&gt;
&lt;a href="#quiet-hosts" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A built-in policy can hold &lt;code&gt;quiet HOST&lt;/code&gt; or &lt;code&gt;quiet HOST:PORT&lt;/code&gt; lines, for one exact host name, never &lt;code&gt;*.name&lt;/code&gt; or &lt;code&gt;**&lt;/code&gt;, so a quiet line can&amp;rsquo;t hide a whole domain&amp;rsquo;s blocks (&lt;a href="https://next.devvm.dev/docs/safety/network/#quiet-hosts"&gt;quiet hosts&lt;/a&gt;). The policy parser returns such a line as one that isn&amp;rsquo;t a rule, marked as a quiet line, so the check of a rule and &lt;code&gt;devvm network allow&lt;/code&gt; never take one. The proxy&amp;rsquo;s read of its built-in policies keeps it as a rule marked &lt;code&gt;quiet&lt;/code&gt;, which allows and denies nothing, so the proxy leaves it out of the rules a decision reads. It matches a host and port against the built-in quiet rules alone, as it matches any rule, but only while no rule covers that host and port, whether an allow, a deny or one that narrows, and never on an open policy or one with a broken deny. The proxy drops a quiet line in any other file and logs it, and devvm warns about it with &lt;code&gt;policy_quiet_not_own&lt;/code&gt;. A quiet host is blocked as any host no rule allows, and an allow of yours still lifts it. The proxy marks a block&amp;rsquo;s event quiet only when its reason is the one for a host no rule allows, it isn&amp;rsquo;t refused whatever the rules say, and a quiet rule matches, for the proxy&amp;rsquo;s path and the transparent one alike, so a block for another reason, such as an internal address, a failed connection or a deny of yours, keeps its notice. A quiet event is logged with &lt;code&gt;&amp;quot;quiet&amp;quot;: true&lt;/code&gt; but never counted among the blocks that &lt;code&gt;/blocked&lt;/code&gt; and &lt;code&gt;/blocked/new&lt;/code&gt; serve, so neither the VM&amp;rsquo;s prompt nor &lt;code&gt;devvm-why&lt;/code&gt; sees it, and the proxy&amp;rsquo;s block page writes no allow command for it. &lt;code&gt;devvm network log&lt;/code&gt; gives it no allow command and a row of its own apart from the same host&amp;rsquo;s other blocks, and ends its line &lt;code&gt;, quiet&lt;/code&gt;, and &lt;code&gt;devvm network lock&lt;/code&gt; leaves it out of what it offers, judging it with the proxy&amp;rsquo;s own match of quiet rules. &lt;code&gt;devvm network&lt;/code&gt; marks a built-in quiet line, its &lt;code&gt;--json&lt;/code&gt; lists the hosts in &lt;code&gt;quiet&lt;/code&gt;, and the agents&amp;rsquo; table on the coding agents page leaves quiet lines out. Each quiet line in devvm&amp;rsquo;s files has a comment that names the host&amp;rsquo;s use and the maker&amp;rsquo;s page that documents it.&lt;/p&gt;
&lt;h3 data-hextra-search-id="requests-by-method-and-path"&gt;Requests by method and path&lt;span class="hx:absolute hx:-mt-20" id="requests-by-method-and-path"&gt;&lt;/span&gt;
&lt;a href="#requests-by-method-and-path" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A rule for a host name or &lt;code&gt;*.name&lt;/code&gt; can have its methods and then its path after it, each after spaces or tabs, such as &lt;code&gt;api.github.com GET,HEAD /repos/&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/safety/network/#rules-by-method-and-path"&gt;rules by method and path&lt;/a&gt;). The policy parser reads such a line as one rule, whose text is its canonical form: the host as before, the methods in capitals in the order of the proxy&amp;rsquo;s list of methods, and the path as written, joined by one space. That&amp;rsquo;s what &lt;code&gt;devvm network allow&lt;/code&gt;, &lt;code&gt;deny&lt;/code&gt; and &lt;code&gt;rm&lt;/code&gt; write from &lt;code&gt;--method&lt;/code&gt; and &lt;code&gt;--path&lt;/code&gt;, and what they compare a line by, so &lt;code&gt;HEAD,get&lt;/code&gt; and &lt;code&gt;GET,HEAD&lt;/code&gt; are the same rule. A method outside that list, &lt;code&gt;CONNECT&lt;/code&gt; among them, an address, a CIDR or &lt;code&gt;**&lt;/code&gt; with methods or a path, and a path that isn&amp;rsquo;t a pattern aren&amp;rsquo;t rules, so a typo in a deny is a broken deny, which denies everything, rather than a deny of nothing.&lt;/p&gt;
&lt;p&gt;The proxy judges a host in two steps. For the connection, &lt;code&gt;CONNECT host:port&lt;/code&gt; or an absolute-form request, a deny that narrows doesn&amp;rsquo;t refuse the host, and an allow that narrows allows it, so a host that only rules by method and path allow is reached. Its requests are then judged one by one when a rule that narrows covers the host and either it&amp;rsquo;s a deny or no rule allows the whole host. Both come from one read of the policy files, the rules that cover the host, so a file that changes between the two can&amp;rsquo;t give the connection one rule&amp;rsquo;s verdict and another&amp;rsquo;s way through. Such a host&amp;rsquo;s &lt;code&gt;CONNECT&lt;/code&gt; on a port the proxy intercepts, &lt;code&gt;:443&lt;/code&gt;, is intercepted with the VM&amp;rsquo;s CA, as a bound host&amp;rsquo;s is, and on any other port, or without a CA, it&amp;rsquo;s refused with &lt;code&gt;403&lt;/code&gt;, logged as a refused block, because the proxy can&amp;rsquo;t see the requests in it. An absolute-form request, plain HTTP on any port or &lt;code&gt;https://&lt;/code&gt;, is judged before it&amp;rsquo;s forwarded.&lt;/p&gt;
&lt;p&gt;Inside an intercepted tunnel, the proxy&amp;rsquo;s own HTTP server reads each request, HTTP/1.1 kept alive or HTTP/2, and calls one handler for each, which checks that the request names the host (&lt;code&gt;421&lt;/code&gt; otherwise), then judges it with the rules as they are then, then forwards it. So every request on a connection is judged, not just the first, and a rule added or removed applies from the tunnel&amp;rsquo;s next request. A WebSocket is judged by its upgrade request, after which the proxy passes its bytes as they are, so for a host that rules narrow, an &lt;code&gt;Upgrade&lt;/code&gt; to any other protocol, such as &lt;code&gt;h2c&lt;/code&gt;, whose requests would pass the same way, is refused, and so is a &lt;code&gt;CONNECT&lt;/code&gt; inside the tunnel. A refused request gets &lt;code&gt;403&lt;/code&gt;, and the event log gets a &lt;code&gt;blocked&lt;/code&gt; event with its method and path. A deny&amp;rsquo;s refusal is marked refused, so neither the VM&amp;rsquo;s prompt nor &lt;code&gt;devvm network log --blocked&lt;/code&gt; suggests an allow, and a request that no allow covers suggests the allow of the whole host. An allowed request&amp;rsquo;s &lt;code&gt;forward&lt;/code&gt; event names the rule that allowed it, as its &lt;code&gt;rule&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The proxy&amp;rsquo;s judge of a request takes the rules that cover the host and port in order. A whole deny refuses, then a &lt;code&gt;CONNECT&lt;/code&gt; and an upgrade to a protocol other than WebSocket are refused when a rule narrows the host, and so is, when a rule narrows it by method, a method that the request names besides its own that isn&amp;rsquo;t exactly one of the proxy&amp;rsquo;s methods, then each deny that narrows refuses what it matches, and then the first allow that matches lets the request through. One matcher judges both rules and &lt;a href="#how-the-proxy-puts-them-in"&gt;secrets&amp;rsquo; bindings&lt;/a&gt; (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt;):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A path in plain form:&lt;/strong&gt; the path as the proxy forwards it starts with &lt;code&gt;/&lt;/code&gt;, has nothing percent-encoded, no &lt;code&gt;\&lt;/code&gt; or &lt;code&gt;;&lt;/code&gt;, and is clean, with no &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;..&lt;/code&gt; segment and no doubled slash. The query is no part of it. These are the forms that servers read apart, by decoding an encoded slash or dot, reading &lt;code&gt;\&lt;/code&gt; as &lt;code&gt;/&lt;/code&gt;, dropping &lt;code&gt;;&lt;/code&gt; and what follows it, or not cleaning the path, so a request in any of them could reach a path that the proxy didn&amp;rsquo;t judge.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A pattern:&lt;/strong&gt; its segments are split at &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt; matches any run of characters within one, and &lt;code&gt;**&lt;/code&gt; as a whole segment matches one segment or more. A pattern&amp;rsquo;s last &lt;code&gt;/&lt;/code&gt; stands for &lt;code&gt;/**&lt;/code&gt;, so &lt;code&gt;/api/&lt;/code&gt; is &lt;code&gt;/api/**&lt;/code&gt;, which is a binding&amp;rsquo;s path below which the value goes in. A path&amp;rsquo;s one trailing &lt;code&gt;/&lt;/code&gt; may be there or not. Matching is a table over the pattern&amp;rsquo;s and the path&amp;rsquo;s segments, linear in the path for each of the pattern&amp;rsquo;s at most 32 segments, so a VM&amp;rsquo;s long path can&amp;rsquo;t make it slow.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The methods a request names:&lt;/strong&gt; besides its own, each value of a header that some servers take the method from, &lt;code&gt;X-HTTP-Method&lt;/code&gt; or any with &lt;code&gt;method-override&lt;/code&gt; in its name, read in any case and with &lt;code&gt;_&lt;/code&gt; for &lt;code&gt;-&lt;/code&gt;, as Rack&amp;rsquo;s and CGI&amp;rsquo;s servers turn &lt;code&gt;-&lt;/code&gt; into &lt;code&gt;_&lt;/code&gt;, and each &lt;code&gt;_method&lt;/code&gt; parameter of the query, in any case of its name. A value that isn&amp;rsquo;t exactly one of the proxy&amp;rsquo;s methods, trimmed, is odd: a list such as &lt;code&gt;DELETE, GET&lt;/code&gt;, which servers read apart, lower case or nothing. The proxy reads no body, so a form&amp;rsquo;s &lt;code&gt;_method&lt;/code&gt; field is the &lt;code&gt;POST&lt;/code&gt;&amp;rsquo;s.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;An allow, and a binding,&lt;/strong&gt; match strictly: the request&amp;rsquo;s method, and every method it names besides, as written, must be among the rule&amp;rsquo;s methods, with none odd, and its path must be plain and match the pattern in its own case. A request the matcher can&amp;rsquo;t judge alike for every server is never allowed by a rule with a path.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A deny&lt;/strong&gt; matches broadly: the method, or any method the request names besides, every word of a list among them, in any case, or any odd one; and the path in any case, any path that isn&amp;rsquo;t plain, the path above a pattern that ends with &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;/**&lt;/code&gt;, the path with its last segment cut at its first &lt;code&gt;.&lt;/code&gt;, which frameworks that take a format from a suffix (Rails, Spring) route to the same handler, and the path with each segment&amp;rsquo;s trailing dots dropped, as servers that drop a trailing dot read it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A query servers read apart:&lt;/strong&gt; while a rule narrows the host by method, a query with a &lt;code&gt;;&lt;/code&gt;, which some servers split pairs at and Go&amp;rsquo;s query parser skips the pair around, or with an escape that doesn&amp;rsquo;t decode, which Go&amp;rsquo;s parser drops, is odd, so a &lt;code&gt;_method&lt;/code&gt; hidden in it can&amp;rsquo;t pass.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In a user&amp;rsquo;s terms, the methods a request names work like this. Some servers take a request&amp;rsquo;s method from a header or a parameter instead of the request itself, so the proxy judges a request by every method it names. It reads the &lt;code&gt;X-HTTP-Method-Override&lt;/code&gt; and &lt;code&gt;X-HTTP-Method&lt;/code&gt; headers and every header with &lt;code&gt;method-override&lt;/code&gt; in its name, in any case and with &lt;code&gt;_&lt;/code&gt; for &lt;code&gt;-&lt;/code&gt;, as some servers read &lt;code&gt;X_HTTP_METHOD_OVERRIDE&lt;/code&gt;, and the &lt;code&gt;_method&lt;/code&gt; parameter of the query. While a rule by method covers a host, a request there whose header or parameter isn&amp;rsquo;t exactly one of those methods in capitals, such as &lt;code&gt;DELETE, GET&lt;/code&gt;, &lt;code&gt;delete&lt;/code&gt; or nothing at all, is refused, because servers could read it either way, and so is a request whose query has a &lt;code&gt;;&lt;/code&gt; in it, which some servers split the query at, or a query with an escape that doesn&amp;rsquo;t decode. Otherwise an allow needs the request&amp;rsquo;s own method and every one it names to be among its methods, so an allow of &lt;code&gt;GET&lt;/code&gt; refuses a &lt;code&gt;GET&lt;/code&gt; that says it&amp;rsquo;s a &lt;code&gt;DELETE&lt;/code&gt;, and a deny refuses a request that names any of its methods. The proxy doesn&amp;rsquo;t read a request&amp;rsquo;s body, so a &lt;code&gt;_method&lt;/code&gt; field in a form that a &lt;code&gt;POST&lt;/code&gt; sends, which some frameworks take as the method, is judged as the &lt;code&gt;POST&lt;/code&gt; it is: a deny of &lt;code&gt;POST&lt;/code&gt; refuses it, and an allow of &lt;code&gt;POST&lt;/code&gt; lets it through whatever the field says.&lt;/p&gt;
&lt;p&gt;Paths work like this. Servers don&amp;rsquo;t all read a request&amp;rsquo;s path alike, so a rule&amp;rsquo;s path matches only a path that every server reads the same way: one with nothing percent-encoded, no &lt;code&gt;\&lt;/code&gt; or &lt;code&gt;;&lt;/code&gt;, no &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;..&lt;/code&gt; part and no doubled slash. An allow matches exactly, its method and its path in their own case, and no path in any other form. A deny matches broadly instead. It matches in any case and every path that isn&amp;rsquo;t in that plain form, a deny whose path ends with &lt;code&gt;/&lt;/code&gt; also matches the path above it, a path&amp;rsquo;s last segment matches with what follows its first &lt;code&gt;.&lt;/code&gt; cut off too, as frameworks that take a format from a suffix route &lt;code&gt;/admin.json&lt;/code&gt; to &lt;code&gt;/admin&lt;/code&gt;, and every segment matches with its trailing dots dropped, as some servers drop them, so a deny of &lt;code&gt;/config.json&lt;/code&gt; refuses &lt;code&gt;/config.json.&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Judging a request costs the policy files&amp;rsquo; stat, which every connection already has, and a scan of the host&amp;rsquo;s rules. Decrypting the tunnel costs a TLS handshake with a certificate from the VM&amp;rsquo;s CA, which the proxy keeps for the 1024 hosts it used most recently, and another to the host, so the proxy decrypts only the hosts whose rules need it: a host that a whole allow covers, with no deny that narrows, stays a tunnel that the proxy doesn&amp;rsquo;t read.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-vms-setup"&gt;The VM&amp;rsquo;s setup&lt;span class="hx:absolute hx:-mt-20" id="the-vms-setup"&gt;&lt;/span&gt;
&lt;a href="#the-vms-setup" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;On every launch, the VM&amp;rsquo;s setup does the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It installs the VM&amp;rsquo;s own CA and the next one into the VM&amp;rsquo;s trust store, as &lt;code&gt;devvm-proxy.crt&lt;/code&gt; and &lt;code&gt;devvm-proxy-next.crt&lt;/code&gt;, so the proxy&amp;rsquo;s certificates for hosts with a bound secret verify, in this VM only. It never gets their keys.&lt;/li&gt;
&lt;li&gt;It points the programs that ignore the proxy variables at the proxy. Those are apt, sudo (which keeps the variables), every ssh connection, Docker&amp;rsquo;s daemon and containers with the &lt;a href="https://next.devvm.dev/docs/using/images/#docker"&gt;docker layer&lt;/a&gt;, and Nix&amp;rsquo;s daemon with the &lt;a href="https://next.devvm.dev/docs/internals/images/#the-nix-layer"&gt;nix layer&lt;/a&gt;. Under systemd, each daemon gets a drop-in, &lt;code&gt;devvm-proxy.conf&lt;/code&gt;, that holds the VM&amp;rsquo;s own proxy address and nothing else, and without systemd, Docker&amp;rsquo;s settings in &lt;code&gt;/etc/conf.d/docker&lt;/code&gt; get a block instead, and Nix&amp;rsquo;s daemon gets &lt;code&gt;/etc/conf.d/nix-daemon&lt;/code&gt;. Every VM has a proxy, an open one&amp;rsquo;s included, so every VM gets them, and the setup restarts a daemon whose settings changed. An ssh connection gets a &lt;code&gt;ProxyCommand&lt;/code&gt; that tunnels through the proxy, and the proxy checks its host and port against the allowlist.&lt;/li&gt;
&lt;li&gt;It writes &lt;code&gt;devvm-local-proxy&lt;/code&gt;, a proxy on the VM&amp;rsquo;s loopback that adds the VM&amp;rsquo;s password to each request, for browsers, which ask for a proxy&amp;rsquo;s password rather than take it from the proxy variables. The desktop layer starts it and points the desktop&amp;rsquo;s session at it (&lt;a href="https://next.devvm.dev/docs/internals/desktop/#the-local-proxy"&gt;the local proxy&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;With the nix layer, it points Nix at the &lt;a href="#the-shared-nix-cache"&gt;shared Nix cache&lt;/a&gt; first: &lt;code&gt;/etc/nix/devvm-cache.conf&lt;/code&gt;, which &lt;code&gt;/etc/nix/nix.conf&lt;/code&gt; includes with &lt;code&gt;!include&lt;/code&gt;, sets &lt;code&gt;substituters = http://devvm.proxy/nix https://cache.nixos.org&lt;/code&gt;. Every VM gets that file, an open one&amp;rsquo;s included, and the setup restarts Nix&amp;rsquo;s daemon when the file changed.&lt;/li&gt;
&lt;li&gt;It sets &lt;code&gt;NO_PROXY&lt;/code&gt; and &lt;code&gt;no_proxy&lt;/code&gt; to the VM itself, &lt;code&gt;localhost,127.0.0.1,::1&lt;/code&gt;, in the daemons&amp;rsquo; settings above and in Docker&amp;rsquo;s client settings (&lt;code&gt;~/.docker/config.json&lt;/code&gt;), as the VM&amp;rsquo;s backend does in the environment it sets at each start. The VM&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/ports/#links-between-vms"&gt;links&lt;/a&gt; aren&amp;rsquo;t in it, because HTTP clients reach them &lt;a href="#links-through-the-proxy"&gt;through the proxy&lt;/a&gt;, so a change of links changes no daemon&amp;rsquo;s settings and restarts nothing.&lt;/li&gt;
&lt;li&gt;It puts the VM&amp;rsquo;s placeholders in &lt;code&gt;~/.config/devvm/env&lt;/code&gt;, which login shells read, as &lt;code&gt;CLAUDE_CODE_OAUTH_TOKEN&lt;/code&gt; and &lt;code&gt;GH_TOKEN&lt;/code&gt;. When &lt;code&gt;github&lt;/code&gt; is bound, it also sets up git&amp;rsquo;s credential helper for GitHub over HTTPS.&lt;/li&gt;
&lt;li&gt;It adds &lt;code&gt;devvm-why&lt;/code&gt;, the note before each prompt, and the notes for Claude Code and Codex (&lt;a href="https://next.devvm.dev/docs/safety/network/#inside-the-vm"&gt;inside the VM&lt;/a&gt;). &lt;code&gt;devvm-why&lt;/code&gt; prints the proxy&amp;rsquo;s &lt;code&gt;/blocked&lt;/code&gt;, and when that list is empty, the proxy&amp;rsquo;s answer adds that a connection refused, or a DNS error, for an allowed host comes from a tool that skipped the proxy where devvm can&amp;rsquo;t send it there, with a link to &lt;a href="https://next.devvm.dev/docs/using/troubleshooting/#a-tool-that-skips-the-proxy-fails"&gt;troubleshooting&lt;/a&gt;. With transparent mode, &lt;code&gt;devvm-why&lt;/code&gt; then prints &lt;code&gt;devvm-transparent status&lt;/code&gt; as root, through &lt;code&gt;sudo -n&lt;/code&gt;. The notes, a block between &lt;code&gt;&amp;lt;!-- devvm-proxy --&amp;gt;&lt;/code&gt; markers in &lt;code&gt;~/.claude/CLAUDE.md&lt;/code&gt; and &lt;code&gt;~/.codex/AGENTS.md&lt;/code&gt;, say to run &lt;code&gt;devvm-why&lt;/code&gt; after a connection error or a &lt;code&gt;403&lt;/code&gt; from the proxy, that a tool that ignores the proxy settings still reaches the proxy by name over HTTPS, HTTP and the ports the rules name, and that a refused connection on another port, or a DNS error, while &lt;code&gt;devvm-why&lt;/code&gt; shows nothing blocked means the tool skipped the proxy and needs its own proxy setting or &lt;code&gt;$HTTPS_PROXY&lt;/code&gt;. The setup writes them only when the VM has a proxy address, and replaces the block on every launch.&lt;/li&gt;
&lt;li&gt;On a VM that runs confined to its proxy, with transparent mode on, it sets up &lt;a href="#tools-that-skip-the-proxy"&gt;transparent mode&lt;/a&gt;, and on any other VM it takes transparent mode out.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each placeholder ends in a random value of the VM&amp;rsquo;s own, its salt, which isn&amp;rsquo;t its password.&lt;/p&gt;
&lt;h2 data-hextra-search-id="tools-that-skip-the-proxy"&gt;Tools that skip the proxy&lt;span class="hx:absolute hx:-mt-20" id="tools-that-skip-the-proxy"&gt;&lt;/span&gt;
&lt;a href="#tools-that-skip-the-proxy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;On a confined VM, transparent mode sends a tool that ignores the proxy settings to the VM&amp;rsquo;s proxy by the names it looks up (&lt;a href="https://next.devvm.dev/docs/safety/network/#tools-that-ignore-the-proxy"&gt;what it covers&lt;/a&gt;). Nothing new runs or listens on the host, and the backends don&amp;rsquo;t change: the VM reaches its proxy over the path its proxy settings use, and the proxy judges each connection as it judges &lt;code&gt;CONNECT host:port&lt;/code&gt;. Every piece in the VM is a program that devvm configures, dnsmasq, nftables and socat, which base installs, and one script, &lt;code&gt;devvm-transparent&lt;/code&gt;, which each launch sends. A tool that looks up &lt;code&gt;api.example.com&lt;/code&gt; and connects to it goes this way:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Its lookup reaches dnsmasq in the VM. glibc and musl both ask &lt;code&gt;127.0.0.1:53&lt;/code&gt; themselves, which is where Lima&amp;rsquo;s DNS setting for a confined VM points (&lt;a href="#the-vms-resolver"&gt;the VM&amp;rsquo;s resolver&lt;/a&gt;). An nftables rule sends &lt;code&gt;127.0.0.1:53&lt;/code&gt; to dnsmasq, which listens on the stand-in address, &lt;code&gt;198.18.0.1&lt;/code&gt;, alone. That rule takes every connection to &lt;code&gt;127.0.0.1:53&lt;/code&gt; in the VM, so a DNS server of the user&amp;rsquo;s own there, or a forward of port 53 to it, gets nothing.&lt;/li&gt;
&lt;li&gt;dnsmasq answers the A query with &lt;code&gt;198.18.0.1&lt;/code&gt;, with a time to live of 0, and every other type, AAAA and HTTPS included, with an empty answer, never &lt;code&gt;REFUSED&lt;/code&gt;, which musl waits 5 seconds on. It has no upstream server, so no query leaves the VM, and it reads &lt;code&gt;/etc/hosts&lt;/code&gt; first, so &lt;code&gt;localhost&lt;/code&gt;, the VM&amp;rsquo;s hostname, &lt;code&gt;host.lima.internal&lt;/code&gt; and the &lt;a href="https://next.devvm.dev/docs/internals/ports/#links-between-vms"&gt;links&lt;/a&gt;&amp;rsquo; names keep their own addresses. Names under &lt;code&gt;devvm.internal&lt;/code&gt; that aren&amp;rsquo;t a link&amp;rsquo;s don&amp;rsquo;t exist, and neither does a name without a dot, nor a name under the search domains that the VM&amp;rsquo;s resolver appends to one, which Lima takes from this machine&amp;rsquo;s network and dnsmasq reads from &lt;code&gt;/etc/resolv.conf&lt;/code&gt; as it starts. So a single-label name that isn&amp;rsquo;t in &lt;code&gt;/etc/hosts&lt;/code&gt; doesn&amp;rsquo;t resolve, rather than turning into a name of this machine&amp;rsquo;s network. dnsmasq can&amp;rsquo;t tell a name the resolver made that way from one a tool names whole, so every name under those domains gets no answer, such as &lt;code&gt;git.corp.example.com&lt;/code&gt; under &lt;code&gt;corp.example.com&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The tool connects to &lt;code&gt;198.18.0.1:443&lt;/code&gt;. The address is on the VM&amp;rsquo;s loopback interface, so the connection stays in the VM, and an nftables rule sends it to a socat listener on &lt;code&gt;198.18.0.1:61443&lt;/code&gt;. Nothing binds port 443 or 80 itself, so your own servers keep them.&lt;/li&gt;
&lt;li&gt;socat opens an ordinary &lt;code&gt;CONNECT transparent.devvm.proxy:443&lt;/code&gt; to the VM&amp;rsquo;s proxy, with the VM&amp;rsquo;s password, which it reads from a file, never from its arguments. Each port has a listener of its own, so the port reaches the proxy in the target, and nothing the VM sends can change it.&lt;/li&gt;
&lt;li&gt;The proxy checks the password, takes one of the VM&amp;rsquo;s 1024 tunnel slots, and reads the connection&amp;rsquo;s first bytes for at most 10 seconds. A TLS record is read whole, and its ClientHello&amp;rsquo;s server name (SNI) is the host. An HTTP/1.x request line or HTTP/2&amp;rsquo;s preface makes each request&amp;rsquo;s &lt;code&gt;Host&lt;/code&gt; the host, judged on its own. Anything else is refused and logged as a refused block of &lt;code&gt;transparent.devvm.proxy&lt;/code&gt;, with why: no SNI, an address as the SNI, a name with anything but ASCII, a name under &lt;code&gt;devvm.proxy&lt;/code&gt;, or bytes that name no host, such as SSH&amp;rsquo;s, Postgres&amp;rsquo;s &lt;code&gt;SSLRequest&lt;/code&gt; or a server that speaks first.&lt;/li&gt;
&lt;li&gt;From there the connection is &lt;code&gt;CONNECT host:443&lt;/code&gt;: the links, the policy and the floor, interception for a bound host, the tunnel and its SNI check, the log, and &lt;code&gt;/blocked&lt;/code&gt;, in the order &lt;code&gt;CONNECT&lt;/code&gt; has them. The ClientHello goes on to whatever serves it first, so the far end gets it byte for byte. The proxy dials the host it judged, by name, so the VM can&amp;rsquo;t name one host and reach another. Its events carry &lt;code&gt;&amp;quot;via&amp;quot;: &amp;quot;dns&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A blocked TLS host gets a TLS handshake with a certificate for its SNI name from the VM&amp;rsquo;s own CA, signed as interception signs, then the proxy&amp;rsquo;s &lt;code&gt;403&lt;/code&gt; text for every request on the connection, over HTTP/1.1 or HTTP/2. The proxy resolves nothing and dials nothing for it. Without a CA, or once it has ended, the connection closes, and the block is logged all the same. A plain HTTP request is always forwarded as &lt;code&gt;http://&lt;/code&gt;, whatever its request line says, so no secret goes into it, and a &lt;code&gt;Host&lt;/code&gt; that names another port than the connection&amp;rsquo;s gets &lt;code&gt;400&lt;/code&gt;, as does a &lt;code&gt;CONNECT&lt;/code&gt; inside it. A link&amp;rsquo;s name gets a refused block on both ways, because dnsmasq never gives a link&amp;rsquo;s name the stand-in address. Its name in &lt;code&gt;/etc/hosts&lt;/code&gt; reaches it. A &lt;code&gt;Host&lt;/code&gt; of &lt;code&gt;devvm.proxy&lt;/code&gt; reaches &lt;code&gt;/blocked&lt;/code&gt; alone and gets &lt;code&gt;403&lt;/code&gt; for every other endpoint, the CA, the ports and the Nix cache, because socat adds the password for any client, a container without the proxy settings included.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The ports.&lt;/strong&gt; The proxy serves the ports to redirect at &lt;code&gt;http://devvm.proxy/transparent/ports&lt;/code&gt;: 80 and 443, then each port an allow rule names for hosts by name, &lt;code&gt;**:8443&lt;/code&gt; included, the lowest first, at most 32 of them. It leaves out &lt;code&gt;:*&lt;/code&gt;, address rules&amp;rsquo; ports, 22 and 53, and every port but 80 and 443 while a deny is broken. The proxy&amp;rsquo;s own log names the ports past 32, once each time they change. &lt;code&gt;devvm-transparent&lt;/code&gt; fetches the list every 10 seconds and at each launch, and takes it only when it&amp;rsquo;s 2 to 34 ports, each once, with 80 and 443 and neither 22 nor 53. A new port gets the lowest free listener from 61100 to 61131, and a port that stays keeps its own. The list shows the VM the ports its rules name, never their hosts, which it can&amp;rsquo;t read otherwise. That&amp;rsquo;s a small disclosure, and it gives the VM nothing to reach: each connection is still judged by its own host and port.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The nftables table.&lt;/strong&gt; The table &lt;code&gt;inet devvm_transparent&lt;/code&gt; is loaded whole, in one transaction, and &lt;code&gt;devvm-transparent&lt;/code&gt; loads it again within 10 seconds when something removes it, such as &lt;code&gt;nft flush ruleset&lt;/code&gt;. Its NAT chains run at priority -110, before Docker&amp;rsquo;s at -100, and the first NAT chain that gives a connection a mapping is the only one that does, so they give every TCP and UDP port of the stand-in address one: a redirected port goes to its listener, DNS to dnsmasq, and every other port to port 61079, where nothing listens, so the kernel refuses it at once with a reset, or for UDP, QUIC included, with a port-unreachable. Docker&amp;rsquo;s chains, which would send a published port&amp;rsquo;s traffic to a container, so never see the stand-in address, and neither a VM process nor a container that connects to &lt;code&gt;db.example.com:5432&lt;/code&gt; reaches a container that publishes 5432. The refused connections are logged in the kernel&amp;rsquo;s log, five a second at most, which &lt;code&gt;devvm-transparent status&lt;/code&gt; reads. DNS to any public server goes to dnsmasq too, from the VM and from Docker&amp;rsquo;s bridges (&lt;code&gt;docker0&lt;/code&gt; and &lt;code&gt;br-*&lt;/code&gt;), so Docker&amp;rsquo;s fallback servers, &lt;code&gt;8.8.8.8&lt;/code&gt; and &lt;code&gt;8.8.4.4&lt;/code&gt;, and resolvers that tools hard-code reach it. So does DNS to the VM&amp;rsquo;s own name servers but loopback&amp;rsquo;s, as &lt;code&gt;/etc/resolv.conf&lt;/code&gt; and systemd-resolved&amp;rsquo;s list name them, such as the one Lima&amp;rsquo;s DHCP adds beside &lt;code&gt;127.0.0.1&lt;/code&gt;, which Docker gives its containers once it drops the loopback one; &lt;code&gt;devvm-transparent&lt;/code&gt; reads them again every 10 seconds. Other loopback addresses, private, link-local and CGNAT ones are left alone, so a DNS server on a container&amp;rsquo;s or the LAN&amp;rsquo;s address still answers, and Lima&amp;rsquo;s DNS addresses that aren&amp;rsquo;t the VM&amp;rsquo;s name servers answer nothing, as the host&amp;rsquo;s confinement has it. Two filter chains run before every NAT chain, at priority -150: one drops traffic to the stand-in address from any interface but the loopback and Docker&amp;rsquo;s bridges, such as Podman&amp;rsquo;s or LXD&amp;rsquo;s bridges and Lima&amp;rsquo;s network, and both drop anything to it but TCP, UDP and ICMP, such as SCTP, which no NAT rule maps. So neither reaches Docker&amp;rsquo;s DNAT of a published port through the stand-in address. An input rule keeps the same interfaces off it again, and only connections the NAT rules translated, and DNS, reach it. The listeners&amp;rsquo; ports, 61080, 61443 and 61100 to 61131, and the dead port, 61079, are above Linux&amp;rsquo;s range for outgoing connections, 32768 to 60999, so no connection out is given one.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The service.&lt;/strong&gt; &lt;code&gt;devvm-transparent run&lt;/code&gt; is the service, under systemd or OpenRC, as root: it adds &lt;code&gt;198.18.0.1/32&lt;/code&gt; to &lt;code&gt;lo&lt;/code&gt;, loads the table, starts dnsmasq and a socat listener for each port, and then restarts any of them that ends within a second, sends dnsmasq &lt;code&gt;SIGHUP&lt;/code&gt; when &lt;code&gt;/etc/hosts&lt;/code&gt; changes, and fetches the ports every tenth second. dnsmasq runs as the user &lt;code&gt;devvm-transparent&lt;/code&gt;, and so does each socat connection&amp;rsquo;s process, which reads the password file through its group. When the service stops, it removes the table, the address and what it started, so names stop resolving, and a stopped or broken service never leaves a way out. It starts at each boot, before any launch, with the last ports and settings, and each launch&amp;rsquo;s setup turns it on, off, or restarts it when its settings changed, such as a new proxy port or password. Its files are root&amp;rsquo;s, in &lt;code&gt;/etc/devvm/transparent&lt;/code&gt;, and the VM&amp;rsquo;s password, which every program in the VM has in its environment already, is in files only, never in a process&amp;rsquo;s arguments. On an open VM, and with transparent mode off, the setup stops and removes all of it, and flushes systemd-resolved&amp;rsquo;s cache. The setup decides by the confinement the VM runs with, so a VM whose tier changed into or out of open keeps what it had until its next start.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What doesn&amp;rsquo;t change.&lt;/strong&gt; The host&amp;rsquo;s confinement is the boundary: root in the VM can change or stop all of this, and then names stop resolving, or a query to Lima&amp;rsquo;s DNS goes nowhere, as for a VM without transparent mode. The &lt;a href="#the-self-check"&gt;self-check&lt;/a&gt;&amp;rsquo;s direct connection is to an address on port 443, so transparent mode never answers it. The VM&amp;rsquo;s names never reach the host&amp;rsquo;s resolver for a blocked host, because the proxy asks the policy before it resolves anything. &lt;a href="https://next.devvm.dev/docs/contributing/design/#transparent-mode"&gt;Design notes&lt;/a&gt; has the threat check.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-vms-resolver"&gt;The VM&amp;rsquo;s resolver&lt;span class="hx:absolute hx:-mt-20" id="the-vms-resolver"&gt;&lt;/span&gt;
&lt;a href="#the-vms-resolver" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;On a confined VM, Lima&amp;rsquo;s DNS setting gives the guest one name server, its own &lt;code&gt;127.0.0.1&lt;/code&gt;, and each launch&amp;rsquo;s setup makes the system&amp;rsquo;s resolver ask it directly. systemd-resolved&amp;rsquo;s stub, &lt;code&gt;127.0.0.53&lt;/code&gt;, would ask &lt;code&gt;127.0.0.1&lt;/code&gt; in turn, and when nothing listens there, because transparent mode is off or stopped, the stub can keep retrying it over UDP and TCP without answering, so a lookup through glibc waits out its own timeout instead of failing. So the setup replaces &lt;code&gt;/etc/resolv.conf&lt;/code&gt;, which on Ubuntu is a link to the stub&amp;rsquo;s file, with a file of its own that names &lt;code&gt;127.0.0.1&lt;/code&gt; alone, with the stub&amp;rsquo;s search line and a timeout of one second, tried twice, which is plenty because dnsmasq answers in the VM itself. glibc then gets a refusal at once when nothing listens, and dnsmasq&amp;rsquo;s answer through the nftables rule when transparent mode runs, as musl on Alpine does.&lt;/p&gt;
&lt;p&gt;systemd-resolved still runs, so &lt;code&gt;resolvectl&lt;/code&gt; and the programs that ask it over D-Bus still go through it. Docker reads &lt;code&gt;/etc/resolv.conf&lt;/code&gt; and finds only a loopback server there, so on its default bridge it gives containers its fallback servers, and on a network of their own, such as Compose&amp;rsquo;s, its embedded DNS server asks &lt;code&gt;127.0.0.1&lt;/code&gt; from the VM&amp;rsquo;s side. The nftables table sends both to dnsmasq. The setup writes its file only on a guest with systemd that has the stub&amp;rsquo;s file and whose &lt;code&gt;/etc/resolv.conf&lt;/code&gt; is the stub&amp;rsquo;s link or the setup&amp;rsquo;s own file, so a file or link of your own stays, and it copies the search line again at each launch. When it can&amp;rsquo;t write the file, it says so in one line and the launch goes on. systemd-resolved reads a file that isn&amp;rsquo;t its own link as servers and search domains of its own, so while the VM is confined it takes &lt;code&gt;127.0.0.1&lt;/code&gt; from the setup&amp;rsquo;s file, and a search line of &lt;code&gt;.&lt;/code&gt; sends every name there. It keeps them after the file is a link again, until it restarts. So on an open VM, the setup puts the stub&amp;rsquo;s link back and restarts systemd-resolved, which then asks Lima&amp;rsquo;s DNS. Going back needs only the setup&amp;rsquo;s own file, which it writes nowhere else, and when the stub&amp;rsquo;s file is missing afterwards, the setup says that names may not resolve.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-shared-nix-cache"&gt;The shared Nix cache&lt;span class="hx:absolute hx:-mt-20" id="the-shared-nix-cache"&gt;&lt;/span&gt;
&lt;a href="#the-shared-nix-cache" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;VMs with the &lt;a href="https://next.devvm.dev/docs/internals/images/#the-nix-layer"&gt;nix layer&lt;/a&gt; share their downloads from Nix&amp;rsquo;s binary cache, so each package comes from cache.nixos.org once per machine instead of once per VM. Each VM keeps its own Nix store and daemon, and only the host writes the cache, so no VM can change what another VM gets. The &lt;a href="https://next.devvm.dev/docs/contributing/design/#the-shared-nix-cache"&gt;design note&lt;/a&gt; says why it&amp;rsquo;s a cache that the host fills rather than a shared store.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In the VM.&lt;/strong&gt; devvm starts the VM&amp;rsquo;s proxy with &lt;code&gt;nix_cache&lt;/code&gt; set to &lt;code&gt;~/.local/share/devvm/cache/nix-cache&lt;/code&gt; in its config when the VM&amp;rsquo;s image has the nix layer, and the VM&amp;rsquo;s setup puts &lt;code&gt;http://devvm.proxy/nix&lt;/code&gt; before &lt;code&gt;https://cache.nixos.org&lt;/code&gt; in Nix&amp;rsquo;s &lt;code&gt;substituters&lt;/code&gt; (&lt;a href="#the-vms-setup"&gt;the VM&amp;rsquo;s setup&lt;/a&gt;). It leaves &lt;code&gt;trusted-public-keys&lt;/code&gt; as Nix has it, which is cache.nixos.org&amp;rsquo;s key alone. Nix&amp;rsquo;s daemon reaches &lt;code&gt;devvm.proxy&lt;/code&gt; through its own proxy settings, so its requests are absolute-form &lt;code&gt;GET&lt;/code&gt;s with the VM&amp;rsquo;s password, and the proxy answers them itself, as it does &lt;code&gt;/blocked&lt;/code&gt; and &lt;code&gt;/ca.pem&lt;/code&gt;, and never forwards them. When the cache answers with anything but a file, Nix goes on to cache.nixos.org, through the proxy as any other download.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What a VM can ask for.&lt;/strong&gt; The proxy takes only &lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;HEAD&lt;/code&gt; requests with no query, for three kinds of path under &lt;code&gt;/nix/&lt;/code&gt;. These are &lt;code&gt;nix-cache-info&lt;/code&gt;, a narinfo named &lt;code&gt;&amp;lt;hash&amp;gt;.narinfo&lt;/code&gt; with a 32-character hash in Nix&amp;rsquo;s base 32, and a NAR named &lt;code&gt;nar/&amp;lt;hash&amp;gt;.nar&lt;/code&gt; with a 52-character hash and no suffix or &lt;code&gt;.xz&lt;/code&gt;, &lt;code&gt;.zst&lt;/code&gt; or &lt;code&gt;.bz2&lt;/code&gt;. Anything else gets &lt;code&gt;400&lt;/code&gt;. The proxy makes up &lt;code&gt;nix-cache-info&lt;/code&gt; itself, with priority 30, so Nix asks the cache before cache.nixos.org, whose priority is 40. It serves the other files from the folder, or fetches them from &lt;code&gt;https://cache.nixos.org&lt;/code&gt; when the VM&amp;rsquo;s policy allows &lt;code&gt;cache.nixos.org:443&lt;/code&gt; and, when &lt;a href="#requests-by-method-and-path"&gt;rules by method and path&lt;/a&gt; narrow that host, a &lt;code&gt;GET&lt;/code&gt; of the file&amp;rsquo;s path there. That&amp;rsquo;s the only host it fetches from, and its fetches go through the same address floor and company proxy as the VM&amp;rsquo;s own requests. It follows no redirect, and nothing of the VM&amp;rsquo;s request goes with it, so nothing a VM sends is ever stored.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What the host checks.&lt;/strong&gt; Before it keeps a narinfo, the proxy checks that its &lt;code&gt;StorePath&lt;/code&gt; is the path the VM asked for, and that &lt;code&gt;cache.nixos.org-1&lt;/code&gt;, whose Ed25519 key devvm pins, signed its fingerprint, &lt;code&gt;1;StorePath;NarHash;NarSize;References&lt;/code&gt;. The signature doesn&amp;rsquo;t cover the NAR&amp;rsquo;s URL, so the proxy also checks that the URL is named by the narinfo&amp;rsquo;s own &lt;code&gt;NarHash&lt;/code&gt; or &lt;code&gt;FileHash&lt;/code&gt;, and no narinfo can put a file in another NAR&amp;rsquo;s place. It fetches a NAR only after it checked a narinfo that names it, never for a &lt;code&gt;HEAD&lt;/code&gt;, and it keeps the NAR only when its SHA-256 and size are that narinfo&amp;rsquo;s &lt;code&gt;FileHash&lt;/code&gt; and &lt;code&gt;FileSize&lt;/code&gt;. The host can&amp;rsquo;t check a NAR&amp;rsquo;s &lt;code&gt;NarHash&lt;/code&gt;, which is the hash of the archive before compression, because the proxy uses Go&amp;rsquo;s standard library alone, and that has no xz or zstd. Each VM&amp;rsquo;s Nix checks the signature and the &lt;code&gt;NarHash&lt;/code&gt; again, so a narinfo with an added reference, or a corrupted NAR, fails there too. A file that fails a check, a not-found and an error all get &lt;code&gt;404&lt;/code&gt;, and the proxy keeps nothing of them, so Nix goes to cache.nixos.org itself.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The folder and its cap.&lt;/strong&gt; The proxy writes each file whole into a temporary file in the folder, then renames it into place, mode 600 in folders of 700. The cache&amp;rsquo;s cap is the &lt;code&gt;nix-cache.size&lt;/code&gt; &lt;a href="https://next.devvm.dev/docs/using/settings/#retention"&gt;retention setting&lt;/a&gt;, 10 GiB when it&amp;rsquo;s off, which devvm puts in the proxy&amp;rsquo;s config as &lt;code&gt;nix_cache_max&lt;/code&gt; when the proxy starts. The cap counts the disk each file takes, in whole blocks, and a NAR being fetched counts at its full size from the start. When a new file would take the cache past its cap, the proxy deletes the least recently used files, down to nine tenths of the cap, and when the NARs being fetched leave no room, it refuses the fetch. One proxy fetches each NAR once, however many requests ask for it, and at most four at once. A request that missed the cache looks again once it&amp;rsquo;s its turn to fetch, so a fetch that ended in between is served from the cache, not downloaded and counted against the cap a second time. A hit marks a file used by setting its modification time. Every VM&amp;rsquo;s proxy and devvm gc take one lock on the folder before they change it, so the cap holds while many VMs fill it, and a running total in the folder saves counting it for each file. Each tries the lock without waiting, again and again for at most 5 seconds, because a proxy&amp;rsquo;s child that a VM took over could hold it for ever. Past that, the request gets &lt;code&gt;404&lt;/code&gt;, so Nix goes to cache.nixos.org itself, and devvm gc skips the trim and says so (&lt;code&gt;nix_cache_locked&lt;/code&gt;). devvm gc and the daily retention run also trim the cache to its cap, and &lt;code&gt;devvm gc --nix-cache&lt;/code&gt; empties it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What a child could leave there.&lt;/strong&gt; A VM&amp;rsquo;s proxy&amp;rsquo;s child writes the cache, so devvm reads it as it reads a file a VM can write. Its trim and its count of the cache open the folder as a root that no link leads out of, take &lt;code&gt;nar/&lt;/code&gt; only when it&amp;rsquo;s a folder and never a link, count and delete only regular files, and delete a link as itself, never what it leads to, so a link a child leaves never leads devvm to your files. Each proxy makes &lt;code&gt;nar/&lt;/code&gt; and sets the cache&amp;rsquo;s folders to yours alone through the folders it opened, never by their paths. The proxy deletes anything at &lt;code&gt;nar/&lt;/code&gt; that isn&amp;rsquo;t a folder, such as a link, as itself, makes a folder in its place and warns of it in its log, so its change of mode never reaches a folder of yours. Every proxy reads a cached file only when it&amp;rsquo;s a regular file, never through a link and without waiting on a FIFO, and takes the lock only on a regular file with one link.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Logs.&lt;/strong&gt; Each request is a &lt;code&gt;nix-cache&lt;/code&gt; event in the VM&amp;rsquo;s own &lt;a href="#log-files"&gt;log&lt;/a&gt;, with its path and what came of it: &lt;code&gt;hit&lt;/code&gt;, &lt;code&gt;fetched&lt;/code&gt;, or why it wasn&amp;rsquo;t found or was refused. &lt;code&gt;devvm network log&lt;/code&gt; shows these as &lt;code&gt;cache&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Open VMs&lt;/strong&gt; have their proxy too, so they share the cache. An open proxy allows cache.nixos.org as it allows every host.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What stays open.&lt;/strong&gt; What one VM can learn of another through the cache, and how it can push other VMs&amp;rsquo; files out, is under &lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#network"&gt;Attack vectors&lt;/a&gt;. Private caches, such as Cachix or one behind a &lt;code&gt;netrc&lt;/code&gt;, are never shared, because only root in a VM can add a substituter, and Nix reaches it directly through the proxy&amp;rsquo;s allowlist.&lt;/p&gt;
&lt;h2 data-hextra-search-id="a-companys-ca"&gt;A company&amp;rsquo;s CA&lt;span class="hx:absolute hx:-mt-20" id="a-companys-ca"&gt;&lt;/span&gt;
&lt;a href="#a-companys-ca" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The CA certificates in &lt;code&gt;~/.config/devvm/ca&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/using/settings/#a-companys-ca"&gt;a company&amp;rsquo;s CA&lt;/a&gt;) reach every project VM, whatever its tier, and the VM&amp;rsquo;s proxy. Builds trust them too, as &lt;a href="https://next.devvm.dev/docs/internals/images/#a-companys-ca-in-builds"&gt;Images and caching&lt;/a&gt; describes, and so does the mise that resolves the shared tools&amp;rsquo; versions on this machine, which on macOS trusts them for every connection but its Sigstore client&amp;rsquo;s, as the host&amp;rsquo;s mise below explains.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reading them.&lt;/strong&gt; devvm reads the folder&amp;rsquo;s &lt;code&gt;*.pem&lt;/code&gt; and &lt;code&gt;*.crt&lt;/code&gt; files at each launch, each build, each proxy start and each run of the host&amp;rsquo;s mise, and nothing outside the folder. It looks at the folder and each of those files itself, never at what a link leads to, and follows no link: a folder that is a link fails with &lt;code&gt;ca_folder_link&lt;/code&gt;, and a file that is one, dangling or not, with &lt;code&gt;ca_link&lt;/code&gt;. A link into a project folder would otherwise let that project&amp;rsquo;s VM write the CA that every VM, build and proxy trusts. A file or folder that it can&amp;rsquo;t read fails with &lt;code&gt;ca_unreadable&lt;/code&gt; or &lt;code&gt;ca_folder_unreadable&lt;/code&gt;, which name it and carry the error. It decodes every PEM block and refuses a block that isn&amp;rsquo;t &lt;code&gt;CERTIFICATE&lt;/code&gt; (&lt;code&gt;ca_not_certificate&lt;/code&gt;), a certificate that &lt;code&gt;crypto/x509&lt;/code&gt; can&amp;rsquo;t parse (&lt;code&gt;ca_invalid&lt;/code&gt;) and a certificate without CA basic constraints (&lt;code&gt;ca_not_ca&lt;/code&gt;). It also refuses a file with no certificate in it. It tells a private key apart by its PEM type, not by the file&amp;rsquo;s name, and a refusal fails the whole launch or build. What leaves the host is each certificate encoded again from its parsed bytes, once each, so the text around a block never does.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Installing them.&lt;/strong&gt; devvm&amp;rsquo;s guest script &lt;code&gt;ca.sh DIR&lt;/code&gt; runs as root and makes devvm&amp;rsquo;s CAs in &lt;code&gt;/usr/local/share/ca-certificates&lt;/code&gt; exactly DIR&amp;rsquo;s &lt;code&gt;devvm-*.crt&lt;/code&gt; files: the VM&amp;rsquo;s own CA and its next one, &lt;code&gt;devvm-proxy.crt&lt;/code&gt; and &lt;code&gt;devvm-proxy-next.crt&lt;/code&gt;, and the user&amp;rsquo;s &lt;code&gt;devvm-extra-N.crt&lt;/code&gt;. When anything changed, it runs &lt;code&gt;update-ca-certificates --fresh&lt;/code&gt;, so a CA that went leaves neither the bundle nor its hashed link. &lt;code&gt;update-ca-certificates&lt;/code&gt; tells the hooks in &lt;code&gt;/etc/ca-certificates/update.d&lt;/code&gt; only about the CAs it links, never about a file that was deleted, so &lt;code&gt;ca.sh&lt;/code&gt; tells them itself. It runs each hook that &lt;code&gt;run-parts&lt;/code&gt; would run, with a &lt;code&gt;-/etc/ssl/certs/NAME.pem&lt;/code&gt; line on its input for each CA it removed, as Debian&amp;rsquo;s &lt;code&gt;update-ca-certificates&lt;/code&gt; does for a CA it deselects. That way Java&amp;rsquo;s &lt;code&gt;cacerts&lt;/code&gt; (ca-certificates-java&amp;rsquo;s &lt;code&gt;jks-keystore&lt;/code&gt; hook) and Mono&amp;rsquo;s store drop a removed CA, in a project VM and in an image whose layer installed Java. A hook that rebuilds its store from the bundle ignores that input. A hook that fails stops nothing, and &lt;code&gt;ca.sh&lt;/code&gt; says so in the run log. It also writes them all to &lt;code&gt;/etc/ssl/devvm.pem&lt;/code&gt;, for Node. In a system without &lt;code&gt;update-ca-certificates&lt;/code&gt;, such as a container image before its &lt;code&gt;ca-certificates&lt;/code&gt; package, it adds them to &lt;code&gt;/etc/ssl/certs/ca-certificates.crt&lt;/code&gt; itself. It keeps the bundle as it was in &lt;code&gt;/var/lib/devvm-ca&lt;/code&gt;, or a mark that there was none, and puts it back once they go, and a package that arrives in between makes the bundle again from the same folder. Run without DIR, &lt;code&gt;ca.sh&lt;/code&gt; removes every one of devvm&amp;rsquo;s files. Its unit tests run it in a folder that stands for &lt;code&gt;/&lt;/code&gt; (&lt;code&gt;DEVVM_CA_ROOT&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Project VMs.&lt;/strong&gt; The setup that devvm sends at each launch carries &lt;code&gt;ca.sh&lt;/code&gt; and the certificates in &lt;code&gt;ca/&lt;/code&gt;, and &lt;code&gt;sync.sh&lt;/code&gt; runs it, so a change applies at the next launch and a running VM needs no restart. Every project VM starts with the CAs&amp;rsquo; variables below in its environment, whatever its tier and whether there are CAs or not, so adding a CA changes nothing that its backend sets at a start. On Lima, the clone that makes the VM sets the environment too, and the VM&amp;rsquo;s first start adds its proxy&amp;rsquo;s address to it in the one edit before its first boot. The variables are &lt;code&gt;NODE_EXTRA_CA_CERTS=/etc/ssl/devvm.pem&lt;/code&gt;, which is empty when there are none (Node warns only about a missing file), &lt;code&gt;SSL_CERT_FILE&lt;/code&gt;, &lt;code&gt;REQUESTS_CA_BUNDLE&lt;/code&gt; and &lt;code&gt;PIP_CERT&lt;/code&gt;, set to the system&amp;rsquo;s bundle, and &lt;code&gt;UV_SYSTEM_CERTS=1&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The proxy.&lt;/strong&gt; As devvm readies a VM&amp;rsquo;s proxy, it reads the folder too, and writes the bundle into the proxy&amp;rsquo;s config, &lt;code&gt;proxy.json&lt;/code&gt; in the VM&amp;rsquo;s run folder, as &lt;code&gt;upstream_cas&lt;/code&gt;, which the proxy adds to the system&amp;rsquo;s roots for its own TLS connections. Each secret lookup&amp;rsquo;s context carries those roots, and an agent&amp;rsquo;s OAuth refresh on the host takes them from there and sets them on its client, so it goes through a company proxy that inspects TLS as the VM&amp;rsquo;s own requests do. devvm&amp;rsquo;s other host requests, such as registry digests and Ubuntu&amp;rsquo;s image check, use the host&amp;rsquo;s own store, as the host&amp;rsquo;s other programs do. A VM can&amp;rsquo;t change that file or the folder, so the proxy&amp;rsquo;s roots grow only by what you put there. A proxy whose bundle differs from the folder&amp;rsquo;s starts again, as one whose CA was replaced does.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The host&amp;rsquo;s mise.&lt;/strong&gt; The client that downloads devvm&amp;rsquo;s own mise adds the folder&amp;rsquo;s CAs to the system&amp;rsquo;s roots, and a download whose server&amp;rsquo;s certificate it still doesn&amp;rsquo;t trust fails with &lt;code&gt;tools_untrusted&lt;/code&gt;, in place of &lt;code&gt;mise_download_failed&lt;/code&gt;. That mise, a release build, uses rustls with the platform&amp;rsquo;s verifier, so it trusts the system&amp;rsquo;s roots, and it falls back to Mozilla&amp;rsquo;s own only when none load. On Linux it reads the system&amp;rsquo;s roots from files, as OpenSSL does. When the environment sets neither &lt;code&gt;SSL_CERT_FILE&lt;/code&gt; nor &lt;code&gt;SSL_CERT_DIR&lt;/code&gt;, it reads the first bundle it finds, such as &lt;code&gt;/etc/ssl/certs/ca-certificates.crt&lt;/code&gt;, and the folders &lt;code&gt;/etc/ssl/certs&lt;/code&gt; and &lt;code&gt;/etc/pki/tls/certs&lt;/code&gt;, and otherwise it reads only what they name. On macOS it asks Security.framework, which trusts what the Keychain trusts and reads no variable. With CAs in the folder, each run of mise gets them in its temporary folder, and &lt;code&gt;MISE_EXTRA_CA_CERTS&lt;/code&gt; names them, which mise adds to its roots on both systems. mise&amp;rsquo;s Sigstore client, which fetches the trust root (&lt;code&gt;tuf-repo-cdn.sigstore.dev&lt;/code&gt;) that its lock-time provenance checks need, ignores that setting, so on Linux devvm also writes a bundle of the system&amp;rsquo;s bundle and the folder&amp;rsquo;s CAs, and &lt;code&gt;SSL_CERT_FILE&lt;/code&gt; names it, which every client in mise reads. The system&amp;rsquo;s bundle is the file that &lt;code&gt;SSL_CERT_FILE&lt;/code&gt; names when devvm&amp;rsquo;s environment sets it. When devvm&amp;rsquo;s environment sets neither variable, &lt;code&gt;SSL_CERT_DIR&lt;/code&gt; names the system&amp;rsquo;s folders, so mise still reads them. Otherwise mise reads the folders that devvm&amp;rsquo;s environment names, and none when it sets only &lt;code&gt;SSL_CERT_FILE&lt;/code&gt;, so a bundle of your own keeps mise to the CAs that you chose and the folder&amp;rsquo;s. On macOS nothing but the Keychain reaches that client, so a CA that a proxy signs that host with has to be trusted there. Each run of mise also logs to a file in its folder (&lt;code&gt;MISE_LOG_FILE&lt;/code&gt;). When a failed resolve&amp;rsquo;s log has rustls&amp;rsquo;s &lt;code&gt;invalid peer certificate&lt;/code&gt;, devvm fails with &lt;code&gt;tools_untrusted&lt;/code&gt;, which names the folder, in place of &lt;code&gt;tools_resolve_failed&lt;/code&gt; or &lt;code&gt;tools_need_resolve&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;End-to-end checks:&lt;/strong&gt; in &lt;code&gt;project&lt;/code&gt;, a VM trusts a test CA from its next launch (&lt;code&gt;openssl verify&lt;/code&gt; against the system&amp;rsquo;s bundle, and curl reaching an HTTPS server on the host that the CA signed), has the variables, fails its launch on a file that isn&amp;rsquo;t a certificate, and trusts the CA no more once the folder is emptied; in &lt;code&gt;tools&lt;/code&gt;, Node fetches from that server.&lt;/p&gt;
&lt;h2 data-hextra-search-id="secrets"&gt;Secrets&lt;span class="hx:absolute hx:-mt-20" id="secrets"&gt;&lt;/span&gt;
&lt;a href="#secrets" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href="https://next.devvm.dev/docs/safety/network/#secrets"&gt;Secrets&lt;/a&gt; lists each secret with its hosts and header. This section describes where devvm keeps them and how the proxy puts them into requests.&lt;/p&gt;
&lt;h3 data-hextra-search-id="where-secrets-are-saved"&gt;Where secrets are saved&lt;span class="hx:absolute hx:-mt-20" id="where-secrets-are-saved"&gt;&lt;/span&gt;
&lt;a href="#where-secrets-are-saved" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;On macOS, devvm saves a secret in the Keychain, under the service &lt;code&gt;devvm&lt;/code&gt; and the account that is the secret&amp;rsquo;s name, such as &lt;code&gt;claude&lt;/code&gt;, &lt;code&gt;github&lt;/code&gt; or &lt;code&gt;stripe&lt;/code&gt;. It saves it through &lt;code&gt;security -i&lt;/code&gt;, giving the value on its input, so the value is in no process&amp;rsquo;s arguments. &lt;code&gt;DEVVM_SECRET_SERVICE&lt;/code&gt; names another service, made of letters, digits, &lt;code&gt;.&lt;/code&gt;, &lt;code&gt;_&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt; only. On other systems, devvm saves a secret in &lt;code&gt;~/.local/share/devvm/secrets/&amp;lt;name&amp;gt;&lt;/code&gt;, a file only you can read.&lt;/p&gt;
&lt;p&gt;A &lt;a href="https://next.devvm.dev/docs/safety/network/#your-own-secrets"&gt;secret of your own&lt;/a&gt; keeps its value under &lt;code&gt;custom.&amp;lt;name&amp;gt;&lt;/code&gt;, as its Keychain account or its file&amp;rsquo;s name, which no known secret&amp;rsquo;s name can be, so a known secret that devvm adds later never finds a value of yours. Its definition is in &lt;code&gt;~/.local/share/devvm/custom-secrets.json&lt;/code&gt;: its name, an ID of 16 random bytes made as it&amp;rsquo;s first saved, its hosts, header, variable, prefix, scheme, path, methods and whether it may be Basic&amp;rsquo;s username, as one JSON object of &lt;code&gt;&amp;quot;version&amp;quot;: 1&lt;/code&gt;, written whole and mode 600, and never its value. A path that devvm writes there has &lt;code&gt;&amp;quot;path_pattern&amp;quot;: true&lt;/code&gt;, as &lt;code&gt;*&lt;/code&gt; in it is a wildcard, and devvm refuses a saved path with a &lt;code&gt;*&lt;/code&gt; but without it, which was saved as a prefix whose &lt;code&gt;*&lt;/code&gt; was itself, rather than read it as wider than it was saved, so the commands that read the list fail and name the file, as for any entry they refuse. devvm changes the list only while it holds &lt;code&gt;custom-secrets.lock&lt;/code&gt; beside it, so two runs of devvm secret set at once never lose one another&amp;rsquo;s secret. It saves the value before the definition, and when a new secret&amp;rsquo;s definition can&amp;rsquo;t be written, it deletes the value again. devvm secret rm unbinds a secret&amp;rsquo;s VMs and deletes it, and devvm secret use binds a VM to the definition that&amp;rsquo;s there, each under the same lock, so neither can come between the other&amp;rsquo;s check and its change. A value devvm can&amp;rsquo;t save whole is refused before the one saved is touched: &lt;code&gt;security -i&lt;/code&gt; reads its commands in lines of 4096 bytes, so a value has at most 3,800 bytes, and devvm checks the whole line before it runs &lt;code&gt;security&lt;/code&gt;. Each value is printable ASCII alone, because a header carries nothing else and the Keychain gives what isn&amp;rsquo;t back in hex.&lt;/p&gt;
&lt;p&gt;Inside devvm, a secret&amp;rsquo;s value has a type of its own from the moment devvm reads it, as you paste it, from the Keychain or its file, or from an agent&amp;rsquo;s login file, until the place that uses it. The same goes for a VM&amp;rsquo;s proxy password and the company proxy&amp;rsquo;s password. Printed in any way, in an error, a warning or devvm&amp;rsquo;s run log, that type shows &lt;code&gt;&amp;lt;redacted&amp;gt;&lt;/code&gt; and never the value, and devvm can&amp;rsquo;t write it into a file by accident, because only the files that must hold the real value write it: the Keychain or the secret&amp;rsquo;s file, the proxy&amp;rsquo;s config, the VM&amp;rsquo;s state and the agents&amp;rsquo; login files (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#secrets-in-the-code"&gt;secrets in the code&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Each VM&amp;rsquo;s state records, for each secret of yours it uses, the definition&amp;rsquo;s ID and the hosts the secret had when devvm secret use bound it. The VM&amp;rsquo;s binding has the secret&amp;rsquo;s hosts that are in that record, so a host the secret gains reaches a VM only once devvm secret use binds it again, and a VM bound to another definition by the name gets no binding at all. The proxy&amp;rsquo;s lookup checks every &lt;code&gt;secret&lt;/code&gt; binding against the secret as it&amp;rsquo;s saved before it gives a value: its hosts within the secret&amp;rsquo;s, and its header, scheme, path, methods, Basic username switch, ID and placeholder the secret&amp;rsquo;s own. A binding that doesn&amp;rsquo;t match gets nothing, and the proxy logs &lt;code&gt;secret_binding_changed&lt;/code&gt;. Writing the bindings of every running VM again goes on past a VM whose files can&amp;rsquo;t be written and returns every failure together, so one VM never keeps the others&amp;rsquo; proxies from dropping a secret. A proxy whose bindings file did change drops every value it has cached at once. One whose file couldn&amp;rsquo;t be written keeps a cached value for at most its 5 minutes, and only for the hosts it had. devvm checks every entry again each time it reads the list, as devvm secret set checks what you give it, so an entry edited by hand with a wildcard host or a known secret&amp;rsquo;s name is refused, and a list it can&amp;rsquo;t read fails the command that reads it, naming the file, rather than leaving a secret out. It reads the list as the proxy reads its own files: a regular file, not a symbolic link, that&amp;rsquo;s yours and that only you may write. Only a command that needs one of your secrets reads it, so a VM that uses none of them launches whatever the list holds. Your secrets&amp;rsquo; names never shadow devvm&amp;rsquo;s own, nor an agent&amp;rsquo;s login&amp;rsquo;s, whose bindings are named after the agent, such as &lt;code&gt;codex-key&lt;/code&gt; or &lt;code&gt;pi-openai&lt;/code&gt;, and their placeholders have &lt;code&gt;secret-&lt;/code&gt; before the name, which no login&amp;rsquo;s placeholder has. &lt;code&gt;devvm secret rm&lt;/code&gt; unbinds a secret of yours from each VM that uses it before it deletes the secret, so a failure part way leaves the secret saved rather than a VM bound to a name that a secret saved later could take.&lt;/p&gt;
&lt;h3 data-hextra-search-id="how-the-proxy-puts-them-in"&gt;How the proxy puts them in&lt;span class="hx:absolute hx:-mt-20" id="how-the-proxy-puts-them-in"&gt;&lt;/span&gt;
&lt;a href="#how-the-proxy-puts-them-in" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A secret&amp;rsquo;s hosts join the VM&amp;rsquo;s allowlist on port 443, whether a value is saved or not. A secret of yours has exact host names alone, because a wildcard would reach names that others may own under a shared domain, and devvm can&amp;rsquo;t tell those domains from the rest without the public suffix list.&lt;/p&gt;
&lt;p&gt;For each secret that has a value, devvm writes the VM&amp;rsquo;s bindings to &lt;code&gt;secrets.json&lt;/code&gt; in the VM&amp;rsquo;s run folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/&lt;/code&gt;, as one JSON object, whole and mode 600. It&amp;rsquo;s of &lt;code&gt;&amp;quot;version&amp;quot;: 1&lt;/code&gt; while every binding has no methods and no path but a prefix longer than &lt;code&gt;/&lt;/code&gt; that ends with &lt;code&gt;/&lt;/code&gt; and has no &lt;code&gt;*&lt;/code&gt;, so a proxy that knows only version 1, still running from before an upgrade, keeps the VM&amp;rsquo;s bindings, its agents&amp;rsquo; logins included. One from after bindings gained paths reads such a file alike. A proxy of devvm 0.1.0 or 0.1.1-rc.1 ignores the path, which for the built-in bindings only widens OpenRouter&amp;rsquo;s key to all of openrouter.ai, as 0.1.0 bound it, until the VM starts again with a new proxy. A secret of yours saved with the path &lt;code&gt;/&lt;/code&gt; has none, as &lt;code&gt;/&lt;/code&gt; is every path. A binding with methods or another path makes it &lt;code&gt;&amp;quot;version&amp;quot;: 2&lt;/code&gt;, which such a proxy refuses, so it puts no value in rather than put one in for every method, and devvm warns about each VM whose proxy is from another devvm binary when it writes one (&lt;code&gt;secrets_other_binary&lt;/code&gt;). A binding holds the secret&amp;rsquo;s name, its kind, its hosts, header and placeholder, sometimes a path and methods, and never its value. The kind is &lt;code&gt;secret&lt;/code&gt; for one that devvm keeps and &lt;code&gt;login&lt;/code&gt; for one of an agent&amp;rsquo;s logins, with the agent whose login file holds it, so where a value comes from never depends on its name. The proxy reads the file only when it&amp;rsquo;s a regular file, not a symbolic link, that only you can read or write, and a file it can&amp;rsquo;t read that way has no bindings until devvm writes it again. For a bound host, the proxy intercepts &lt;code&gt;:443&lt;/code&gt; tunnels instead of passing them through. It terminates TLS with a certificate from &lt;a href="#the-vms-ca"&gt;the VM&amp;rsquo;s own CA&lt;/a&gt;. Each certificate it makes for a host lasts a day, but never past the CA&amp;rsquo;s own end or before its start, because a client checks the whole chain. The proxy keeps the certificates of the 1024 hosts it used most recently and makes a new one for any other, so a binding with a wildcard host such as &lt;code&gt;*.example.com&lt;/code&gt;, which needs a certificate for each name the VM asks for, can&amp;rsquo;t grow the proxy&amp;rsquo;s memory without end. It then puts the real value in the binding&amp;rsquo;s header and forwards the request over a new TLS connection. Absolute-form &lt;code&gt;https://&lt;/code&gt; requests get the same.&lt;/p&gt;
&lt;p&gt;How the proxy puts the value in depends on the binding&amp;rsquo;s kind. A &lt;code&gt;secret&lt;/code&gt; binding&amp;rsquo;s placeholder is replaced only when exactly one value of its header holds it, as it is or inside &lt;code&gt;Basic&lt;/code&gt; credentials, and that value has one of four shapes. It&amp;rsquo;s the placeholder alone, or for &lt;code&gt;Authorization&lt;/code&gt;, &lt;code&gt;Bearer&lt;/code&gt;, &lt;code&gt;Token&lt;/code&gt; or the binding&amp;rsquo;s own &lt;code&gt;scheme&lt;/code&gt; in any case, one space and the placeholder, because &lt;code&gt;gh&lt;/code&gt; sends the GitHub token after &lt;code&gt;token&lt;/code&gt;. It&amp;rsquo;s also &lt;code&gt;Basic&lt;/code&gt; credentials, canonical base64 after one space, whose password is the placeholder, after a username of printable ASCII without a colon and at most 64 characters, because git sends the GitHub token as &lt;code&gt;x-access-token:&amp;lt;token&amp;gt;&lt;/code&gt; that way. With the binding&amp;rsquo;s &lt;code&gt;basic_user&lt;/code&gt;, it may be the username instead, before a password of printable ASCII of at most 64 characters, as Stripe takes its key. The proxy then puts the value where the placeholder was and nowhere else. A username, framed bytes, a doubled placeholder and a &lt;code&gt;Digest&lt;/code&gt; field are all places that a server can echo when it refuses a request, as Elasticsearch names the user it couldn&amp;rsquo;t authenticate, so those keep the placeholder. A &lt;code&gt;login&lt;/code&gt; binding&amp;rsquo;s placeholder is replaced only when the header has one value and that value is the placeholder alone, or, for &lt;code&gt;Authorization&lt;/code&gt;, &lt;code&gt;Bearer&lt;/code&gt; in any case, one space and the placeholder. Every agent sends its logins that way: an API key alone in &lt;code&gt;x-api-key&lt;/code&gt; or &lt;code&gt;x-goog-api-key&lt;/code&gt;, every other key and every OAuth login&amp;rsquo;s access token after &lt;code&gt;Bearer&lt;/code&gt;, and an MCP server&amp;rsquo;s header as the whole value that the VM&amp;rsquo;s copy replaced. Any other value keeps the placeholder, and so does a header that&amp;rsquo;s sent twice, which a server may join into one value. So code in the VM can&amp;rsquo;t put text of its own before or after a real API key, and a provider that quotes part of a key it refuses, as xAI&amp;rsquo;s, OpenAI&amp;rsquo;s and DeepSeek&amp;rsquo;s errors do, quotes only the placeholder. The proxy&amp;rsquo;s own log names the binding and its header when it leaves a placeholder for that reason, without a value.&lt;/p&gt;
&lt;p&gt;A binding can also have a path, a pattern as a rule&amp;rsquo;s is, and methods, and then the proxy puts its value in only for a request that they match as a rule&amp;rsquo;s allow does, with the one matcher of &lt;a href="#requests-by-method-and-path"&gt;requests by method and path&lt;/a&gt;, so a request with another method, or with a method-override header that names another, keeps the placeholder. Only a secret of yours has methods, from devvm secret set&amp;rsquo;s &lt;code&gt;--method&lt;/code&gt;, and a binding without them goes in for every method. A path that ends with &lt;code&gt;/&lt;/code&gt; matches everything below it. OpenRouter&amp;rsquo;s API keys are bound below &lt;code&gt;/api/&lt;/code&gt;, because opencode and pi send them only to &lt;code&gt;openrouter.ai/api/v1/&lt;/code&gt;, so the rest of the site gets the placeholder. They&amp;rsquo;re bound in two headers, each a binding of its own with the same name and placeholder. pi sends the key in &lt;code&gt;x-api-key&lt;/code&gt; to &lt;code&gt;/api/v1/messages&lt;/code&gt; for OpenRouter&amp;rsquo;s &lt;code&gt;anthropic/*&lt;/code&gt; models, which it calls with Anthropic&amp;rsquo;s API, and in &lt;code&gt;Authorization&lt;/code&gt; after &lt;code&gt;Bearer&lt;/code&gt; for every other model. opencode sends it in &lt;code&gt;Authorization&lt;/code&gt; today, and in &lt;code&gt;x-api-key&lt;/code&gt; for a model whose first API in the models.dev catalog is Anthropic&amp;rsquo;s Messages API, because it uses a model&amp;rsquo;s first API. The proxy compares the path as it forwards it, after a token endpoint&amp;rsquo;s capture has set it, and it takes the path only in a form that every server reads alike: clean already, without a &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;..&lt;/code&gt; segment or a doubled slash, with nothing percent-encoded, so no encoded slash or dot can move the request elsewhere after the check, and without a backslash or a &lt;code&gt;;&lt;/code&gt;, which some servers read as a separator or drop with what follows. A request for &lt;code&gt;/api/../settings&lt;/code&gt;, &lt;code&gt;/api%2F..%2Fsettings&lt;/code&gt; or &lt;code&gt;/%61pi/v1&lt;/code&gt; keeps the placeholder. A bindings file with a path that isn&amp;rsquo;t a pattern, or with methods that aren&amp;rsquo;t in their canonical form, has no bindings. Each request must name the bound host, and one that names another host gets &lt;code&gt;421&lt;/code&gt;. The proxy checks the bindings file for every request and reads it again when it has changed, so removing a binding applies to tunnels that are already open.&lt;/p&gt;
&lt;p&gt;The proxy&amp;rsquo;s broker is devvm itself, so it looks a value up in its own process, from the Keychain, devvm&amp;rsquo;s secrets folder or the agent&amp;rsquo;s login file, by the binding&amp;rsquo;s kind, when the child asks for it. The child names the binding by its kind, agent and name alone, and the broker finds that binding in its own read of the VM&amp;rsquo;s bindings file and looks the value up with its own copy of it, so a child can ask for no value that isn&amp;rsquo;t bound to its VM. It runs no other devvm for it, no devvm command prints a secret, and no value is in any process&amp;rsquo;s arguments. On macOS it asks the Keychain through &lt;code&gt;security find-generic-password&lt;/code&gt;, whose output is the value. A lookup takes at most 20 seconds, and the broker makes one at a time, so two requests never refresh a login at once. The broker keeps values for 5 minutes, or 30 seconds for agents&amp;rsquo; logins, and a failed lookup for 5 seconds, so a child can&amp;rsquo;t make it run &lt;code&gt;security&lt;/code&gt; or try a refresh back to back, and it drops them all when the bindings file changes, so a secret set right after a failure goes in at the next request. The child keeps a value only until the broker&amp;rsquo;s lookup is that old, and neither logs one. Each keeps a value by its binding&amp;rsquo;s kind, agent and name together, so a binding never gets the value of another one with the same name. A lookup that fails puts nothing in, and the proxy&amp;rsquo;s own log says why, without the value, such as &lt;code&gt;agent_refresh_failed&lt;/code&gt; when refreshing a Codex login failed. It refuses with &lt;code&gt;403&lt;/code&gt; the GitHub API calls that would make a credential of their own with the GitHub token, which are adding an account or deploy key, registering a runner and adding a webhook, whether the repo or organization is named or given by its ID. Every HTTPS request it forwards is checked, inside an intercepted tunnel and in absolute form alike, before it goes anywhere.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tests:&lt;/strong&gt; the unit tests check what a secret of yours may be and what devvm secret set&amp;rsquo;s flags change, that every variable the VM&amp;rsquo;s scripts export, and the proxy&amp;rsquo;s, is one it can&amp;rsquo;t take, each shape its value goes in and each that keeps the placeholder, and that a binding&amp;rsquo;s path and methods let it in only for the requests they match, each request of a kept-alive or HTTP/2 connection on its own. They check that a binding that isn&amp;rsquo;t the secret&amp;rsquo;s as it&amp;rsquo;s saved gets nothing, that a value too long for the Keychain&amp;rsquo;s line is refused before anything runs, and that every secret&amp;rsquo;s placeholder has one shape, the VM&amp;rsquo;s own, and is never taken as a value. They check the list, its mode and its checks on reading, that no value is in it or in a VM&amp;rsquo;s bindings, and that only a VM that uses the secret gets its binding and hosts, that two bindings of one name are cached apart, and use, a new value and the question that names the VMs before a delete. The CLI tests check every refusal before anything runs, the value on stdin and at a prompt and never in a command&amp;rsquo;s arguments, the list, &lt;code&gt;--json&lt;/code&gt;, the binding and the variable a VM gets and the other VM doesn&amp;rsquo;t, and the delete (&lt;a href="https://next.devvm.dev/docs/contributing/tests/#the-tests-behind-how-it-works"&gt;the tests behind it&lt;/a&gt;). &lt;strong&gt;End-to-end checks&lt;/strong&gt; (&lt;code&gt;network&lt;/code&gt;): a secret of yours bound to a host that the run&amp;rsquo;s company proxy fakes; the VM&amp;rsquo;s variable is its placeholder, the host gets the real value in the secret&amp;rsquo;s header, another host gets only the placeholder, and no log holds the value. Once the section has saved, bound and captured its secrets, and again at its end, no VM&amp;rsquo;s proxy password and none of the tokens, keys and logins the section used are in devvm&amp;rsquo;s run logs, its other logs or any VM&amp;rsquo;s proxy logs, as they are or in Basic credentials, and no VM&amp;rsquo;s proxy password is in Lima&amp;rsquo;s logs, &lt;code&gt;ha.stderr.log&lt;/code&gt; and the serial logs.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-vms-ca"&gt;The VM&amp;rsquo;s CA&lt;span class="hx:absolute hx:-mt-20" id="the-vms-ca"&gt;&lt;/span&gt;
&lt;a href="#the-vms-ca" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Each VM has a CA of its own, whatever its tier, which only its proxy signs with and only that VM trusts, so a copy of one VM&amp;rsquo;s key can impersonate sites to that VM alone, and no VM&amp;rsquo;s proxy can make a certificate that another VM accepts. A CA is ECDSA P-256, valid for 30 days from an hour before it&amp;rsquo;s made, and it names no host. Its common name holds its serial number, so no two CAs share a name. devvm keeps the VM&amp;rsquo;s CAs in the VM&amp;rsquo;s run folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/ca/&lt;/code&gt;: the current CA as &lt;code&gt;ca.pem&lt;/code&gt; and its key &lt;code&gt;ca.key&lt;/code&gt;, and the next CA as &lt;code&gt;next.pem&lt;/code&gt; and its key &lt;code&gt;next.key&lt;/code&gt;. The folder and both keys are yours alone (modes 700 and 600), devvm writes each file whole, a key before its certificate, and on macOS it keeps the folder out of Time Machine. The keys never leave this machine: the VM gets the two certificates and nothing else. The proxy reads each certificate and key only when it&amp;rsquo;s a regular file, not a symbolic link, and refuses a key that anybody but you may read or write.&lt;/p&gt;
&lt;p&gt;At each launch, devvm readies both CAs before the proxy starts, holding the folder&amp;rsquo;s lock, &lt;code&gt;lock&lt;/code&gt;, so two launches of one VM at once take turns. The current CA stays while it has over a week left. When it has less, or there&amp;rsquo;s none, the next CA takes its place if it has started and has over a week left, and otherwise devvm makes a new current CA. The next CA starts a week and an hour before the current one ends, and lasts 30 days too. When it doesn&amp;rsquo;t follow the current one that way, by ending after it and starting by the time it&amp;rsquo;s replaced, devvm makes it again. A key without its certificate, or a CA that lasts longer than 30 days, is made again too. Each launch&amp;rsquo;s setup installs both certificates in the VM, so the VM trusts the next CA weeks before the proxy uses it.&lt;/p&gt;
&lt;p&gt;The proxy holds both CAs, and it signs with the next one from an hour after that CA&amp;rsquo;s start, which is a week before the current one ends and the moment from which the next launch would make it the current one. The hour lets a VM whose clock is behind see that the CA has started. The switch needs no launch and no new proxy, because the VM already trusts the next CA, so a VM that you don&amp;rsquo;t open again keeps verifying the proxy&amp;rsquo;s certificates until the next CA ends, which is at least 30 days less an hour after its last launch. A proxy keeps the CAs it started with, because the VM trusts no others, and a launch that replaced either one starts the proxy again with the new ones, as &lt;a href="#how-long-a-proxy-runs"&gt;how long a proxy runs&lt;/a&gt; describes. &lt;code&gt;/ca.pem&lt;/code&gt; at &lt;code&gt;devvm.proxy&lt;/code&gt; serves both certificates.&lt;/p&gt;
&lt;p&gt;A VM that runs past its next CA&amp;rsquo;s end without a launch can&amp;rsquo;t verify the proxy&amp;rsquo;s certificates any more. From then on, its proxy answers each &lt;code&gt;CONNECT&lt;/code&gt; to a bound host&amp;rsquo;s &lt;code&gt;:443&lt;/code&gt; with &lt;code&gt;403&lt;/code&gt; before any tunnel opens, and it logs a refused block with the reason &lt;code&gt;devvm's CA has ended: open the VM again (devvm in its folder) for a new one&lt;/code&gt;, so neither the VM&amp;rsquo;s prompt nor &lt;code&gt;devvm network log&lt;/code&gt; suggests an allow rule. Absolute-form &lt;code&gt;https://&lt;/code&gt; requests involve no certificate for the VM, so they go on getting their secrets. The VM&amp;rsquo;s other connections work until you open it again. Running &lt;code&gt;devvm&lt;/code&gt; in the VM&amp;rsquo;s folder then makes a new CA and a next one and starts the proxy again with them, which ends the connections open through the old one, and the launch&amp;rsquo;s setup installs both in the VM.&lt;/p&gt;
&lt;p&gt;The CAs live as long as the VM&amp;rsquo;s folder. A remake keeps the folder, so the VM keeps its CAs, and so does a change of tier. &lt;code&gt;devvm rm&lt;/code&gt;, &lt;code&gt;devvm gc --orphans&lt;/code&gt;, and devvm deleting a VM whose creation it interrupted or whose folder an earlier VM of the project left, delete the folder, and the CAs and their keys with it.&lt;/p&gt;
&lt;p&gt;In a user&amp;rsquo;s terms: to put a secret in, the proxy shows the VM a certificate from the VM&amp;rsquo;s own CA, which every VM has, an open one&amp;rsquo;s included, and which no other VM trusts, so one VM&amp;rsquo;s proxy can&amp;rsquo;t make certificates that another VM accepts. Each CA lasts 30 days, and its key stays on this machine. Each launch installs the VM&amp;rsquo;s current CA and the next one, which starts a week before the current one ends, and the proxy switches to the next CA then on its own, without a launch. So a VM that you don&amp;rsquo;t open again keeps working for at least 30 days after its last launch with &lt;code&gt;devvm&lt;/code&gt; in its folder. Connecting with &lt;code&gt;ssh&lt;/code&gt; alone isn&amp;rsquo;t a launch. When a VM runs past its next CA&amp;rsquo;s end without a launch, its proxy refuses its HTTPS connections to secrets&amp;rsquo; hosts, and &lt;code&gt;devvm network log --blocked&lt;/code&gt; gives the reason &lt;code&gt;devvm's CA has ended&lt;/code&gt;. The VM&amp;rsquo;s other requests keep working. Running &lt;code&gt;devvm&lt;/code&gt; in the VM&amp;rsquo;s folder installs new CAs, which also starts the VM&amp;rsquo;s proxy again and ends the connections open through it (&lt;a href="https://next.devvm.dev/docs/safety/network/#saving-and-binding-secrets"&gt;saving and binding secrets&lt;/a&gt;). &lt;code&gt;devvm rm&lt;/code&gt; deletes a VM&amp;rsquo;s CAs with the VM, and a VM keeps them when its tier changes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tests:&lt;/strong&gt; the unit tests check the dates, the modes, the switch and each CA that&amp;rsquo;s made again, that launches at once take turns on the lock, that an open VM&amp;rsquo;s proxy has the VM&amp;rsquo;s CAs, salt and secrets file and that a VM keeps its CAs as its tier changes, that a client trusting both CAs verifies the proxy&amp;rsquo;s certificates before the switch and after it, with the same proxy, that the proxy refuses a key others may read and a symbolic link, and that two proxies&amp;rsquo; certificates come from their own CAs. The CLI tests check each VM&amp;rsquo;s CA files and modes, that two VMs&amp;rsquo; CAs differ, that the setup sends both certificates and no key, an open VM&amp;rsquo;s too, and that a VM turned off and on again keeps its CAs (&lt;a href="https://next.devvm.dev/docs/contributing/tests/#the-tests-behind-how-it-works"&gt;the tests behind it&lt;/a&gt;). &lt;strong&gt;End-to-end checks&lt;/strong&gt; (&lt;code&gt;network&lt;/code&gt;): a second confined VM, whose CAs differ from the first&amp;rsquo;s; each VM trusts its own two and none of the other&amp;rsquo;s; no key is anywhere in the VM; each proxy serves its own CAs at &lt;code&gt;/ca.pem&lt;/code&gt;, and its certificates verify with its own VM&amp;rsquo;s CAs and not with the other&amp;rsquo;s; &lt;code&gt;devvm rm&lt;/code&gt; deletes a VM&amp;rsquo;s CA with its folder.&lt;/p&gt;
&lt;h2 data-hextra-search-id="agents-logins-and-settings"&gt;Agents&amp;rsquo; logins and settings&lt;span class="hx:absolute hx:-mt-20" id="agents-logins-and-settings"&gt;&lt;/span&gt;
&lt;a href="#agents-logins-and-settings" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Agents&amp;rsquo; login files also stay on the host, in devvm&amp;rsquo;s agent store, which &lt;code&gt;devvm agent import&lt;/code&gt; fills, and so do &lt;a href="#logins-made-in-a-vm"&gt;logins made in a VM&lt;/a&gt; (&lt;a href="https://next.devvm.dev/docs/using/coding-agents/#devvms-agent-store"&gt;devvm&amp;rsquo;s agent store&lt;/a&gt;). devvm never reads an agent&amp;rsquo;s own login file in the home folder for a VM. When a VM&amp;rsquo;s image has the agent and the store has a login file for it, the login&amp;rsquo;s bindings join the VM&amp;rsquo;s, and their hosts join its allowlist on port 443.&lt;/p&gt;
&lt;p&gt;Codex&amp;rsquo;s login is &lt;code&gt;~/.local/share/devvm/logins/codex/.codex/auth.json&lt;/code&gt;, opencode&amp;rsquo;s is &lt;code&gt;~/.local/share/devvm/logins/opencode/.local/share/opencode/auth.json&lt;/code&gt; and pi&amp;rsquo;s is &lt;code&gt;~/.local/share/devvm/logins/pi/.pi/agent/auth.json&lt;/code&gt;, the store&amp;rsquo;s copies of &lt;code&gt;~/.codex/auth.json&lt;/code&gt;, &lt;code&gt;~/.local/share/opencode/auth.json&lt;/code&gt; and &lt;code&gt;~/.pi/agent/auth.json&lt;/code&gt;. The VM&amp;rsquo;s copy holds placeholders, shaped like a JWT where the tools read claims, and the bindings put the store&amp;rsquo;s API key or access token into requests for the provider&amp;rsquo;s hosts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For Codex, those are OpenAI&amp;rsquo;s hosts, &lt;code&gt;api.openai.com&lt;/code&gt;, and &lt;code&gt;chatgpt.com&lt;/code&gt; for a ChatGPT login.&lt;/li&gt;
&lt;li&gt;For opencode, they&amp;rsquo;re the hosts of the API keys of the providers in &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#api-keys-the-proxy-puts-in"&gt;API keys the proxy puts in&lt;/a&gt;, each in the headers that its row names, and of OpenAI and GitHub Copilot logins, but not Copilot Enterprise. opencode keeps one entry per provider, &lt;code&gt;{&amp;quot;type&amp;quot;:&amp;quot;api&amp;quot;,&amp;quot;key&amp;quot;,&amp;quot;metadata&amp;quot;}&lt;/code&gt;, &lt;code&gt;{&amp;quot;type&amp;quot;:&amp;quot;oauth&amp;quot;,&amp;quot;refresh&amp;quot;,&amp;quot;access&amp;quot;,&amp;quot;expires&amp;quot;,&amp;quot;accountId&amp;quot;,&amp;quot;enterpriseUrl&amp;quot;}&lt;/code&gt; or &lt;code&gt;{&amp;quot;type&amp;quot;:&amp;quot;wellknown&amp;quot;,&amp;quot;key&amp;quot;,&amp;quot;token&amp;quot;}&lt;/code&gt;. A bound key&amp;rsquo;s entry reaches the VM as &lt;code&gt;{&amp;quot;type&amp;quot;,&amp;quot;key&amp;quot;}&lt;/code&gt; alone, its key the placeholder, so its &lt;code&gt;metadata&lt;/code&gt; stays on this machine, and a bound OAuth login&amp;rsquo;s keeps only the fields that name its account beside the placeholders (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;For pi, they&amp;rsquo;re the hosts of the same providers&amp;rsquo; API keys, each in the same headers. Both agents name each of these providers by the same ID, and neither puts a key in a URL, such as Gemini&amp;rsquo;s &lt;code&gt;?key=&lt;/code&gt;, which the proxy couldn&amp;rsquo;t fill in, because it swaps the placeholder in a header alone. pi keeps one entry per provider, &lt;code&gt;{&amp;quot;type&amp;quot;:&amp;quot;api_key&amp;quot;,&amp;quot;key&amp;quot;,&amp;quot;env&amp;quot;}&lt;/code&gt; or &lt;code&gt;{&amp;quot;type&amp;quot;:&amp;quot;oauth&amp;quot;,&amp;quot;access&amp;quot;,&amp;quot;refresh&amp;quot;,&amp;quot;expires&amp;quot;}&lt;/code&gt;, and devvm binds only the first kind, with a key that&amp;rsquo;s a value rather than a &lt;code&gt;!command&lt;/code&gt; or a &lt;code&gt;$NAME&lt;/code&gt; or &lt;code&gt;${NAME}&lt;/code&gt; template, which pi fills in from the entry&amp;rsquo;s &lt;code&gt;env&lt;/code&gt; or the environment (&lt;code&gt;$$&lt;/code&gt; is a literal &lt;code&gt;$&lt;/code&gt;). A bound entry reaches the VM as &lt;code&gt;{&amp;quot;type&amp;quot;,&amp;quot;key&amp;quot;}&lt;/code&gt; alone, its key the placeholder, so nothing else of it, its &lt;code&gt;env&lt;/code&gt; included, leaves this machine.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The store keeps opencode&amp;rsquo;s login in the &lt;code&gt;auth.json&lt;/code&gt; format of opencode 1: one entry per provider, &lt;code&gt;{&amp;quot;type&amp;quot;:&amp;quot;api&amp;quot;,&amp;quot;key&amp;quot;}&lt;/code&gt; or &lt;code&gt;{&amp;quot;type&amp;quot;:&amp;quot;oauth&amp;quot;,&amp;quot;access&amp;quot;,&amp;quot;refresh&amp;quot;,&amp;quot;expires&amp;quot;}&lt;/code&gt; with its expiry in milliseconds. opencode 2 keeps its logins in the &lt;code&gt;credential&lt;/code&gt; table of its SQLite database, &lt;code&gt;~/.local/share/opencode/opencode.db&lt;/code&gt;, and imports &lt;code&gt;auth.json&lt;/code&gt; into it once, in the migration that makes the table, so a VM&amp;rsquo;s opencode gets the VM&amp;rsquo;s copy when it first runs there. A VM&amp;rsquo;s placeholders don&amp;rsquo;t change when the host refreshes a login, so the database&amp;rsquo;s copies keep working. After that, the store&amp;rsquo;s opencode logins reach the database through &lt;code&gt;opencode auth import&lt;/code&gt;, as &lt;code&gt;auth export&lt;/code&gt; entries with the IDs &lt;code&gt;cred_devvm_&amp;lt;provider&amp;gt;&lt;/code&gt;: the placeholder of each API key that the proxy puts in, each key that &lt;code&gt;[pass-keys]&lt;/code&gt; passes, with its &lt;code&gt;metadata&lt;/code&gt;, and the OpenAI login&amp;rsquo;s placeholders from one of opencode&amp;rsquo;s Codex logins. The VM&amp;rsquo;s setup sends these entries on every launch, and &lt;code&gt;devvm agent login opencode --api-key --provider PROVIDER&lt;/code&gt; sends them at once, both on the input of devvm&amp;rsquo;s guest script &lt;code&gt;opencode.sh&lt;/code&gt;, never in a command&amp;rsquo;s arguments. The script keeps the last entries it got in &lt;code&gt;~/.local/state/devvm/opencode-import.json&lt;/code&gt; in the VM. When opencode has made its database and the new entries differ from the record, or the database no longer holds one of their IDs because it was made again, such as after you delete it or a history import replaces it, it logs out of devvm&amp;rsquo;s entries from the last ones with &lt;code&gt;opencode auth logout&lt;/code&gt;, because &lt;code&gt;opencode auth import&lt;/code&gt; skips an ID it already has, and then imports the new ones and makes each of them its provider&amp;rsquo;s active credential with &lt;code&gt;opencode auth switch&lt;/code&gt;, so a ChatGPT login for another account or a key saved from another VM reaches every VM at its next launch. Credentials that you added in the VM yourself have other IDs, so they stay in the database, and &lt;code&gt;opencode auth switch&lt;/code&gt; makes one of them active again. Before opencode has made its database, the script does nothing and records nothing, because opencode 2.2.5 doesn&amp;rsquo;t always import &lt;code&gt;auth.json&lt;/code&gt; as it makes the database, so the first launch after opencode has run imports every entry. The script imports each entry on its own, so an entry that opencode refuses doesn&amp;rsquo;t keep the others out, and &lt;code&gt;devvm agent login&lt;/code&gt; names the providers that opencode refused. A failed import leaves the record as it was, so the next launch tries again. The script and its record live in the VM rather than in the VM&amp;rsquo;s state on the host, because only the VM knows whether its database exists and what it last imported, and a VM that is set up again or has its home copied keeps both together.&lt;/p&gt;
&lt;p&gt;Each VM&amp;rsquo;s placeholders end in its own random value, so no other VM&amp;rsquo;s placeholder gets its secrets. devvm reads a login file only when it&amp;rsquo;s a regular file, so a FIFO or a device in its place can&amp;rsquo;t hold devvm. devvm refreshes OAuth logins on the host, one lookup at a time, and writes them back to the store&amp;rsquo;s file, so a VM never holds the refresh token of a login devvm keeps. Claude Code&amp;rsquo;s logins to MCP servers that you make in a VM are that VM&amp;rsquo;s own (&lt;a href="https://next.devvm.dev/docs/internals/agents/#claude-codes-login"&gt;Claude Code&amp;rsquo;s login&lt;/a&gt;). A refresh that has started finishes and is written back even when the request that needed it ends, because OpenAI may already have replaced the refresh token. When a refresh fails, or the store&amp;rsquo;s login no longer has what a binding names, the proxy puts nothing in, and its own log says to log in again with the agent and import the login again (&lt;code&gt;agent_refresh_failed&lt;/code&gt;, &lt;code&gt;agent_provider_refresh_failed&lt;/code&gt; for one of opencode&amp;rsquo;s providers, &lt;code&gt;codex_no_key&lt;/code&gt;, &lt;code&gt;codex_no_chatgpt&lt;/code&gt;), or names the login file it couldn&amp;rsquo;t read (&lt;code&gt;login_read_failed&lt;/code&gt;). The VM&amp;rsquo;s copy of Codex&amp;rsquo;s &lt;code&gt;auth.json&lt;/code&gt; holds only the fields that devvm knows, as Codex 0.166.0&amp;rsquo;s login code reads them. Its API key and its tokens are placeholders, and the copy keeps &lt;code&gt;auth_mode&lt;/code&gt; and &lt;code&gt;last_refresh&lt;/code&gt;, and in &lt;code&gt;tokens&lt;/code&gt;, &lt;code&gt;account_id&lt;/code&gt;, &lt;code&gt;login_owner_id&lt;/code&gt; and the refresh token&amp;rsquo;s &lt;code&gt;oauth_provenance&lt;/code&gt;, its &lt;code&gt;issuer&lt;/code&gt; and &lt;code&gt;client_id&lt;/code&gt;, each a plain value. devvm leaves every other field out, at the top of the file or in &lt;code&gt;tokens&lt;/code&gt;, Codex&amp;rsquo;s other logins included (&lt;code&gt;agent_identity&lt;/code&gt;, &lt;code&gt;personal_access_token&lt;/code&gt;, &lt;code&gt;bedrock_api_key&lt;/code&gt; and &lt;code&gt;bedrock_access_keys&lt;/code&gt;), because the proxy has no binding for them, and warns you, naming a field in &lt;code&gt;tokens&lt;/code&gt; by its path, such as &lt;code&gt;tokens.zz&lt;/code&gt; (&lt;code&gt;login_fields_withheld&lt;/code&gt;). A unit test plants a field that no format knows in every object of each kind&amp;rsquo;s login file, as a string, an object and a list, and checks that no VM&amp;rsquo;s copy holds it (&lt;a href="https://next.devvm.dev/docs/contributing/tests/#the-tests-behind-how-it-works"&gt;the tests behind it&lt;/a&gt;). opencode&amp;rsquo;s and pi&amp;rsquo;s logins are withheld by default, by the same rule, which each agent&amp;rsquo;s entry in devvm&amp;rsquo;s registry of the agents sets. Every entry that devvm doesn&amp;rsquo;t bind, an API key, an OAuth login or opencode&amp;rsquo;s well-known login, reaches the VM with only the fields that name its account or how it logs in, &lt;code&gt;type&lt;/code&gt;, &lt;code&gt;expires&lt;/code&gt;, &lt;code&gt;accountId&lt;/code&gt;, &lt;code&gt;enterpriseUrl&lt;/code&gt;, &lt;code&gt;projectId&lt;/code&gt;, &lt;code&gt;email&lt;/code&gt;, &lt;code&gt;scope&lt;/code&gt;, &lt;code&gt;scopes&lt;/code&gt; and &lt;code&gt;clientId&lt;/code&gt;, each a plain value or a list of strings, and devvm warns you (&lt;code&gt;login_withheld&lt;/code&gt;). opencode skips an entry that lacks its key or its tokens as it reads &lt;code&gt;auth.json&lt;/code&gt;, so it doesn&amp;rsquo;t use that provider in the VM. The exception is an API-key entry of a provider that &lt;code&gt;config.toml&lt;/code&gt;&amp;rsquo;s &lt;code&gt;[pass-keys]&lt;/code&gt; lists under the agent&amp;rsquo;s name, which goes as it is, and devvm notes it (&lt;code&gt;login_passed&lt;/code&gt;). It&amp;rsquo;s never an OAuth login, whose tokens a VM never gets, and never a provider that devvm binds, whose key is always its placeholder, so binding wins over the table, and devvm notes each bound provider that the table lists (&lt;code&gt;login_pass_bound&lt;/code&gt;). The table has one key per agent, so each agent&amp;rsquo;s withheld keys are passed on their own. If devvm can&amp;rsquo;t make the VM&amp;rsquo;s copy of a login, it stops the VM&amp;rsquo;s setup (&lt;code&gt;login_copy_failed&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;&lt;a href="https://next.devvm.dev/docs/using/coding-agents/"&gt;Coding agents&lt;/a&gt; lists which files each agent shares.&lt;/p&gt;
&lt;h3 data-hextra-search-id="logins-made-in-a-vm"&gt;Logins made in a VM&lt;span class="hx:absolute hx:-mt-20" id="logins-made-in-a-vm"&gt;&lt;/span&gt;
&lt;a href="#logins-made-in-a-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A login that an agent makes inside a VM goes to devvm&amp;rsquo;s store too, and the VM gets only placeholders for it. The VM&amp;rsquo;s proxy does this at the agent&amp;rsquo;s OAuth token endpoint, the one request of a login whose reply holds its tokens. Codex and opencode both log in to OpenAI at &lt;code&gt;auth.openai.com/oauth/token&lt;/code&gt;, whether the code comes from a browser&amp;rsquo;s redirect or from a device code typed into a browser elsewhere. For opencode 2, those are its Codex logins, the methods &lt;code&gt;chatgpt-browser&lt;/code&gt; and &lt;code&gt;chatgpt-headless&lt;/code&gt;. Its Sign in with ChatGPT, &lt;code&gt;chatgpt-token-sharing&lt;/code&gt;, registers a client of its own and gets its tokens from &lt;code&gt;auth.openai.com/api/accounts/oauth/token&lt;/code&gt;, then checks the &lt;code&gt;id_token&lt;/code&gt;&amp;rsquo;s signature against OpenAI&amp;rsquo;s keys, which a placeholder can&amp;rsquo;t pass, so devvm doesn&amp;rsquo;t capture that endpoint, and its replies get &lt;code&gt;502&lt;/code&gt;, as the next paragraph says. Every VM&amp;rsquo;s proxy config lists that endpoint in &lt;code&gt;captures&lt;/code&gt;, for Codex and for opencode, whatever the VM&amp;rsquo;s image holds, because a program in the VM could install either agent itself, and the proxy refuses that agent&amp;rsquo;s login rather than let its tokens reach the VM. The endpoint&amp;rsquo;s host joins the VM&amp;rsquo;s &lt;code&gt;secrets.policy&lt;/code&gt; on port 443 only when its image has one of them, so that agent can log in on every tier. The proxy intercepts the host&amp;rsquo;s &lt;code&gt;:443&lt;/code&gt; tunnels as it does a bound host&amp;rsquo;s, with a certificate from &lt;a href="#the-vms-ca"&gt;the VM&amp;rsquo;s CA&lt;/a&gt;, and forwards every request to it. Only a request of the endpoint&amp;rsquo;s method to its path is captured, a &lt;code&gt;POST&lt;/code&gt; for every OAuth token endpoint, and the proxy compares the path once it&amp;rsquo;s cleaned, each segment without its path parameters, a backslash read as a slash, and in any case, as a host that normalizes paths reads it, so a request for &lt;code&gt;/oauth//token&lt;/code&gt;, &lt;code&gt;/OAuth/Token/&lt;/code&gt;, &lt;code&gt;/oauth/token;x&lt;/code&gt; or &lt;code&gt;/x;/../oauth/token&lt;/code&gt; is captured too. A captured request goes to the endpoint&amp;rsquo;s own path whatever the VM&amp;rsquo;s spelling of it, and a &lt;code&gt;POST&lt;/code&gt; goes without a query. An endpoint can be a &lt;code&gt;GET&lt;/code&gt; instead, for a login that the agent polls for, whose request is its query. The proxy then refuses a query that isn&amp;rsquo;t a form or that names a field twice, which devvm and the endpoint could read apart, and a &lt;code&gt;GET&lt;/code&gt; with a body, and the query goes on in a canonical form, its fields sorted, so the endpoint reads what devvm read. Any other successful reply from that host that names an &lt;code&gt;access_token&lt;/code&gt;, a &lt;code&gt;refresh_token&lt;/code&gt; or an &lt;code&gt;id_token&lt;/code&gt; anywhere gets &lt;code&gt;502&lt;/code&gt;, whatever its type, so no other path there, such as another token endpoint&amp;rsquo;s, hands the VM a login, and so does one that names a field that the endpoint&amp;rsquo;s agent keeps its tokens in, such as &lt;code&gt;accessToken&lt;/code&gt;. The proxy passes only a web page and its parts unread, which are HTML, CSS, JavaScript, images and fonts, and it refuses a reply it can&amp;rsquo;t read for that, one that&amp;rsquo;s encoded or longer than 1 MiB, and an upgrade (&lt;code&gt;101&lt;/code&gt;). No informational reply (&lt;code&gt;1xx&lt;/code&gt;) from the host reaches the VM, because its headers could hold a cookie. When the host serves an API of its own beside the endpoint, which these checks would break, with its streamed, encoded or long replies, the endpoint names a path prefix that the endpoint is below, its guard, and the proxy checks only the replies below it. It checks the reply to any path that isn&amp;rsquo;t already clean too, such as one with path parameters, encoded characters or &lt;code&gt;..&lt;/code&gt;, because the host could read it as below the guard where devvm doesn&amp;rsquo;t. The API&amp;rsquo;s replies elsewhere pass as they are, their informational replies, upgrades and encodings included. A path there that handed out tokens would hand them to the VM, and the VM&amp;rsquo;s requests to that API carry the agent&amp;rsquo;s real login, which the proxy puts in, so the agent&amp;rsquo;s section names the paths that could.&lt;/p&gt;
&lt;p&gt;The proxy&amp;rsquo;s child judges a captured request by the VM&amp;rsquo;s rules as any other, reads its body whole, up to 64 KiB, with at most 64 KiB of headers, and hands it to the broker, which does the rest itself, so a login&amp;rsquo;s real tokens, a new login&amp;rsquo;s refresh token among them, and the store&amp;rsquo;s &lt;code&gt;id_token&lt;/code&gt; never reach the child. The broker finds the endpoint in its own config by the request&amp;rsquo;s host, path and method, and refuses a request that matches none. It names the VM itself and sends the request to the endpoint&amp;rsquo;s host from its own config, on port 443, through the company proxy when there is one, trusting the system&amp;rsquo;s roots and your CAs, as a refresh does. It refuses one that names a field twice, or a JSON body with more after its object, which devvm and the endpoint could read apart. It drops the VM&amp;rsquo;s &lt;code&gt;Accept-Encoding&lt;/code&gt; header from every request to the host, so each reply comes as it is, or as gzip that Go&amp;rsquo;s transport undoes. The request goes on unchanged, with two exceptions. After a code&amp;rsquo;s login, Codex exchanges the login&amp;rsquo;s &lt;code&gt;id_token&lt;/code&gt; for an API key, with a token-exchange grant that asks for &lt;code&gt;openai-api-key&lt;/code&gt;. The VM&amp;rsquo;s request carries the VM&amp;rsquo;s placeholder of the &lt;code&gt;id_token&lt;/code&gt;, so the proxy puts the store&amp;rsquo;s &lt;code&gt;id_token&lt;/code&gt; in its place, and only when the placeholder is that VM&amp;rsquo;s for the store&amp;rsquo;s current login. An error reply to that request reaches the VM with its OAuth error code alone, such as &lt;code&gt;{&amp;quot;error&amp;quot;:&amp;quot;invalid_grant&amp;quot;}&lt;/code&gt;, in case the endpoint&amp;rsquo;s message quotes the &lt;code&gt;id_token&lt;/code&gt;. A refresh whose refresh token is the VM&amp;rsquo;s own, &lt;code&gt;devvm-proxy-managed&lt;/code&gt;, or for opencode its access token&amp;rsquo;s placeholder, goes nowhere, and the VM gets the store&amp;rsquo;s login as placeholders again, because the host refreshes the login itself. devvm refuses any other grant than a code&amp;rsquo;s, a refresh&amp;rsquo;s or Codex&amp;rsquo;s exchange before the request leaves the host, because it couldn&amp;rsquo;t read the reply. Any other error reply reaches the VM as it is, with the few headers below, up to 1 MiB, and one that&amp;rsquo;s longer gets &lt;code&gt;502&lt;/code&gt;. The child reads at most 8 requests and replies to and from the host whole at once, and the broker runs at most 8 exchanges at once.&lt;/p&gt;
&lt;p&gt;A successful reply never reaches the VM as it is. The broker reads it whole, up to 1 MiB, and saves its tokens in the store&amp;rsquo;s login file, in the agent&amp;rsquo;s own format, under the file&amp;rsquo;s lock, so a refresh on the host never runs at the same time. Codex&amp;rsquo;s goes in &lt;code&gt;tokens&lt;/code&gt; of its &lt;code&gt;auth.json&lt;/code&gt;, with the account from the &lt;code&gt;id_token&lt;/code&gt;, and the exchange&amp;rsquo;s API key in &lt;code&gt;OPENAI_API_KEY&lt;/code&gt;. opencode&amp;rsquo;s goes in the &lt;code&gt;openai&lt;/code&gt; entry of its &lt;code&gt;auth.json&lt;/code&gt;, as an OAuth login with its expiry in milliseconds and its account. A code&amp;rsquo;s reply replaces the login, and for Codex it also replaces the API key of the login before it. A refresh&amp;rsquo;s reply adds to the login, so the store keeps only the newest refresh token. Then devvm writes the VM&amp;rsquo;s bindings again, so its proxy puts the new login into requests at once. When that write fails, the login is still saved, the VM gets its reply, its proxy&amp;rsquo;s own log says why, and the VM&amp;rsquo;s next launch writes its bindings.&lt;/p&gt;
&lt;p&gt;The VM gets a reply with placeholders in place of the tokens. Its access token&amp;rsquo;s placeholder is the one the store&amp;rsquo;s login binds, a JWT with the login&amp;rsquo;s account claims, its API key&amp;rsquo;s is the one its binding names, and its refresh token is &lt;code&gt;devvm-proxy-managed&lt;/code&gt;, which is no token. The reply keeps only the token type and scope, says that the access token lasts until 2099, and holds nothing else of the endpoint&amp;rsquo;s reply, so the agent in the VM never refreshes the login itself. Its headers are only &lt;code&gt;Content-Type&lt;/code&gt;, &lt;code&gt;Cache-Control&lt;/code&gt;, &lt;code&gt;Pragma&lt;/code&gt; and &lt;code&gt;Date&lt;/code&gt;, so no cookie of the endpoint&amp;rsquo;s reaches the VM. A reply that&amp;rsquo;s too long, encoded in another way, or not a login devvm reads, such as one without an access token, gets &lt;code&gt;502&lt;/code&gt; instead, logged as a refused block, and devvm saves nothing of it. An error reply holds no tokens, so it reaches the VM as it is, with the same headers alone. The event log gets a &lt;code&gt;login&lt;/code&gt; event for each login saved, which names the agent, and the proxy&amp;rsquo;s own log says why a capture failed, without a value.&lt;/p&gt;
&lt;p&gt;A VM captures a login only for an agent that its image has, because a capture replaces the login that every VM with that agent uses. So a login at OpenAI&amp;rsquo;s endpoint is the agent&amp;rsquo;s that the VM&amp;rsquo;s image has, of Codex and opencode, and in a VM with both, the request&amp;rsquo;s &lt;code&gt;User-Agent&lt;/code&gt; says whose login it is. Each login format that captures logins names its endpoints and the starts of its agent&amp;rsquo;s &lt;code&gt;User-Agent&lt;/code&gt;, and devvm lists every format&amp;rsquo;s endpoints in the registry&amp;rsquo;s order. opencode runs on Bun, so a request whose &lt;code&gt;User-Agent&lt;/code&gt; starts with &lt;code&gt;Bun/&lt;/code&gt; or &lt;code&gt;opencode/&lt;/code&gt; is opencode&amp;rsquo;s, and any other is Codex&amp;rsquo;s, because Codex&amp;rsquo;s format names none. When the VM&amp;rsquo;s image has neither and its tier reaches the host, its request gets &lt;code&gt;502&lt;/code&gt; before it leaves this machine, devvm saves nothing, and the proxy&amp;rsquo;s own log says why (&lt;code&gt;login_capture_refused&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Claude Code logs in at &lt;code&gt;platform.claude.com/v1/oauth/token&lt;/code&gt;, and older releases at &lt;code&gt;console.anthropic.com/v1/oauth/token&lt;/code&gt;, so every VM&amp;rsquo;s proxy config lists both in &lt;code&gt;captures&lt;/code&gt; for Claude Code, and their hosts join the &lt;code&gt;secrets.policy&lt;/code&gt; of a VM whose image has it. Anthropic doesn&amp;rsquo;t document these requests: devvm reads them from Claude Code 2.1&amp;rsquo;s bundle, so a release that changes them can break the capture, and the &lt;code&gt;network&lt;/code&gt; end-to-end section drives the real Claude Code&amp;rsquo;s login against a fake endpoint to catch that. Claude Code sends JSON with its public client ID, &lt;code&gt;9d1c250a-e61b-44d9-88ed-5944d1962f5e&lt;/code&gt;, and PKCE, without a client secret. A code&amp;rsquo;s request holds &lt;code&gt;grant_type&lt;/code&gt;, &lt;code&gt;code&lt;/code&gt;, &lt;code&gt;redirect_uri&lt;/code&gt;, &lt;code&gt;client_id&lt;/code&gt;, &lt;code&gt;code_verifier&lt;/code&gt; and &lt;code&gt;state&lt;/code&gt;, and a refresh&amp;rsquo;s &lt;code&gt;grant_type&lt;/code&gt;, &lt;code&gt;refresh_token&lt;/code&gt;, &lt;code&gt;client_id&lt;/code&gt; and &lt;code&gt;scope&lt;/code&gt;. The reply holds &lt;code&gt;access_token&lt;/code&gt;, &lt;code&gt;refresh_token&lt;/code&gt;, &lt;code&gt;expires_in&lt;/code&gt; and &lt;code&gt;scope&lt;/code&gt;, with the account and the organization.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;claude setup-token&lt;/code&gt; also sends a code&amp;rsquo;s request, with &lt;code&gt;expires_in&lt;/code&gt; of a year added, and asks only for the &lt;code&gt;user:inference&lt;/code&gt; scope, so devvm tells it apart by that field. Its reply&amp;rsquo;s access token, which must start with &lt;code&gt;sk-ant-oat01-&lt;/code&gt;, is saved as the &lt;code&gt;claude&lt;/code&gt; secret, and the VM gets the secret&amp;rsquo;s placeholder in its place, which &lt;code&gt;claude setup-token&lt;/code&gt; then prints. Any other code&amp;rsquo;s login goes in the store&amp;rsquo;s &lt;code&gt;.claude/.credentials.json&lt;/code&gt;, as Claude Code keeps it on Linux: &lt;code&gt;claudeAiOauth&lt;/code&gt; with &lt;code&gt;accessToken&lt;/code&gt;, &lt;code&gt;refreshToken&lt;/code&gt;, &lt;code&gt;expiresAt&lt;/code&gt; in Unix milliseconds and &lt;code&gt;scopes&lt;/code&gt;. A new login whose scope lacks &lt;code&gt;user:inference&lt;/code&gt; gets &lt;code&gt;502&lt;/code&gt;, because it can&amp;rsquo;t use the model. Such a login is an Anthropic Console login, which Claude Code would use to make an API key at &lt;code&gt;api.anthropic.com/api/oauth/claude_cli/create_api_key&lt;/code&gt; with the access token the VM never gets. A login or a refresh whose scope has &lt;code&gt;org:create_api_key&lt;/code&gt; also gets &lt;code&gt;502&lt;/code&gt;, whatever else it has, because the proxy puts the login into every request to &lt;code&gt;api.anthropic.com&lt;/code&gt;, so a VM could make an API key with it and get the key itself. The access token must start with &lt;code&gt;sk-ant-oat01-&lt;/code&gt; and hold no space, quote, backslash or control character, in a capture&amp;rsquo;s reply and in the host&amp;rsquo;s refresh&amp;rsquo;s. Only a VM whose image has Claude Code captures a Claude Code login, because a capture replaces the login every VM with Claude Code uses, so another VM&amp;rsquo;s gets &lt;code&gt;502&lt;/code&gt; and devvm saves nothing. The VM&amp;rsquo;s reply holds &lt;code&gt;sk-ant-oat01-devvm-proxy-managed-oauth-&amp;lt;salt&amp;gt;&lt;/code&gt; as its access token and &lt;code&gt;devvm-proxy-managed&lt;/code&gt; as its refresh token, so the Claude login in the VM&amp;rsquo;s &lt;code&gt;~/.claude/.credentials.json&lt;/code&gt;, which Claude Code writes from it, holds no token. A refresh with &lt;code&gt;devvm-proxy-managed&lt;/code&gt; goes nowhere, and the VM gets the placeholders again.&lt;/p&gt;
&lt;p&gt;devvm keeps one Claude Code login. Saving the &lt;code&gt;claude&lt;/code&gt; secret, captured or with &lt;code&gt;devvm secret set claude&lt;/code&gt;, deletes the store&amp;rsquo;s &lt;code&gt;.credentials.json&lt;/code&gt;, and capturing an OAuth login deletes the saved &lt;code&gt;claude&lt;/code&gt; secret, so the newest login wins. Both happen under the lock of the store&amp;rsquo;s &lt;code&gt;logins/claude&lt;/code&gt; folder, so two at once never leave devvm with neither login, and a saved token that can&amp;rsquo;t be deleted is a warning in the proxy&amp;rsquo;s log, as the login is saved. A &lt;code&gt;CLAUDE_CODE_OAUTH_TOKEN&lt;/code&gt; in devvm&amp;rsquo;s environment wins over both, as it does in Claude Code. A launch gives the VM &lt;code&gt;CLAUDE_CODE_OAUTH_TOKEN&lt;/code&gt; with its placeholder when there&amp;rsquo;s a token, and otherwise the VM&amp;rsquo;s copy of &lt;code&gt;.credentials.json&lt;/code&gt;, with that placeholder, no refresh token and an expiry of 2099, never both. The copy&amp;rsquo;s &lt;code&gt;claudeAiOauth&lt;/code&gt; replaces the VM&amp;rsquo;s own in its &lt;code&gt;~/.claude/.credentials.json&lt;/code&gt;, and the rest of that file, such as Claude Code&amp;rsquo;s logins to MCP servers, stays in the VM (&lt;a href="https://next.devvm.dev/docs/internals/agents/#claude-codes-login"&gt;Claude Code&amp;rsquo;s login&lt;/a&gt;). The VM&amp;rsquo;s bindings hold both logins&amp;rsquo; placeholders, the &lt;code&gt;claude&lt;/code&gt; secret&amp;rsquo;s and &lt;code&gt;claude-oauth&lt;/code&gt;, whenever devvm keeps either login, and the store&amp;rsquo;s lookup gives each the login devvm keeps now. So a VM that started with the login that the newest replaced keeps working until its next launch gives it the new one. Both put their value into &lt;code&gt;Authorization&lt;/code&gt; for &lt;code&gt;api.anthropic.com&lt;/code&gt;. Claude Code lists the connectors of the claude.ai account at &lt;code&gt;api.anthropic.com/v1/mcp_servers&lt;/code&gt;, which needs the login&amp;rsquo;s &lt;code&gt;user:mcp_servers&lt;/code&gt; scope, and then reaches each connector at &lt;code&gt;mcp-proxy.anthropic.com/v1/mcp/&amp;lt;id&amp;gt;&lt;/code&gt;, with the login&amp;rsquo;s access token too. So the VM gets a third binding, &lt;code&gt;claude-connectors&lt;/code&gt;, with &lt;code&gt;claude-oauth&lt;/code&gt;&amp;rsquo;s placeholder, which puts the login into &lt;code&gt;Authorization&lt;/code&gt; for &lt;code&gt;mcp-proxy.anthropic.com&lt;/code&gt; below &lt;code&gt;/v1/mcp/&lt;/code&gt; alone. It&amp;rsquo;s a binding of its own because the proxy looks a value up by its binding&amp;rsquo;s name, and the store&amp;rsquo;s lookup gives &lt;code&gt;claude-connectors&lt;/code&gt; only the OAuth login, never a token. While devvm keeps a token, saved or in its environment, that binding&amp;rsquo;s lookup fails and puts nothing in. A token in devvm&amp;rsquo;s environment isn&amp;rsquo;t checked for its scope, so it could hold the connectors&amp;rsquo; scope, and that&amp;rsquo;s why a token goes to &lt;code&gt;api.anthropic.com&lt;/code&gt; alone. Claude Code sends the &lt;code&gt;anthropic-beta&lt;/code&gt; header that names &lt;code&gt;oauth-2025-04-20&lt;/code&gt; itself, so the proxy only swaps the placeholder.&lt;/p&gt;
&lt;p&gt;The host refreshes the OAuth login when its access token is due, as Codex&amp;rsquo;s is: a JSON refresh to &lt;code&gt;platform.claude.com/v1/oauth/token&lt;/code&gt; with Claude Code&amp;rsquo;s client ID and the login&amp;rsquo;s scopes, through the company proxy the VM&amp;rsquo;s proxy goes through, written back under the file&amp;rsquo;s lock. When the refresh fails, the proxy&amp;rsquo;s log says to run &lt;code&gt;devvm agent login claude&lt;/code&gt; again (&lt;code&gt;agent_refresh_failed&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm agent login claude&lt;/code&gt; runs &lt;code&gt;claude auth login --claudeai&lt;/code&gt; in the VM, or &lt;code&gt;claude setup-token&lt;/code&gt; with &lt;code&gt;--setup-token&lt;/code&gt;, without the VM&amp;rsquo;s &lt;code&gt;CLAUDE_CODE_OAUTH_TOKEN&lt;/code&gt;. Claude Code shows the address that comes back to &lt;code&gt;platform.claude.com/oauth/code/callback&lt;/code&gt;, which shows the code to paste, so devvm forwards no port. The login runs on your terminal. When devvm&amp;rsquo;s input and output are both terminals, devvm gives the login its output and errors as the files they are, so Lima&amp;rsquo;s &lt;code&gt;limactl shell&lt;/code&gt; gives it a terminal in the VM with &lt;code&gt;ssh -t&lt;/code&gt;, as it does devvm&amp;rsquo;s shell. &lt;code&gt;claude setup-token&lt;/code&gt; draws full-screen, so without that terminal it draws nothing and waits. Without a terminal, such as in a script or most end-to-end checks, the login gets pipes to devvm&amp;rsquo;s output, and with &lt;code&gt;--setup-token&lt;/code&gt; devvm warns first (&lt;code&gt;setup_token_no_terminal&lt;/code&gt;). Every agent&amp;rsquo;s login runs the same way, and either way, the login&amp;rsquo;s output goes to devvm&amp;rsquo;s output and never to the run log. On a terminal, ssh holds it in raw mode, so Ctrl-C goes to the login in the VM, which ends, and devvm then says that the login ended or saved nothing, rather than stopping as interrupted. A signal sent to devvm alone, such as &lt;code&gt;kill&lt;/code&gt;, ends the login in the VM within 10 seconds, for a VM that ends its login when told, and until then ssh may hold the terminal in raw mode and write the VM&amp;rsquo;s output to it. devvm saves the terminal&amp;rsquo;s state before the login starts, and puts it back once the login and its end are done, or in a cleanup if the run ends first, so an ssh that a signal killed in raw mode doesn&amp;rsquo;t leave your terminal that way. Once the store has a new login of the kind asked for, which devvm tells by the logins&amp;rsquo; checksums before and after, devvm sets the VM up again, so its environment and files hold the login devvm keeps now.&lt;/p&gt;
&lt;p&gt;Cursor&amp;rsquo;s CLI logs in by polling: &lt;code&gt;cursor-agent login&lt;/code&gt; shows &lt;code&gt;cursor.com/loginDeepControl&lt;/code&gt; with a PKCE challenge and a uuid, and asks &lt;code&gt;GET api2.cursor.sh/auth/poll?uuid=…&amp;amp;verifier=…&lt;/code&gt; until it answers &lt;code&gt;200&lt;/code&gt; with &lt;code&gt;accessToken&lt;/code&gt; and &lt;code&gt;refreshToken&lt;/code&gt;, or gives up. Its endpoint in &lt;code&gt;captures&lt;/code&gt; is that &lt;code&gt;GET&lt;/code&gt;, as devvm&amp;rsquo;s format for Cursor&amp;rsquo;s login names it, checked against the CLI&amp;rsquo;s Linux package 2026.11.17-f532c45, read but not run). The store&amp;rsquo;s poll is the request&amp;rsquo;s query, as a form, with its &lt;code&gt;uuid&lt;/code&gt; and its &lt;code&gt;verifier&lt;/code&gt;, and nothing else. A pending login&amp;rsquo;s &lt;code&gt;404&lt;/code&gt; passes as it is, and the success replaces the store&amp;rsquo;s &lt;code&gt;~/.config/cursor/auth.json&lt;/code&gt; with the two tokens. The VM gets &lt;code&gt;accessToken&lt;/code&gt; as a JWT-shaped placeholder that lasts until 2099, because the CLI reads its &lt;code&gt;exp&lt;/code&gt;, with the token&amp;rsquo;s &lt;code&gt;sub&lt;/code&gt;, which the CLI names the repos it indexes by, and &lt;code&gt;refreshToken&lt;/code&gt; as &lt;code&gt;devvm-proxy-managed&lt;/code&gt;, with the team that the reply chose. A reply without both tokens, such as an xAI sign-in&amp;rsquo;s, is refused and saves nothing.&lt;/p&gt;
&lt;p&gt;The login&amp;rsquo;s bindings put the token in &lt;code&gt;Authorization&lt;/code&gt; only for the methods that the CLI&amp;rsquo;s package calls, each one by its whole path, &lt;code&gt;/package.Service/Method&lt;/code&gt;: on &lt;code&gt;api2.cursor.sh&lt;/code&gt;, those of its API&amp;rsquo;s services, such as &lt;code&gt;DashboardService&lt;/code&gt;&amp;rsquo;s &lt;code&gt;GetMe&lt;/code&gt;, never its methods that make API keys, and its traces at &lt;code&gt;/v1/traces&lt;/code&gt;. On the agent&amp;rsquo;s hosts, &lt;code&gt;api5.cursor.sh&lt;/code&gt; and &lt;code&gt;*.api5.cursor.sh&lt;/code&gt;, which &lt;code&gt;api2.cursor.sh&lt;/code&gt;&amp;rsquo;s server config names, and on &lt;code&gt;api2.cursor.sh&lt;/code&gt;, where HTTP/1.1 takes it, only the agent&amp;rsquo;s stream, &lt;code&gt;Run&lt;/code&gt; and &lt;code&gt;RunSSE&lt;/code&gt;, and &lt;code&gt;BidiAppend&lt;/code&gt;. On &lt;code&gt;repo42.cursor.sh&lt;/code&gt;, its indexing, only its five indexing methods. The package checks the agent&amp;rsquo;s hosts only for being URLs and names none of them, so devvm takes every host below &lt;code&gt;api5.cursor.sh&lt;/code&gt;, the one Cursor&amp;rsquo;s network docs name. On every one of those hosts the proxy refuses, with &lt;code&gt;403&lt;/code&gt;, any request below &lt;code&gt;/auth/&lt;/code&gt; other than the poll it captures, so no other login endpoint there hands the VM tokens. It also refuses the API&amp;rsquo;s other methods that make, show or exchange a credential, which are the ones that the package defines by name and, in any service, any method whose name has a key, a secret, a token, a login, a session, auth, a cookie, a password, a JWT, an invitation or a link in it. It refuses the methods that change the account in a way that outlasts the VM and acts outside it, as the proxy refuses GitHub&amp;rsquo;s keys and webhooks, though the CLI calls them on the host: installing, updating and removing plugins and marketplaces, applying, deleting, testing and changing automations, setting and deleting cloud agents&amp;rsquo; environments, starting a cloud agent, and checking Bedrock keys, which devvm doesn&amp;rsquo;t keep. It refuses every method of the agent store&amp;rsquo;s service, &lt;code&gt;AgentStoreService&lt;/code&gt;, and of any service of any package whose name starts with &lt;code&gt;AgentStore&lt;/code&gt;, in any case, because the agent store isn&amp;rsquo;t the VM&amp;rsquo;s alone. The account&amp;rsquo;s CLIs on every machine and its cloud agents mount its user store read-write, its cloud agents load the skills in that store as instructions, every member of a team mounts the team&amp;rsquo;s store, and a path in a store can be shared with the team or the public. The store&amp;rsquo;s methods also take a token of its own, which &lt;code&gt;MintAgentStoreToken&lt;/code&gt; makes and which a VM could send out and use from elsewhere until it expires, so the VM gets neither the token nor the store, and the CLI keeps its sessions in a local database without them. In the services that hold the account&amp;rsquo;s and its teams&amp;rsquo; own state, &lt;code&gt;DashboardService&lt;/code&gt;, &lt;code&gt;AutomationsService&lt;/code&gt; and &lt;code&gt;BackgroundComposerService&lt;/code&gt;, it refuses any method whose name starts with a verb that changes something, such as &lt;code&gt;Set&lt;/code&gt;, &lt;code&gt;Install&lt;/code&gt;, &lt;code&gt;Start&lt;/code&gt;, &lt;code&gt;Commit&lt;/code&gt;, &lt;code&gt;Merge&lt;/code&gt;, &lt;code&gt;Fork&lt;/code&gt;, &lt;code&gt;Write&lt;/code&gt; or &lt;code&gt;Pin&lt;/code&gt;, as those services define many more. Each verb was checked against every method of those services in the pinned release, and none matches a method the CLI calls. A verb such as &lt;code&gt;Submit&lt;/code&gt;, whose &lt;code&gt;SubmitFeedback&lt;/code&gt; the CLI calls, or &lt;code&gt;Check&lt;/code&gt; or &lt;code&gt;Generate&lt;/code&gt;, whose methods also only read, isn&amp;rsquo;t on the list, so &lt;code&gt;GenerateGrokCollectionDescription&lt;/code&gt;, which drafts a description and only returns it, passes. &lt;code&gt;Test&lt;/code&gt; matches one method that only reads, &lt;code&gt;TestAutomationFilter&lt;/code&gt;, a dry run of an automation&amp;rsquo;s filter, and stays on the list for &lt;code&gt;TestTeamCustomerTelemetryDestinationConnection&lt;/code&gt;, which has Cursor&amp;rsquo;s servers send a request with any headers to any address. It also refuses every path below &lt;code&gt;/cloud-agent/&lt;/code&gt;, where &lt;code&gt;cursor-agent worker&lt;/code&gt;, which makes the machine a worker for your cloud agents, gets its identity tokens. That worker connects to &lt;code&gt;api2direct.cursor.sh&lt;/code&gt;, which has no bindings, with &lt;code&gt;Host: api2.cursor.sh&lt;/code&gt;, so the proxy doesn&amp;rsquo;t open its tunnel and the login never goes in, and on the allowlist tier the host isn&amp;rsquo;t allowed either. The list of verbs is defence in depth, because the bindings put the login only into the methods the CLI calls. A changing method whose name starts with a verb that the list doesn&amp;rsquo;t have, such as &lt;code&gt;ResolveReviewThread&lt;/code&gt;, whose verb also starts methods that only read, isn&amp;rsquo;t refused by the list, but it gets no login from the proxy either. So in a VM, Cursor&amp;rsquo;s CLI can&amp;rsquo;t do those, and you do them from Cursor on your machine. It also refuses any path it can&amp;rsquo;t read as those hosts do, with an escape, path parameters, a backslash, a byte past ASCII&amp;rsquo;s printable ones, a segment that ends in a dot or a space, or one that cleaning changes, and any request for a part of a reply (&lt;code&gt;Range&lt;/code&gt;), as the proxy could then see no more than a part of a token.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;api2.cursor.sh&lt;/code&gt; also serves the CLI&amp;rsquo;s API, whose agent replies stream, so the endpoint&amp;rsquo;s guard is &lt;code&gt;/auth/&lt;/code&gt;, with the CLI&amp;rsquo;s own token fields, such as &lt;code&gt;accessToken&lt;/code&gt;, &lt;code&gt;sessionToken&lt;/code&gt; and &lt;code&gt;apiKey&lt;/code&gt;, and any JWT added to what guard refuses there, and any cookie dropped. The bindings and those refusals are the real control. The rest is a defence in depth. On every one of Cursor&amp;rsquo;s hosts, the proxy drops the VM&amp;rsquo;s &lt;code&gt;Accept-Encoding&lt;/code&gt;, &lt;code&gt;Connect-Accept-Encoding&lt;/code&gt; and &lt;code&gt;Grpc-Accept-Encoding&lt;/code&gt; from each request, so each reply comes as it is, or as gzip that Go&amp;rsquo;s transport undoes. A Connect or gRPC server still compresses a stream&amp;rsquo;s messages with gzip when the request&amp;rsquo;s are, as the CLI&amp;rsquo;s agent stream&amp;rsquo;s are. It drops any &lt;code&gt;Set-Cookie&lt;/code&gt; from the reply, because the CLI keeps no cookies, and it refuses a reply that comes encoded anyway, by HTTP, or by Connect or gRPC in any way but a stream&amp;rsquo;s gzip, a part of a reply (&lt;code&gt;206&lt;/code&gt;), and a reply with a JWT&amp;rsquo;s start in any header, its name or its value. A Connect or gRPC stream, which its &lt;code&gt;Content-Type&lt;/code&gt; names, passes message by message: the proxy reads each message whole, at most 16 MiB as it comes and as it decompresses, gunzips it when its flag says it&amp;rsquo;s compressed, and checks it for a JWT&amp;rsquo;s start before any of it passes, as it came. Connect&amp;rsquo;s end of stream is JSON, and so is every message of a stream whose &lt;code&gt;Content-Type&lt;/code&gt; says JSON, so the proxy checks those messages&amp;rsquo; strings as they decode, escapes undone. It refuses gRPC-Web&amp;rsquo;s text variant, a whole body in base64, outright. A token in base64, such as in a &lt;code&gt;-bin&lt;/code&gt; header or a protobuf &lt;code&gt;bytes&lt;/code&gt; field of a JSON stream, isn&amp;rsquo;t found, as before. A message with a token, a flag the proxy doesn&amp;rsquo;t know, a compressed message that isn&amp;rsquo;t gzip, one over the limit or an envelope cut off ends the stream there, before that message. Every other reply&amp;rsquo;s body, of any status, length or type, passes through a reader that keeps the last 4 KiB that passed and fails at the read that would complete a JWT&amp;rsquo;s start, a header and the start of its claims, passing none of that read. The reply then ends there, so the token&amp;rsquo;s claims and signature never reach the VM, though its header may. At the body&amp;rsquo;s end the reader checks the reply&amp;rsquo;s trailers, which HTTP/2 and gRPC send after it, in the same way, and fails before the proxy sends them. Upgrades and informational replies are refused on every path, because the CLI uses neither. A token in another shape, such as an opaque one or one that the reply encodes in a way of its own, could still reach the VM. So could a presigned address that isn&amp;rsquo;t a JWT, such as one for cloud storage, in the reply of a method the login goes to, and the VM could then use it from anywhere until it expires. Refusing a path stops only the requests the VM makes, so a write that Cursor&amp;rsquo;s server makes on its own, as a side effect of a method the login goes to, such as one to the agent store, isn&amp;rsquo;t stopped either. devvm checked the CLI&amp;rsquo;s behaviour against one release of it by reading its code, not against Cursor&amp;rsquo;s servers. devvm doesn&amp;rsquo;t guard Cursor&amp;rsquo;s other hosts either: if one of them also answered &lt;code&gt;/auth/poll&lt;/code&gt;, a VM could finish a login there and keep its tokens, though none is known to. Unauthenticated requests for &lt;code&gt;/auth/poll&lt;/code&gt; with an unknown login got &lt;code&gt;404 Not found&lt;/code&gt; from &lt;code&gt;api2.cursor.sh&lt;/code&gt;, as a pending login does, and a route-not-found &lt;code&gt;404&lt;/code&gt; from &lt;code&gt;agent.api5.cursor.sh&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The CLI never refreshes a login with its refresh token: only an API key is exchanged for a token, at &lt;code&gt;/auth/exchange_user_api_key&lt;/code&gt;, which the proxy refuses, as devvm keeps no Cursor API key. So the host doesn&amp;rsquo;t refresh it either, and once the access token&amp;rsquo;s &lt;code&gt;exp&lt;/code&gt; has passed, the lookup fails with &lt;code&gt;agent_refresh_failed&lt;/code&gt;, which says to log in again.&lt;/p&gt;
&lt;p&gt;Any VM with the agent can replace the store&amp;rsquo;s login, because the store keeps one login for each agent. A VM you don&amp;rsquo;t trust can log your other VMs in to an account of its choosing, and their requests then go to that account. Claude Code&amp;rsquo;s long-lived tokens have the same shape whatever asks for one, so a token that Claude Code mints in a VM for another use, such as &lt;code&gt;claude /install-github-app&lt;/code&gt;&amp;rsquo;s, becomes devvm&amp;rsquo;s Claude Code login too, and what the VM gets is its placeholder, which works only through its proxy. A VM with Claude Code can also use the login, through its proxy, for whatever else its scopes allow at &lt;code&gt;api.anthropic.com&lt;/code&gt;, beyond the model, such as reading the account&amp;rsquo;s profile, and devvm doesn&amp;rsquo;t limit the paths it goes to there. At &lt;code&gt;mcp-proxy.anthropic.com&lt;/code&gt;, below &lt;code&gt;/v1/mcp/&lt;/code&gt;, it can call any of the account&amp;rsquo;s claude.ai connectors with any method, as Claude Code can, and each connector acts in the service it connects to with the access you gave it, so the VM can read what you connected, such as mail or documents, and send through a connector that sends. A deny of &lt;code&gt;mcp-proxy.anthropic.com&lt;/code&gt; in your rules, on every tier but open, keeps connectors from a VM (&lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#the-network"&gt;your claude.ai connectors&lt;/a&gt;). devvm doesn&amp;rsquo;t guard Anthropic&amp;rsquo;s other hosts either. If one of them also answered &lt;code&gt;/v1/oauth/token&lt;/code&gt;, a VM could exchange its code there and keep the login&amp;rsquo;s tokens, though none is known to. On the open tier, a program in the VM can go around its proxy, and then it gets the login&amp;rsquo;s tokens itself and devvm saves nothing.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tests:&lt;/strong&gt; the unit tests check what goes out and what the VM gets, its headers included, which paths are captured and the one they go to, that tokens from another path are refused, that no &lt;code&gt;1xx&lt;/code&gt; reaches the VM, an answered request and a login saved without its bindings, that an error passes, with its code alone after a real value went out, and that what can&amp;rsquo;t be read is refused. They check each agent&amp;rsquo;s file, the VM&amp;rsquo;s placeholders and copies, the exchange, the VM&amp;rsquo;s own refresh, a Console login refused, setup-token&amp;rsquo;s request told apart, the host&amp;rsquo;s refresh of Claude Code&amp;rsquo;s login and repeated fields, and that the newest Claude Code login replaces the other, the environment&amp;rsquo;s token wins, both logins&amp;rsquo; bindings get the login devvm keeps while the connectors&amp;rsquo; binding gets the OAuth login alone, never a saved token or the environment&amp;rsquo;s, and the VM&amp;rsquo;s copy holds placeholders. They also check that every VM&amp;rsquo;s config has the endpoints on every tier, which agent a capture is, that a VM captures no login for an agent its image doesn&amp;rsquo;t have, that a capture writes the VM&amp;rsquo;s bindings, and that an agent&amp;rsquo;s login gets the terminal&amp;rsquo;s files only when devvm&amp;rsquo;s input and output are both terminals, and pipes otherwise (&lt;a href="https://next.devvm.dev/docs/contributing/tests/#the-tests-behind-how-it-works"&gt;the tests behind it&lt;/a&gt;). &lt;strong&gt;End-to-end checks&lt;/strong&gt; (&lt;code&gt;network&lt;/code&gt;): a fake token endpoint behind a company proxy of the run&amp;rsquo;s own, which the VM reaches through its proxy; the store gets the real tokens and the API key, the VM&amp;rsquo;s replies hold placeholders and no refresh token, no log holds a value, and the VM&amp;rsquo;s next launch gets the login as placeholders. For Claude Code, the same company proxy fakes Claude&amp;rsquo;s token endpoint and Anthropic&amp;rsquo;s API: &lt;code&gt;claude setup-token&lt;/code&gt;&amp;rsquo;s request makes the &lt;code&gt;claude&lt;/code&gt; secret and the VM gets its placeholder, the real Claude Code&amp;rsquo;s &lt;code&gt;claude auth login&lt;/code&gt; through &lt;code&gt;devvm agent login claude&lt;/code&gt; saves the login in the store and leaves placeholders alone in the VM, &lt;code&gt;devvm agent login claude --setup-token&lt;/code&gt;, run in a terminal of its own, shows Claude Code&amp;rsquo;s address, the API gets the store&amp;rsquo;s token for the VM&amp;rsquo;s placeholders, &lt;code&gt;mcp-proxy.anthropic.com&lt;/code&gt; gets only placeholders while devvm keeps the &lt;code&gt;claude&lt;/code&gt; secret, whichever of the two the VM sends, and a login that&amp;rsquo;s due makes the host refresh it at Claude&amp;rsquo;s endpoint through the company proxy, after which both the API and &lt;code&gt;mcp-proxy.anthropic.com&lt;/code&gt; get the refreshed access token.&lt;/p&gt;
&lt;h3 data-hextra-search-id="mcp-servers"&gt;MCP servers&lt;span class="hx:absolute hx:-mt-20" id="mcp-servers"&gt;&lt;/span&gt;
&lt;a href="#mcp-servers" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;On each launch, devvm merges the settings and MCP servers from the store&amp;rsquo;s &lt;code&gt;.claude.json&lt;/code&gt;, &lt;code&gt;~/.local/share/devvm/logins/claude/.claude.json&lt;/code&gt;, into the VM&amp;rsquo;s own &lt;code&gt;~/.claude.json&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Each of your servers replaces the VM&amp;rsquo;s server of that name whole.&lt;/li&gt;
&lt;li&gt;devvm removes the servers it copied before that you no longer have.&lt;/li&gt;
&lt;li&gt;Servers added in the VM stay.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The copy holds only your settings, onboarding and account state, and MCP servers. Everything else stays out, such as &lt;code&gt;primaryApiKey&lt;/code&gt;, &lt;code&gt;customApiKeyResponses&lt;/code&gt; and your per-project entries, which &lt;code&gt;devvm agent import&lt;/code&gt; already leaves out of the store, and the VM keeps its own value of each. So the VM keeps its own per-project entries, such as trust and allowed tools, and yours never go in. Your account state, &lt;code&gt;oauthAccount&lt;/code&gt;, keeps only the fields that Claude Code 2.1.319 writes there: its profile (&lt;code&gt;accountUuid&lt;/code&gt;, &lt;code&gt;emailAddress&lt;/code&gt;, &lt;code&gt;organizationUuid&lt;/code&gt;, &lt;code&gt;hasExtraUsageEnabled&lt;/code&gt;, &lt;code&gt;billingType&lt;/code&gt;, &lt;code&gt;accountCreatedAt&lt;/code&gt;, &lt;code&gt;subscriptionCreatedAt&lt;/code&gt;, &lt;code&gt;claudeCodeTrialEndsAt&lt;/code&gt;, &lt;code&gt;claudeCodeTrialDurationDays&lt;/code&gt;, &lt;code&gt;seatTier&lt;/code&gt;, &lt;code&gt;planDisplayName&lt;/code&gt;, &lt;code&gt;displayName&lt;/code&gt;, &lt;code&gt;fullName&lt;/code&gt; and &lt;code&gt;profileFetchedAt&lt;/code&gt;), its roles (&lt;code&gt;organizationRole&lt;/code&gt;, &lt;code&gt;workspaceRole&lt;/code&gt; and &lt;code&gt;organizationName&lt;/code&gt;) and its rate-limit tiers (&lt;code&gt;organizationType&lt;/code&gt;, &lt;code&gt;organizationRateLimitTier&lt;/code&gt; and &lt;code&gt;userRateLimitTier&lt;/code&gt;), each a plain value. Its &lt;code&gt;ccOnboardingFlags&lt;/code&gt; stays as an empty object, because Claude Code fetches your profile again while that field is missing, and the flags in it stay out. devvm leaves every other field of &lt;code&gt;oauthAccount&lt;/code&gt; out of the VM&amp;rsquo;s copy and warns you, naming each by its path, such as &lt;code&gt;oauthAccount.zz&lt;/code&gt; (&lt;code&gt;login_fields_withheld&lt;/code&gt;), and the unit test that plants unknown fields checks &lt;code&gt;~/.claude.json&lt;/code&gt; as it checks the other login files. If devvm can&amp;rsquo;t read the store&amp;rsquo;s &lt;code&gt;.claude.json&lt;/code&gt;, it stops the VM&amp;rsquo;s setup (&lt;code&gt;login_copy_failed&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;On every tier, an HTTPS server&amp;rsquo;s headers become bindings for its host, which must be a DNS name on port 443. devvm replaces these with &lt;code&gt;devvm-redacted&lt;/code&gt;: env values, plain-HTTP servers&amp;rsquo; headers, user info and secret-looking values in URLs, and secret-named or key-shaped arguments. A server&amp;rsquo;s &lt;code&gt;command&lt;/code&gt; and &lt;code&gt;headersHelper&lt;/code&gt;, which are shell commands, lose the same words as other text in settings files (&lt;a href="#keys-in-settings-files"&gt;keys in settings files&lt;/a&gt;).&lt;/p&gt;
&lt;h3 data-hextra-search-id="keys-in-settings-files"&gt;Keys in settings files&lt;span class="hx:absolute hx:-mt-20" id="keys-in-settings-files"&gt;&lt;/span&gt;
&lt;a href="#keys-in-settings-files" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;devvm also takes the keys out of the VM&amp;rsquo;s copies of the agents&amp;rsquo; settings files, which are &lt;code&gt;~/.claude/settings.json&lt;/code&gt;, &lt;code&gt;~/.codex/config.toml&lt;/code&gt;, opencode&amp;rsquo;s &lt;code&gt;.json&lt;/code&gt;, &lt;code&gt;.jsonc&lt;/code&gt; and &lt;code&gt;.toml&lt;/code&gt; files and pi&amp;rsquo;s &lt;code&gt;settings.json&lt;/code&gt;, &lt;code&gt;models.json&lt;/code&gt; and &lt;code&gt;mcp.json&lt;/code&gt;. Those are JSON, JSONC or TOML, and devvm parses each file whole and writes the VM&amp;rsquo;s copy from what it parsed, so a JSONC file&amp;rsquo;s copy is JSON and a TOML file&amp;rsquo;s copy has no comments. devvm replaces these with &lt;code&gt;devvm-redacted&lt;/code&gt;, and names what it replaced (&lt;code&gt;config_redacted&lt;/code&gt;):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Every value under a key that looks like a secret&amp;rsquo;s (&lt;code&gt;*key*&lt;/code&gt;, &lt;code&gt;*token*&lt;/code&gt;, &lt;code&gt;*secret*&lt;/code&gt;, &lt;code&gt;*password*&lt;/code&gt;, &lt;code&gt;Authorization&lt;/code&gt;), and every string in a list or a table under such a key, but key bindings, such as opencode&amp;rsquo;s &lt;code&gt;keybinds&lt;/code&gt;. A name you choose isn&amp;rsquo;t judged that way, so an MCP server, a plugin or a marketplace named &lt;code&gt;secret-scanner&lt;/code&gt; or &lt;code&gt;token-saver&lt;/code&gt; keeps its settings, while its own fields, such as its &lt;code&gt;env&lt;/code&gt; or an &lt;code&gt;apiKey&lt;/code&gt;, are judged as anywhere else. devvm knows the agents&amp;rsquo; tables of names from their docs, and reads every agent&amp;rsquo;s settings files with all of them: Claude Code&amp;rsquo;s &lt;code&gt;mcpServers&lt;/code&gt;, &lt;code&gt;extraKnownMarketplaces&lt;/code&gt;, &lt;code&gt;pluginConfigs&lt;/code&gt;, &lt;code&gt;enabledPlugins&lt;/code&gt; and &lt;code&gt;skillOverrides&lt;/code&gt; among them, Codex&amp;rsquo;s &lt;code&gt;mcp_servers&lt;/code&gt;, &lt;code&gt;model_providers&lt;/code&gt;, &lt;code&gt;marketplaces&lt;/code&gt;, &lt;code&gt;plugins&lt;/code&gt;, &lt;code&gt;projects&lt;/code&gt; and &lt;code&gt;hooks.state&lt;/code&gt;, opencode&amp;rsquo;s &lt;code&gt;mcp&lt;/code&gt;, &lt;code&gt;provider&lt;/code&gt;, &lt;code&gt;agent&lt;/code&gt; and &lt;code&gt;command&lt;/code&gt;, with their 2.x names, and pi&amp;rsquo;s &lt;code&gt;providers&lt;/code&gt; and &lt;code&gt;mcpServers&lt;/code&gt;. In most of those tables, only a table under a name escapes the check, so a string right under &lt;code&gt;mcpServers&lt;/code&gt; with a secret-looking key is still replaced. In tables of settings, such as Claude Code&amp;rsquo;s &lt;code&gt;enabledPlugins&lt;/code&gt; and &lt;code&gt;skillOverrides&lt;/code&gt;, a table and a setting&amp;rsquo;s word, such as &lt;code&gt;off&lt;/code&gt; or &lt;code&gt;name-only&lt;/code&gt;, which has only lower-case letters and dashes, aren&amp;rsquo;t judged by their name either, while any other value is. A name that&amp;rsquo;s an env or headers table&amp;rsquo;s key, such as a server named &lt;code&gt;env&lt;/code&gt;, still gets its values replaced.&lt;/li&gt;
&lt;li&gt;Any string that starts like a known key or token, such as &lt;code&gt;sk-&lt;/code&gt;, &lt;code&gt;ghp_&lt;/code&gt; or &lt;code&gt;eyJ&lt;/code&gt;, wherever it is.&lt;/li&gt;
&lt;li&gt;Every value in an env or headers table, whatever its name: &lt;code&gt;env&lt;/code&gt;, &lt;code&gt;environment&lt;/code&gt;, &lt;code&gt;headers&lt;/code&gt;, &lt;code&gt;http_headers&lt;/code&gt;, and Codex&amp;rsquo;s &lt;code&gt;shell_environment_policy.set&lt;/code&gt;. A number of up to five digits, &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; stay, because they&amp;rsquo;re switches and ports. In Claude Code&amp;rsquo;s own &lt;code&gt;env&lt;/code&gt;, the top-level one of &lt;code&gt;settings.json&lt;/code&gt;, its &lt;a href="https://code.claude.com/docs/en/env-vars" target="_blank" rel="noopener"&gt;configuration variables&lt;/a&gt; stay too: &lt;code&gt;ANTHROPIC_MODEL&lt;/code&gt;, &lt;code&gt;ANTHROPIC_SMALL_FAST_MODEL&lt;/code&gt;, the &lt;code&gt;ANTHROPIC_DEFAULT_*_MODEL&lt;/code&gt; and &lt;code&gt;ANTHROPIC_CUSTOM_MODEL_OPTION&lt;/code&gt; families, &lt;code&gt;CLAUDE_CODE_*&lt;/code&gt;, &lt;code&gt;DISABLE_*&lt;/code&gt;, &lt;code&gt;MAX_*&lt;/code&gt; and &lt;code&gt;*_TIMEOUT_MS&lt;/code&gt;. A variable whose name has &lt;code&gt;KEY&lt;/code&gt;, &lt;code&gt;TOKEN&lt;/code&gt; as a word, &lt;code&gt;SECRET&lt;/code&gt;, &lt;code&gt;PASS&lt;/code&gt;, &lt;code&gt;AUTH&lt;/code&gt;, &lt;code&gt;CREDENTIAL&lt;/code&gt;, &lt;code&gt;COOKIE&lt;/code&gt; or &lt;code&gt;HEADER&lt;/code&gt; in it is redacted all the same, such as &lt;code&gt;CLAUDE_CODE_OAUTH_TOKEN&lt;/code&gt;, and so is its value when it&amp;rsquo;s a URL.&lt;/li&gt;
&lt;li&gt;In a URL anywhere in the file, a string&amp;rsquo;s whole value or a part of other text, its user info and its secret-looking query values and path segments.&lt;/li&gt;
&lt;li&gt;In every list, the arguments that MCP servers&amp;rsquo; arguments in &lt;code&gt;~/.claude.json&lt;/code&gt; lose: the value after a secret-named flag, such as &lt;code&gt;--api-key X&lt;/code&gt;, the value of &lt;code&gt;--token=X&lt;/code&gt;, and any that looks like a key.&lt;/li&gt;
&lt;li&gt;In any other string, such as a hook&amp;rsquo;s command or an argument that holds a header, each word that starts like a known key, and the credential after &lt;code&gt;Bearer&lt;/code&gt; or &lt;code&gt;Basic&lt;/code&gt;, quoted or not, when it has 16 or more characters, with a digit, &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt; or &lt;code&gt;=&lt;/code&gt; among them, which words don&amp;rsquo;t have, and isn&amp;rsquo;t a path. devvm replaces only those words, so &lt;code&gt;curl -H 'x-api-key: sk-…' URL&lt;/code&gt; becomes &lt;code&gt;curl -H 'x-api-key: devvm-redacted' URL&lt;/code&gt;, and a reference such as &lt;code&gt;Bearer ${GITHUB_TOKEN}&lt;/code&gt; stays. MCP servers&amp;rsquo; arguments, &lt;code&gt;command&lt;/code&gt; and &lt;code&gt;headersHelper&lt;/code&gt; in &lt;code&gt;~/.claude.json&lt;/code&gt; lose the same words.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Values that only name where a secret is stay as they are. Those are an environment variable&amp;rsquo;s name (&lt;code&gt;env_key = &amp;quot;OPENAI_API_KEY&amp;quot;&lt;/code&gt;), &lt;code&gt;{env:X}&lt;/code&gt;, &lt;code&gt;${X}&lt;/code&gt; and a path. devvm refuses a file that doesn&amp;rsquo;t parse as its format, instead of copying any of it unread, so the VM doesn&amp;rsquo;t get that file (&lt;code&gt;config_not_copied&lt;/code&gt;). The VM doesn&amp;rsquo;t get opencode&amp;rsquo;s other files in &lt;code&gt;~/.config/opencode&lt;/code&gt; either, such as a &lt;code&gt;.env&lt;/code&gt;, because devvm can&amp;rsquo;t take secrets out of them, apart from its Markdown files, such as &lt;code&gt;AGENTS.md&lt;/code&gt;, which hold instructions for the agent (&lt;code&gt;config_not_copied&lt;/code&gt;). An MCP server or a provider that needs one of those keys in the VM has to get it another way.&lt;/p&gt;
&lt;h3 data-hextra-search-id="saving-the-copies-back"&gt;Saving the copies back&lt;span class="hx:absolute hx:-mt-20" id="saving-the-copies-back"&gt;&lt;/span&gt;
&lt;a href="#saving-the-copies-back" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;devvm agent save&lt;/code&gt; reads the VM&amp;rsquo;s copies back, and they hold &lt;code&gt;devvm-redacted&lt;/code&gt; and the proxy&amp;rsquo;s placeholders where devvm&amp;rsquo;s agent store has your secrets (&lt;a href="https://next.devvm.dev/docs/using/coding-agents/#saving-a-vms-settings"&gt;saving a VM&amp;rsquo;s settings&lt;/a&gt;). devvm parses the VM&amp;rsquo;s file whole, and when it holds a placeholder, devvm also makes the copy the VM got from the store&amp;rsquo;s file again: the same redaction for a settings file, and for &lt;code&gt;~/.claude.json&lt;/code&gt; the copy with the VM&amp;rsquo;s own salted placeholders. Each placeholder gets the store&amp;rsquo;s value at the same path, but only when the copy had the same placeholder there, and when the table the placeholder is in and the table above that one, below the file&amp;rsquo;s top level, are the same as in the copy. Those tables say where the secret goes, such as an MCP server&amp;rsquo;s &lt;code&gt;url&lt;/code&gt; beside its &lt;code&gt;headers&lt;/code&gt;, a provider&amp;rsquo;s &lt;code&gt;baseURL&lt;/code&gt; beside its &lt;code&gt;apiKey&lt;/code&gt; and an &lt;code&gt;env&lt;/code&gt; table&amp;rsquo;s base URL beside its key, so a VM can&amp;rsquo;t keep a placeholder and point it at another host. A placeholder that fails the check leaves the whole file out of the save (&lt;code&gt;agent_save_placeholder&lt;/code&gt;), and so does a placeholder in a file without a format devvm parses, such as a skill. A file with placeholders put back is written as devvm writes the VM&amp;rsquo;s copies, as JSON or as TOML without comments, and a file without placeholders is saved as the VM has it.&lt;/p&gt;
&lt;h3 data-hextra-search-id="what-stays-in-the-vms-copies"&gt;What stays in the VM&amp;rsquo;s copies&lt;span class="hx:absolute hx:-mt-20" id="what-stays-in-the-vms-copies"&gt;&lt;/span&gt;
&lt;a href="#what-stays-in-the-vms-copies" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Taking secrets out of a file works only where devvm can tell a secret from the rest, so some go into the VM on every tier, and &lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#secrets-and-keys-the-vm-may-use"&gt;keys devvm can&amp;rsquo;t tell apart&lt;/a&gt; lists them among what devvm leaves open:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The agents&amp;rsquo; mounted folders.&lt;/strong&gt; devvm mounts Claude Code&amp;rsquo;s &lt;code&gt;skills&lt;/code&gt;, &lt;code&gt;agents&lt;/code&gt;, &lt;code&gt;commands&lt;/code&gt;, &lt;code&gt;output-styles&lt;/code&gt; and &lt;code&gt;plugins&lt;/code&gt;, Codex&amp;rsquo;s &lt;code&gt;prompts&lt;/code&gt; and &lt;code&gt;skills&lt;/code&gt;, opencode&amp;rsquo;s subfolders, and pi&amp;rsquo;s &lt;code&gt;extensions&lt;/code&gt;, &lt;code&gt;skills&lt;/code&gt;, &lt;code&gt;prompts&lt;/code&gt; and &lt;code&gt;themes&lt;/code&gt; whole and read-only, so every file in them reaches the VM, a &lt;code&gt;.env&lt;/code&gt; in &lt;code&gt;~/.config/opencode/plugin&lt;/code&gt; included. So does a plugin marketplace&amp;rsquo;s git config in &lt;code&gt;~/.claude/plugins/marketplaces&lt;/code&gt;, which holds a password or a token when you added a private marketplace with one in its URL. These folders hold code that the agent runs, such as plugins, hooks and the scripts that skills call, so a copy with only settings and Markdown, as opencode&amp;rsquo;s config folder&amp;rsquo;s files get, would break them. A copy without files whose names look secret, such as &lt;code&gt;.env&lt;/code&gt; or &lt;code&gt;*.pem&lt;/code&gt;, would miss a key in any other file, and it would need a copy of each folder, which can be large, on every launch, while a mount shows the changes to devvm&amp;rsquo;s agent store at once. So devvm mounts them as they are, and the &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#mounts"&gt;coding agents page&lt;/a&gt; says to keep secrets out of them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Free text of an unknown shape.&lt;/strong&gt; A key in other text, such as a hook&amp;rsquo;s command, stays when it neither starts like a known key nor follows &lt;code&gt;Bearer&lt;/code&gt; or &lt;code&gt;Basic&lt;/code&gt;, because devvm can&amp;rsquo;t tell it from a word.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logins devvm can&amp;rsquo;t bind.&lt;/strong&gt; opencode&amp;rsquo;s and pi&amp;rsquo;s keys that devvm can&amp;rsquo;t bind, a local model server&amp;rsquo;s among them, are withheld unless &lt;code&gt;[pass-keys]&lt;/code&gt; lists their provider, and then they go as they are (&lt;code&gt;login_passed&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;pi&amp;rsquo;s settings that undo devvm&amp;rsquo;s.&lt;/strong&gt; The VM&amp;rsquo;s copy of pi&amp;rsquo;s &lt;code&gt;settings.json&lt;/code&gt; leaves out &lt;code&gt;httpProxy&lt;/code&gt;, &lt;code&gt;sessionDir&lt;/code&gt; and &lt;code&gt;selfUpdateCommand&lt;/code&gt; (&lt;code&gt;pi_settings_dropped&lt;/code&gt;), and devvm warns when it sets &lt;code&gt;defaultProjectTrust&lt;/code&gt; to &lt;code&gt;always&lt;/code&gt; (&lt;code&gt;pi_trusts_all&lt;/code&gt;). Its other settings stay, with their keys taken out as above.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="the-self-check"&gt;The self-check&lt;span class="hx:absolute hx:-mt-20" id="the-self-check"&gt;&lt;/span&gt;
&lt;a href="#the-self-check" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A confined tier holds only while the VM runs on the process that devvm started confined. A process can&amp;rsquo;t leave its sandbox, but &lt;code&gt;limactl start&lt;/code&gt; starts a new Lima process, unconfined. So on every launch, and whenever an export or &lt;code&gt;devvm rm&lt;/code&gt;&amp;rsquo;s check of a &lt;code&gt;--clone&lt;/code&gt; VM needs the VM running, whether devvm started the VM or found it running, devvm checks two things, from the host:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;That the VM still runs on the process devvm started. The VM can&amp;rsquo;t fake this check.&lt;/li&gt;
&lt;li&gt;That a direct connection from the VM to the internet fails. The VM answers this check, so it catches only the honest case.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;devvm records the result in the VM&amp;rsquo;s state, as &lt;code&gt;ok&lt;/code&gt; or &lt;code&gt;unenforced&lt;/code&gt; in the &lt;code&gt;net&lt;/code&gt; section&amp;rsquo;s &lt;code&gt;made.check&lt;/code&gt;. When the check fails, what devvm does depends on why:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The VM wasn&amp;rsquo;t started confined,&lt;/strong&gt; because it was started outside devvm or has been running since before &lt;code&gt;devvm network&lt;/code&gt; moved it from open to a confined tier. In a terminal, devvm offers to restart the VM confined (&lt;code&gt;net_unenforced_restart&lt;/code&gt;), and if you decline, it warns you and goes on (&lt;code&gt;net_unenforced&lt;/code&gt;). Without a terminal, or if the VM is still unenforced after the restart, devvm stops the VM and ends without opening a shell (&lt;code&gt;net_unenforced_stop&lt;/code&gt;). The next &lt;code&gt;devvm&lt;/code&gt; starts the VM confined.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The VM was started confined, yet it gets out,&lt;/strong&gt; because it reaches the internet through something devvm didn&amp;rsquo;t set up, such as a second network. A restart wouldn&amp;rsquo;t help, so devvm stops the VM and ends (&lt;code&gt;net_direct_route&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is the check, and what devvm does when it fails:&lt;/p&gt;
&lt;div class="devvm-diagram" style="contain-intrinsic-block-size: auto 1086px; --devvm-diagram-width: 643px"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" class="pele pele-flowchart" viewBox="0 0 643 1086" width="643" height="1086" style="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,&amp;quot;Departure Mono&amp;quot;, monospace);font:14px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,&amp;quot;Departure Mono&amp;quot;, monospace)" fill="var(--_fg)" role="graphics-document document" aria-roledescription="flowchart" aria-labelledby="dc7b02a0e328ce16f--title" aria-describedby="dc7b02a0e328ce16f--desc"&gt;&lt;title id="dc7b02a0e328ce16f--title"&gt;The self-check on every launch&lt;/title&gt;&lt;desc id="dc7b02a0e328ce16f--desc"&gt;On every launch, devvm checks that the VM runs on the process devvm started and that a direct connection from it fails. If either isn't so, the check is unenforced. A VM started confined is then stopped, because it has another way out. Otherwise, without a terminal, devvm stops the VM without a shell, and the next devvm starts it confined. In a terminal, devvm offers to restart it confined, and warns and goes on if you say no, or stops it if the check still fails after the restart.&lt;/desc&gt;&lt;g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round"&gt;&lt;g class="pele-edge" data-id="L_launch_proc_0"&gt;&lt;path d="M191.91,53L191.91,91"/&gt;&lt;path class="pele-marker" d="M191.91,98L188.55,90L195.27,90Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_proc_direct_0"&gt;&lt;path d="M163.55,158L163.55,164Q163.55,176 151.55,176L122.64,176Q110.64,176 110.64,188L110.64,231.5"/&gt;&lt;path class="pele-marker" d="M110.64,238.5L107.28,230.5L114,230.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_direct_ok_0"&gt;&lt;path d="M85.5,298.5L85.5,372"/&gt;&lt;path class="pele-marker" d="M85.5,379L82.14,371L88.86,371Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_proc_un_0"&gt;&lt;path d="M220.27,158L220.27,164Q220.27,176 232.27,176L278.32,176Q290.32,176 290.32,188L290.32,372"/&gt;&lt;path class="pele-marker" d="M290.32,379L286.96,371L293.68,371Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_direct_un_0"&gt;&lt;path d="M161.27,298.5L161.27,304.5Q161.27,316.5 173.27,316.5L255.41,316.5Q267.41,316.5 267.41,328.5L267.41,372"/&gt;&lt;path class="pele-marker" d="M267.41,379L264.05,371L270.77,371Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_un_confined_0"&gt;&lt;path d="M282.32,424L282.32,462"/&gt;&lt;path class="pele-marker" d="M282.32,469L278.96,461L285.68,461Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_confined_route_0"&gt;&lt;path d="M240.59,514L240.59,520Q240.59,532 228.59,532L202.59,532Q190.59,532 190.59,544L190.59,601.5"/&gt;&lt;path class="pele-marker" d="M190.59,608.5L187.23,600.5L193.95,600.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_confined_term_0"&gt;&lt;path d="M324.05,514L324.05,520Q324.05,532 336.05,532L362.05,532Q374.05,532 374.05,544L374.05,609"/&gt;&lt;path class="pele-marker" d="M374.05,616L370.69,608L377.41,608Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_term_stop_0"&gt;&lt;path d="M359.05,661L359.05,674.5Q359.05,686.5 347.05,686.5L241.43,686.5Q229.43,686.5 229.43,698.5L229.43,993"/&gt;&lt;path class="pele-marker" d="M229.43,1000L226.07,992L232.79,992Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_term_offer_0"&gt;&lt;path d="M389.05,661L389.05,674.5Q389.05,686.5 401.05,686.5L438.3,686.5Q450.3,686.5 450.3,698.5L450.3,742"/&gt;&lt;path class="pele-marker" d="M450.3,749L446.94,741L453.66,741Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_offer_warn_0"&gt;&lt;path d="M395.2,794L395.2,800Q395.2,812 383.2,812L361.66,812Q349.66,812 349.66,824L349.66,867.5"/&gt;&lt;path class="pele-marker" d="M349.66,874.5L346.3,866.5L353.02,866.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_offer_again_0"&gt;&lt;path d="M505.39,794L505.39,800Q505.39,812 517.39,812L538.93,812Q550.93,812 550.93,824L550.93,867.5"/&gt;&lt;path class="pele-marker" d="M550.93,874.5L547.57,866.5L554.29,866.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_again_ok2_0"&gt;&lt;path d="M576.07,919.5L576.07,993"/&gt;&lt;path class="pele-marker" d="M576.07,1000L572.71,992L579.43,992Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_again_stop_0"&gt;&lt;path d="M525.8,919.5L525.8,970Q525.8,982 513.8,982L314.14,982Q305.89,982 305.89,990.25L305.89,993"/&gt;&lt;path class="pele-marker" d="M305.89,1000L302.53,992L309.25,992Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edge-labels" font-size="14"&gt;&lt;g class="pele-edge-label" data-id="L_proc_direct_0"&gt;&lt;rect x="93.27" y="196" width="34.73" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="110.64" y="209.2" text-anchor="middle"&gt;yes&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_direct_ok_0"&gt;&lt;rect x="68.14" y="336.5" width="34.73" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="85.5" y="349.7" text-anchor="middle"&gt;yes&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_proc_un_0"&gt;&lt;rect x="277.41" y="259.5" width="25.82" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="290.32" y="272.7" text-anchor="middle"&gt;no&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_direct_un_0"&gt;&lt;rect x="254.5" y="336.5" width="25.82" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="267.41" y="349.7" text-anchor="middle"&gt;no&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_confined_route_0"&gt;&lt;rect x="133.14" y="552" width="114.91" height="32" rx="3" fill="var(--_bg)"/&gt;&lt;text text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="190.59" y="564.2"&gt;yes: another&lt;/tspan&gt;&lt;tspan x="190.59" y="580.2"&gt;way out&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_confined_term_0"&gt;&lt;rect x="361.14" y="559" width="25.82" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="374.05" y="572.2" text-anchor="middle"&gt;no&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_term_stop_0"&gt;&lt;rect x="216.52" y="762.5" width="25.82" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="229.43" y="775.7" text-anchor="middle"&gt;no&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_term_offer_0"&gt;&lt;rect x="432.93" y="706.5" width="34.73" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="450.3" y="719.7" text-anchor="middle"&gt;yes&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_offer_warn_0"&gt;&lt;rect x="336.75" y="832" width="25.82" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="349.66" y="845.2" text-anchor="middle"&gt;no&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_offer_again_0"&gt;&lt;rect x="533.57" y="832" width="34.73" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="550.93" y="845.2" text-anchor="middle"&gt;yes&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_again_ok2_0"&gt;&lt;rect x="558.7" y="944" width="34.73" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="576.07" y="957.2" text-anchor="middle"&gt;yes&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_again_stop_0"&gt;&lt;rect x="512.89" y="944" width="25.82" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="525.8" y="957.2" text-anchor="middle"&gt;no&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-nodes"&gt;&lt;g class="pele-node pele-shape-rect" data-id="launch" transform="translate(191.91,30.5)"&gt;&lt;rect x="-71.45" y="-22.5" width="142.91" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;every launch&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="proc" transform="translate(191.91,128)"&gt;&lt;rect x="-80.36" y="-30" width="160.73" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;on the process&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;devvm started?&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="direct" transform="translate(110.64,268.5)"&gt;&lt;rect x="-102.64" y="-30" width="205.27" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;a direct connection&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;from the VM fails?&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="ok" transform="translate(85.5,401.5)"&gt;&lt;rect x="-58.09" y="-22.5" width="116.18" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;check: ok&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="un" transform="translate(282.32,401.5)"&gt;&lt;rect x="-93.73" y="-22.5" width="187.45" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;check: unenforced&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="confined" transform="translate(282.32,491.5)"&gt;&lt;rect x="-93.73" y="-22.5" width="187.45" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;started confined?&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="route" transform="translate(190.59,638.5)"&gt;&lt;rect x="-71.45" y="-30" width="142.91" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;stops the VM&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;and ends&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="term" transform="translate(374.05,638.5)"&gt;&lt;rect x="-67" y="-22.5" width="134" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;a terminal?&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="stop" transform="translate(237.43,1039)"&gt;&lt;rect x="-120.45" y="-39" width="240.91" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;stops the VM, no shell;&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;the next devvm starts&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;it confined&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="offer" transform="translate(450.3,771.5)"&gt;&lt;rect x="-107.09" y="-22.5" width="214.18" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;restart it confined?&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="warn" transform="translate(349.66,897)"&gt;&lt;rect x="-80.36" y="-22.5" width="160.73" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;warns, goes on&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="again" transform="translate(550.93,897)"&gt;&lt;rect x="-75.91" y="-22.5" width="151.82" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;enforced now?&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="ok2" transform="translate(576.07,1022.5)"&gt;&lt;rect x="-58.09" y="-22.5" width="116.18" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;check: ok&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/div&gt;&lt;p&gt;An open VM isn&amp;rsquo;t confined, so its self-check is another one: a command in the VM asks its proxy for &lt;code&gt;http://devvm.proxy/blocked&lt;/code&gt; through the proxy that the VM&amp;rsquo;s &lt;code&gt;/etc/environment&lt;/code&gt; names, the variable&amp;rsquo;s name in the command and never the password. When the proxy doesn&amp;rsquo;t answer, devvm warns you (&lt;code&gt;net_proxy_unreachable&lt;/code&gt;) and goes on, records no result, and the VM keeps running.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm ls&lt;/code&gt; and &lt;code&gt;devvm network&lt;/code&gt; show such a VM&amp;rsquo;s tier as &lt;code&gt;unenforced&lt;/code&gt;. That&amp;rsquo;s a VM whose last self-check failed, or a running VM that isn&amp;rsquo;t on the process devvm started confined, which devvm checks on the host each time.&lt;/p&gt;
&lt;p&gt;On Lima, &amp;ldquo;the process devvm started&amp;rdquo; is the VM&amp;rsquo;s Lima process, which devvm starts &lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;confined&lt;/a&gt;.&lt;/p&gt;
&lt;h2 data-hextra-search-id="log-files"&gt;Log files&lt;span class="hx:absolute hx:-mt-20" id="log-files"&gt;&lt;/span&gt;
&lt;a href="#log-files" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The proxy writes every decision (&lt;code&gt;tunnel&lt;/code&gt;, &lt;code&gt;intercept&lt;/code&gt;, &lt;code&gt;forward&lt;/code&gt;, &lt;code&gt;blocked&lt;/code&gt;, or &lt;code&gt;nix-cache&lt;/code&gt; for a request to the &lt;a href="#the-shared-nix-cache"&gt;shared Nix cache&lt;/a&gt;) as a JSON line in &lt;code&gt;network.jsonl&lt;/code&gt; in the VM&amp;rsquo;s logs folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/logs/&lt;/code&gt;. A line holds the time, the VM, the host and port, the method and path when the proxy sees them, the rule or the reason, and the names of the secrets it put in, never their values. A connection that &lt;a href="#tools-that-skip-the-proxy"&gt;transparent mode&lt;/a&gt; sent to the proxy, and each request on it, has &lt;code&gt;&amp;quot;via&amp;quot;: &amp;quot;dns&amp;quot;&lt;/code&gt;, which &lt;code&gt;devvm network log&lt;/code&gt; shows as &lt;code&gt;, without proxy settings&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The proxy&amp;rsquo;s own lines, such as what it loaded and what failed upstream, go to &lt;code&gt;proxy.log&lt;/code&gt; next to it. An upstream error stays there, because it can name addresses that the VM shouldn&amp;rsquo;t learn. So when a name doesn&amp;rsquo;t resolve, or a tunnel can&amp;rsquo;t connect, the VM&amp;rsquo;s &lt;code&gt;403&lt;/code&gt;, its &lt;code&gt;http://devvm.proxy/blocked&lt;/code&gt; and the event log give only the reason. For a name, that&amp;rsquo;s &lt;code&gt;this machine's DNS has no address for it&lt;/code&gt; when the DNS server says the name has none, with &lt;code&gt;and names resolve without its search domain; use the full name, such as jenkins.corp.example.com&lt;/code&gt; after it for a name without a dot, &lt;code&gt;this machine's DNS didn't answer in time; see proxy.log on the host&lt;/code&gt; when it doesn&amp;rsquo;t answer, and &lt;code&gt;can't resolve it; see proxy.log on the host&lt;/code&gt; for any other failure. A rule allows the name already, so each of these blocks is marked &lt;code&gt;refused&lt;/code&gt;, and neither the &lt;code&gt;403&lt;/code&gt;, nor &lt;code&gt;http://devvm.proxy/blocked/new&lt;/code&gt;, nor &lt;code&gt;devvm network log --blocked&lt;/code&gt; suggests a &lt;code&gt;devvm network allow&lt;/code&gt; command for it. For a tunnel, it&amp;rsquo;s &lt;code&gt;connect failed; see proxy.log on the host&lt;/code&gt;. The error itself, which can name this machine&amp;rsquo;s DNS server or the company proxy&amp;rsquo;s address and what it answered, goes to &lt;code&gt;proxy.log&lt;/code&gt; alone. After a timeout or another failure that may pass, the proxy asks the DNS server once more before it blocks the name. When the client goes away while its name is still resolving, nothing was refused, so the event log and &lt;code&gt;http://devvm.proxy/blocked&lt;/code&gt; record no block. The lookup still went out, though, and a name can carry data, so &lt;code&gt;proxy.log&lt;/code&gt; names the host and port with &lt;code&gt;the client went away while its name resolved&lt;/code&gt;, for at most 20 such lookups a minute, and then says that it stops until the minute is up. The broker&amp;rsquo;s own line for each of the child&amp;rsquo;s lookups and connections that failed, such as one to an address that no rule names, is held the same way, to 20 a minute. A name that resolves to an internal address gets the reason &lt;code&gt;it resolves to an internal address; allow the address itself to reach it&lt;/code&gt;, which tells the VM that much and not the address (&lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#network"&gt;attack vectors&lt;/a&gt;). Only you can read the VM&amp;rsquo;s logs folder and its run folder, and devvm&amp;rsquo;s run logs never hold a VM&amp;rsquo;s password. The VM chose the hosts and paths, so &lt;code&gt;devvm network log&lt;/code&gt; drops control characters in them.&lt;/p&gt;
&lt;p&gt;The event log also holds the VM&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/internals/ports/#links-between-vms"&gt;links&lt;/a&gt;&amp;rsquo; connections, which &lt;code&gt;devvm _links&lt;/code&gt; writes in the same format: &lt;code&gt;link&lt;/code&gt; for a connection it carried, and &lt;code&gt;link_refused&lt;/code&gt;, &lt;code&gt;link_target_stopped&lt;/code&gt; or &lt;code&gt;link_limit&lt;/code&gt; for one it refused, with the link&amp;rsquo;s name as the host and the target VM in &lt;code&gt;target&lt;/code&gt;. An open VM&amp;rsquo;s event log holds its proxy&amp;rsquo;s events and its links&amp;rsquo;, but nothing it reached directly.&lt;/p&gt;
&lt;p&gt;The proxy&amp;rsquo;s broker and its child are the only programs that write &lt;code&gt;proxy.log&lt;/code&gt;, which is the output of both, each line&amp;rsquo;s prefix saying whether the broker or the child wrote it. Either may rotate it, through the file devvm opened for them and never by its path. It takes the file&amp;rsquo;s lock, checks the file&amp;rsquo;s size again, copies the file to &lt;code&gt;proxy.log.1&lt;/code&gt; and empties it, so the two rotate it once. The event log has the child and &lt;code&gt;devvm _links&lt;/code&gt; as its writers.&lt;/p&gt;
&lt;p&gt;The child writes the VM&amp;rsquo;s logs folder, so devvm, &lt;code&gt;devvm _links&lt;/code&gt;, &lt;code&gt;devvm network log&lt;/code&gt;, &lt;code&gt;devvm network lock&lt;/code&gt; and the proxy never open the logs there through a link at their end, and they take only a regular file with one link that&amp;rsquo;s yours. A start that finds a link, a FIFO or another file&amp;rsquo;s hard link where a log should be removes that name, never what it leads to, and starts a new log there, and &lt;code&gt;devvm network log&lt;/code&gt; refuses such a file without waiting on it. The proxy rotates each log before a line would take it past 10 MiB, and &lt;code&gt;devvm _links&lt;/code&gt; writes the event log with the proxy&amp;rsquo;s own code, so it rotates the log by the same rule and a VM that runs for months keeps at most about 20 MiB of each. A line never spans two files, and lines from the proxy&amp;rsquo;s connections at the same time are written one after another, so a rotation loses none and splits none. Before each line, each writer checks that the file it has open is still &lt;code&gt;network.jsonl&lt;/code&gt;, and when the other writer has rotated it, the writer opens the new &lt;code&gt;network.jsonl&lt;/code&gt; and writes there, so its lines go on reaching the file that &lt;code&gt;devvm network log --follow&lt;/code&gt; follows. Each writer takes the log&amp;rsquo;s size from the file, so it counts the other writer&amp;rsquo;s lines too. A writer rotates the log while it holds a lock on the file and checks the name again first, so when both reach the limit at once, only one renames the file and the other writes to the new one. A rotation renames &lt;code&gt;network.jsonl&lt;/code&gt; to &lt;code&gt;network.jsonl.1&lt;/code&gt;, which replaces the one that was there, and starts a new &lt;code&gt;network.jsonl&lt;/code&gt;. &lt;code&gt;proxy.log&lt;/code&gt; is also the proxy process&amp;rsquo;s output, where its last error goes when it stops, so the proxy copies it to &lt;code&gt;proxy.log.1&lt;/code&gt; and empties it instead, and that error still reaches the current file. The proxy takes &lt;code&gt;proxy.log&lt;/code&gt;&amp;rsquo;s size from the file before each line, so what reached it as the processes&amp;rsquo; output counts too, and its HTTP server&amp;rsquo;s errors, such as a handler&amp;rsquo;s panic, go through the child&amp;rsquo;s own lines rather than straight to that output. Every log file and its &lt;code&gt;.1&lt;/code&gt; file is readable only by you (mode 600).&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm network log&lt;/code&gt; reads &lt;code&gt;network.jsonl.1&lt;/code&gt; before &lt;code&gt;network.jsonl&lt;/code&gt;, so the history it shows and the blocks that &lt;code&gt;devvm network log --blocked&lt;/code&gt; counts carry on across a rotation. &lt;code&gt;devvm network log --follow&lt;/code&gt; reads the renamed file to its end and then follows the new one from its start. &lt;code&gt;devvm rm&lt;/code&gt; deletes the &lt;code&gt;.1&lt;/code&gt; files with the rest of the VM&amp;rsquo;s logs.&lt;/p&gt;
&lt;h3 data-hextra-search-id="learning-from-the-log"&gt;Learning from the log&lt;span class="hx:absolute hx:-mt-20" id="learning-from-the-log"&gt;&lt;/span&gt;
&lt;a href="#learning-from-the-log" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A VM that &lt;a href="https://next.devvm.dev/docs/safety/network/#learning-the-hosts-a-vm-needs"&gt;learns the hosts it needs&lt;/a&gt; is on the internet tier, and its state&amp;rsquo;s &lt;code&gt;net&lt;/code&gt; section has &lt;code&gt;learning.since&lt;/code&gt;, the time it started, which any tier set later clears. Its proxy runs as any internet VM&amp;rsquo;s does, so nothing else records what it reaches: &lt;code&gt;devvm network lock&lt;/code&gt; and each launch&amp;rsquo;s reminder read the event log, both files. They take each &lt;code&gt;tunnel&lt;/code&gt;, &lt;code&gt;intercept&lt;/code&gt; and &lt;code&gt;forward&lt;/code&gt; event since that time, one row for each host and port, its rule the exact one for that host, which always writes the port, counting its events and the first word of the &lt;code&gt;User-Agent&lt;/code&gt; its requests sent most, which a CONNECT&amp;rsquo;s event records too, when that word is at most 32 of &lt;code&gt;[A-Za-z0-9._/+-]&lt;/code&gt;. The proxy caps an event&amp;rsquo;s path and &lt;code&gt;User-Agent&lt;/code&gt; at 512 bytes as it records them, and takes no request headers past 64 KiB, so a VM can&amp;rsquo;t bloat the log. An address that isn&amp;rsquo;t public, by the proxy&amp;rsquo;s one judge of that, and a host the policy doesn&amp;rsquo;t take are left out. Each host and port is judged once with the policies the VM would have on the allowlist tier, read as the proxy reads them, its built-in policies from the binary included, and with the proxy&amp;rsquo;s own decisions by its rules, so a host that the allowlist already allows, or that a rule denies, never shows. A host starts ticked when, on port 443, it&amp;rsquo;s one of devvm&amp;rsquo;s reviewed registry and vendor names, or under one, each with its reason beside it, and it isn&amp;rsquo;t risky. Nothing of the VM&amp;rsquo;s rules, secrets or own policy file makes a host tickable, so a host one lock added never makes its neighbours tick later, and a unit test checks that no name on the list is a shared-hosting domain or under one. The risky hosts, which are marked and start unticked, are an address, a punycode label, a host on its lists of paste and drop sites, storage, tunnels, webhook and OAST services, free hosting and chat endpoints, or under one of them, and the patterns of OAST domains, S3 and API Gateway. Past 30 hosts none starts ticked. The picker reads the terminal&amp;rsquo;s size, cuts each row to its width and a long name from the left, and scrolls in a window that keeps the same number of lines, so a redraw moves back over exactly what it drew. It refuses a terminal too short for a row and its two &amp;ldquo;more&amp;rdquo; lines (&lt;code&gt;pick_too_small&lt;/code&gt;), takes a terminal of unknown size as 80 by 24, and on a read that fails, such as the EIO of a terminal that hung up, returns &lt;code&gt;pick_failed&lt;/code&gt; and confirms nothing, while the end of the input confirms, as Enter does. The risky hosts are a section of their own under a heading, so their mark never depends on a row&amp;rsquo;s width, and so are the hosts that only events with &lt;code&gt;&amp;quot;via&amp;quot;: &amp;quot;dns&amp;quot;&lt;/code&gt; reached, between the others and the risky ones. The lock re-reads the VM&amp;rsquo;s state under the VM&amp;rsquo;s lock, in the one update of a VM&amp;rsquo;s state, before it adds a rule, and changes nothing when its context ended meanwhile or the VM no longer learns since the same time, and it says what it added only once the proxy has the new tier. &lt;code&gt;devvm network learn&lt;/code&gt; and &lt;code&gt;devvm group join&lt;/code&gt; each check the other&amp;rsquo;s change under the VM&amp;rsquo;s lock too, so a learning VM never ends up in a group. A launch&amp;rsquo;s reminder counts only while both files hold at most 2 MiB. devvm keeps no record of its own beside the log, so a log that rotated twice since the VM started learning has lost its first hosts. As a VM starts learning, devvm writes a &lt;code&gt;learn&lt;/code&gt; event into its log with the proxy&amp;rsquo;s own writer, which &lt;code&gt;devvm network log&lt;/code&gt; doesn&amp;rsquo;t show, and &lt;code&gt;devvm network lock&lt;/code&gt; warns when that mark is gone.&lt;/p&gt;
&lt;h2 data-hextra-search-id="devvm-_proxy"&gt;devvm _proxy&lt;span class="hx:absolute hx:-mt-20" id="devvm-_proxy"&gt;&lt;/span&gt;
&lt;a href="#devvm-_proxy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm runs the proxy as itself, &lt;code&gt;devvm _proxy -config FILE&lt;/code&gt;, and nothing else is in its arguments. That&amp;rsquo;s the broker, which runs its child as &lt;code&gt;devvm _proxy-child -for FILE&lt;/code&gt;, with the same config&amp;rsquo;s path, which the child never opens. The path is there so devvm can tell each VM&amp;rsquo;s child apart, by &lt;code&gt;run/proxy-child.pid&lt;/code&gt; and those arguments, and stop one that outlived its broker. Their flags take one dash or two, and their errors end in one line, &lt;code&gt;The VM's proxy failed: …&lt;/code&gt; (&lt;code&gt;proxy_failed&lt;/code&gt;). &lt;a href="https://next.devvm.dev/docs/internals/processes/#a-vms-proxy"&gt;Processes&lt;/a&gt; has what a VM&amp;rsquo;s proxy holds, what it reads from the VM and its bounds, and &lt;a href="https://next.devvm.dev/docs/internals/processes/#a-builds-proxy"&gt;a build&amp;rsquo;s proxy&lt;/a&gt; has the build&amp;rsquo;s.&lt;/p&gt;
&lt;p&gt;The config is one JSON file, which a VM&amp;rsquo;s proxy and a build&amp;rsquo;s proxy both run with. For a VM it&amp;rsquo;s &lt;code&gt;proxy.json&lt;/code&gt; in the VM&amp;rsquo;s run folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/&lt;/code&gt;, and for a build it&amp;rsquo;s &lt;code&gt;proxy.json&lt;/code&gt; in the build proxy&amp;rsquo;s folder. devvm writes it whole, mode 600, before each start. It holds the VM&amp;rsquo;s password and the company proxy&amp;rsquo;s credentials from the environment, though never &lt;code&gt;config.toml&lt;/code&gt;&amp;rsquo;s password, which the proxy looks up itself, so it&amp;rsquo;s never in a process&amp;rsquo;s arguments, which other users can see. The proxy reads it once, as it starts, and refuses to start unless it&amp;rsquo;s a regular file, not a symbolic link, owned by the user the proxy runs as and readable and writable by nobody else, at most 1 MiB, of &lt;code&gt;&amp;quot;version&amp;quot;: 1&lt;/code&gt;, with no field the proxy doesn&amp;rsquo;t know. It also refuses a config without a password, one whose &lt;code&gt;listen&lt;/code&gt; isn&amp;rsquo;t a loopback address and port, one with &lt;code&gt;ca&lt;/code&gt; and no &lt;code&gt;ca_key&lt;/code&gt; or the other way around, and one with a &lt;code&gt;nix_cache_max&lt;/code&gt; below 0. A config of another version is never read, so a proxy and the devvm that started it always agree on what each field means.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;What&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;version&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;listen&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the loopback address and port to listen on, port 0 for any free one&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;vm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s name, for the log&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;password&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s password, which every request carries in &lt;code&gt;Proxy-Authorization&lt;/code&gt; with the user &lt;code&gt;devvm&lt;/code&gt;; required&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;builtin_policies&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the built-in policies, paths in devvm&amp;rsquo;s own files, read from the binary once as the proxy starts, ahead of &lt;code&gt;policies&lt;/code&gt;; a missing one refuses to start&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;policies&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;your policy files, in order, each read again when it changes; a missing one has no rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;log&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the JSON-lines event log (none: standard output), &lt;a href="#log-files"&gt;rotated&lt;/a&gt; past 10 MiB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;proxy_log&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the file that the proxy&amp;rsquo;s output goes to, which is its own log, rotated past 10 MiB by copying&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;lifeline&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the hostagent&amp;rsquo;s pid file: exit once it no longer holds what it held when the proxy first saw its process running, or that process is gone&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ca&lt;/code&gt;, &lt;code&gt;ca_key&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the &lt;a href="#the-vms-ca"&gt;VM&amp;rsquo;s own CA&lt;/a&gt;, for interception: its certificate and key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ca_next&lt;/code&gt;, &lt;code&gt;ca_next_key&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;with &lt;code&gt;ca&lt;/code&gt;: the VM&amp;rsquo;s next CA, which signs from an hour after its start&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;secrets&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s bindings file, read again when it changes, and the broker looks each binding&amp;rsquo;s value up in its own process, for the child&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;upstream_cas&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the &lt;a href="#a-companys-ca"&gt;CAs in your CA folder&lt;/a&gt; (PEM), which the proxy&amp;rsquo;s own TLS connections trust besides the system&amp;rsquo;s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;upstream&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the &lt;a href="#through-a-company-proxy"&gt;company proxy&lt;/a&gt;: &lt;code&gt;https&lt;/code&gt;, &lt;code&gt;http&lt;/code&gt; and &lt;code&gt;no_proxy&lt;/code&gt;, as &lt;code&gt;HTTPS_PROXY&lt;/code&gt;, &lt;code&gt;HTTP_PROXY&lt;/code&gt; and &lt;code&gt;NO_PROXY&lt;/code&gt; or &lt;code&gt;config.toml&lt;/code&gt;&amp;rsquo;s &lt;code&gt;[proxy]&lt;/code&gt; had them, and &lt;code&gt;secret&lt;/code&gt;, the secret the proxy looks up as the password of a URL that names a user and none of its own; allowed hosts are reached through it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;upstream_unresolved&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;with &lt;code&gt;upstream&lt;/code&gt;: names this machine can&amp;rsquo;t resolve go there even when only &lt;code&gt;**&lt;/code&gt; allows them, which builds&amp;rsquo; proxies get&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;nix_cache&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;serve the &lt;a href="#the-shared-nix-cache"&gt;shared Nix cache&lt;/a&gt; at &lt;code&gt;http://devvm.proxy/nix/&lt;/code&gt; from this folder, which it makes, only yours (mode 700)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;nix_cache_max&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;with &lt;code&gt;nix_cache&lt;/code&gt;: the cache&amp;rsquo;s cap, in bytes (none: 10 GiB)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;links&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s links&amp;rsquo; list, which &lt;code&gt;devvm _links&lt;/code&gt; writes: reach each link through its socket, before any rule (&lt;a href="#links-through-the-proxy"&gt;links through the proxy&lt;/a&gt;); a missing list has no links&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;link_sockets&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;with &lt;code&gt;links&lt;/code&gt;: the folder of the links&amp;rsquo; sockets, devvm&amp;rsquo;s run folder; without it, no link is reached&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;vm_logs&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the logs that the VM&amp;rsquo;s backend writes as the VM runs and the VM can drive, such as its serial console&amp;rsquo;s, which the proxy holds to their cap for as long as it runs (&lt;a href="https://next.devvm.dev/docs/internals/processes/#limas-hostagent"&gt;Lima&amp;rsquo;s hostagent&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agent&lt;/code&gt;, &lt;code&gt;agent_socket&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;together, as absolute paths: the SSH agent that the VM&amp;rsquo;s start forwards, your own or devvm&amp;rsquo;s, and the VM&amp;rsquo;s own socket in devvm&amp;rsquo;s run folder, &lt;code&gt;agent-&amp;lt;hash&amp;gt;.sock&lt;/code&gt;, on which the proxy relays it and which the VM&amp;rsquo;s backend forwards instead (&lt;a href="https://next.devvm.dev/docs/internals/processes/#the-ssh-agents"&gt;the SSH agents&lt;/a&gt;). devvm keeps a running VM&amp;rsquo;s as its start set them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;devvm_sha256&lt;/code&gt;, &lt;code&gt;ca_sha256&lt;/code&gt;, &lt;code&gt;ca_next_sha256&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the SHA-256 of devvm&amp;rsquo;s binary, of the VM&amp;rsquo;s CA certificate and of its next CA&amp;rsquo;s that the proxy started with; the proxy doesn&amp;rsquo;t read them, and they&amp;rsquo;re there so that a new binary or a new CA makes another config (&lt;a href="#how-long-a-proxy-runs"&gt;how long a proxy runs&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;-config&lt;/code&gt; is the proxy&amp;rsquo;s only flag, and running the proxy is its only mode. What only this machine does for a VM&amp;rsquo;s proxy runs inside devvm itself, never through the proxy&amp;rsquo;s arguments. devvm makes each VM&amp;rsquo;s CAs, and the VM&amp;rsquo;s copies of agents&amp;rsquo; logins and settings files, their bindings and their values, in its own process (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt;).&lt;/p&gt;</description></item><item><title>.git protection</title><link>https://next.devvm.dev/docs/internals/git-protection/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/git-protection/</guid><description>
&lt;p&gt;This page explains what devvm locks in a project&amp;rsquo;s git folder, when it locks and checks the locks again, and what the locks can&amp;rsquo;t stop. &lt;a href="https://next.devvm.dev/docs/safety/git-protection/"&gt;.git protection&lt;/a&gt; covers what still works, turning protection on or off, VMs that were strict, and what isn&amp;rsquo;t covered.&lt;/p&gt;
&lt;p&gt;On macOS devvm locks with the user-immutable flag (&lt;code&gt;chflags uchg&lt;/code&gt;), which even root in the VM can&amp;rsquo;t clear. A read-only mount wouldn&amp;rsquo;t hold, because root in the VM can unmount it.&lt;/p&gt;
&lt;p&gt;On Linux devvm makes the same paths read-only in the user and mount namespace it runs the VM&amp;rsquo;s QEMU in (&lt;a href="#on-linux-hosts"&gt;on Linux hosts&lt;/a&gt;), so the VM, which reaches the folder only through QEMU, can&amp;rsquo;t change them.&lt;/p&gt;
&lt;p&gt;Each check reads each repo&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt; once, the folder&amp;rsquo;s own and those nested in it, finding its git folders, submodules, what it would lock, what the locked files hand over and what points git elsewhere, and then locks, unlocks, watches and reports from what it found. The host&amp;rsquo;s locker does the locking: the flag on macOS, and on Linux nothing at the check itself, because the VM&amp;rsquo;s next start makes the paths read-only. A Linux host whose kernel refuses devvm the namespace locks nothing, and devvm &lt;a href="#the-watch"&gt;watches&lt;/a&gt; &lt;code&gt;.git&lt;/code&gt; there instead.&lt;/p&gt;
&lt;h2 data-hextra-search-id="whats-locked"&gt;What&amp;rsquo;s locked&lt;span class="hx:absolute hx:-mt-20" id="whats-locked"&gt;&lt;/span&gt;
&lt;a href="#whats-locked" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm locks these paths, of the folder&amp;rsquo;s own repo and of each &lt;a href="#nested-repos"&gt;nested repo&lt;/a&gt; it protects:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.git/hooks&lt;/code&gt; and &lt;code&gt;.git/config&lt;/code&gt;. A repo without a &lt;code&gt;hooks&lt;/code&gt; folder gets an empty one, locked, so the VM can&amp;rsquo;t make one.&lt;/li&gt;
&lt;li&gt;The same paths for each submodule devvm finds, submodules of submodules included. Those are the git folders under &lt;code&gt;.git/modules&lt;/code&gt;, and those in the working tree, which are &lt;code&gt;sub/.git&lt;/code&gt; or the folder that a &lt;code&gt;sub/.git&lt;/code&gt; file points to. devvm finds the submodules from the index, which it reads with &lt;code&gt;core.fsmonitor&lt;/code&gt; off. It takes a folder for a git folder only when it has what git looks for in one, which is a &lt;code&gt;HEAD&lt;/code&gt;, and &lt;code&gt;objects&lt;/code&gt; and &lt;code&gt;refs&lt;/code&gt; in the folder or in the folder its &lt;code&gt;commondir&lt;/code&gt; names, as git&amp;rsquo;s own test has it. The VM can point a &lt;code&gt;sub/.git&lt;/code&gt; file at any folder in the project, such as &lt;code&gt;src&lt;/code&gt;, and locking that folder&amp;rsquo;s &lt;code&gt;hooks&lt;/code&gt; and &lt;code&gt;config&lt;/code&gt; would lock your own files, so devvm locks and creates nothing in a folder that fails the check and reports it instead.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;.git/config.worktree&lt;/code&gt;, when &lt;code&gt;extensions.worktreeConfig&lt;/code&gt; is on. devvm creates it empty if it&amp;rsquo;s missing.&lt;/li&gt;
&lt;li&gt;What linked worktrees elsewhere on your machine read from here, which is &lt;code&gt;.git/worktrees/&amp;lt;name&amp;gt;/commondir&lt;/code&gt; and &lt;code&gt;config.worktree&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The project folder&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt; file, if the project folder is itself a linked worktree. The repo it points to is outside the VM.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 data-hextra-search-id="when-devvm-locks"&gt;When devvm locks&lt;span class="hx:absolute hx:-mt-20" id="when-devvm-locks"&gt;&lt;/span&gt;
&lt;a href="#when-devvm-locks" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;devvm records a new VM&amp;rsquo;s mode in its state before its backend makes the VM, so the mode is never unset: on with locks (macOS, and Linux where the kernel lets devvm use a user namespace), off when you pass &lt;code&gt;--no-git-protect&lt;/code&gt; or on hosts without locks, and &lt;code&gt;clone&lt;/code&gt; for a &lt;code&gt;--clone&lt;/code&gt; VM, which mounts no &lt;code&gt;.git&lt;/code&gt;. devvm locks once the backend has made the VM, and again on each launch that finds the VM stopped and on &lt;code&gt;devvm stop&lt;/code&gt;, so nothing in the VM can race the locks. A VM whose creation stopped before its first locks, or that &lt;code&gt;devvm adopt&lt;/code&gt; moved to this folder, is locked on its next launch as a new VM is, without reports. A running VM keeps the locks it had, and &lt;code&gt;devvm stop&lt;/code&gt; or the next launch that finds the VM stopped, such as &lt;code&gt;devvm restart&lt;/code&gt;, sets new ones. &lt;code&gt;devvm git-protect&lt;/code&gt; on a running VM saves the mode in the VM&amp;rsquo;s state (the &lt;code&gt;git&lt;/code&gt; section&amp;rsquo;s &lt;code&gt;next&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Each time it locks, devvm records in the VM&amp;rsquo;s state what it locked and found: the identity of &lt;code&gt;.git&lt;/code&gt; (its device and inode, and its birth time where the file system keeps one), every git folder it locked besides &lt;code&gt;.git&lt;/code&gt; (those under &lt;code&gt;.git/modules&lt;/code&gt; and the submodules&amp;rsquo; in the working tree, in one list), and a hash of what the locked files hand over to the project folder. The next check compares with those, so it reports what changed since. When only the device of &lt;code&gt;.git&lt;/code&gt; differs, and it&amp;rsquo;s at the same path with no link on it and has the same inode and birth time, it&amp;rsquo;s the &lt;code&gt;.git&lt;/code&gt; that devvm locked, on a disk that macOS numbered anew at boot, as for &lt;a href="https://next.devvm.dev/docs/internals/security/#one-vm-per-folder"&gt;one VM per folder&lt;/a&gt;. The check then records its identity as it is now and doesn&amp;rsquo;t report a replaced &lt;code&gt;.git&lt;/code&gt;. The same places first check &lt;code&gt;.git&lt;/code&gt; under the mode the VM ran with, so a &lt;code&gt;.git&lt;/code&gt; that the VM replaced meanwhile is still named (&lt;code&gt;git_replaced&lt;/code&gt;), and then set the new mode, which locks &lt;code&gt;.git&lt;/code&gt; as it is then.&lt;/p&gt;
&lt;p&gt;A new VM that&amp;rsquo;s interrupted before its first shell is deleted, and devvm takes its locks off. When &lt;code&gt;devvm rm&lt;/code&gt; deletes a VM, devvm also takes its locks off. It unlocks what it would lock now and every git folder the VM&amp;rsquo;s state records locking, so a submodule whose entry the VM dropped from the index since is unlocked too.&lt;/p&gt;
&lt;h3 data-hextra-search-id="symlinks"&gt;Symlinks&lt;span class="hx:absolute hx:-mt-20" id="symlinks"&gt;&lt;/span&gt;
&lt;a href="#symlinks" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;devvm never locks or creates anything through a symlink, because the VM could plant one under &lt;code&gt;.git&lt;/code&gt; so that devvm would lock a file elsewhere. devvm reports a path that is a symlink, or is under one, instead of locking it (&lt;code&gt;git_not_locked&lt;/code&gt;). devvm also checks each lock again once it&amp;rsquo;s set. If the path moved in the meantime, devvm unlocks it where it landed and reports it (&lt;code&gt;git_lock_raced&lt;/code&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="on-each-launch"&gt;On each launch&lt;span class="hx:absolute hx:-mt-20" id="on-each-launch"&gt;&lt;/span&gt;
&lt;a href="#on-each-launch" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Every launch of an existing VM, every export of its agents&amp;rsquo; history, and &lt;code&gt;devvm stop&lt;/code&gt; check &lt;code&gt;.git&lt;/code&gt; again. devvm reports each of these once:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;.git&lt;/code&gt; that was replaced since devvm locked it (&lt;code&gt;git_replaced&lt;/code&gt;). devvm then does nothing else, so check the new &lt;code&gt;.git&lt;/code&gt;, and look for the old one, renamed.&lt;/li&gt;
&lt;li&gt;A repo that appeared in the folder after the VM was made (&lt;code&gt;git_appeared&lt;/code&gt;), which devvm then locks, and a nested repo that appeared since the last check (&lt;code&gt;git_nested_appeared&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;A nested repo devvm protected that&amp;rsquo;s gone (&lt;code&gt;git_nested_gone&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;A submodule git folder that appeared, in the working tree or under &lt;code&gt;.git/modules&lt;/code&gt; (&lt;code&gt;git_embedded_new&lt;/code&gt;), which devvm then locks. devvm compares with the git folders it recorded last time, so &lt;code&gt;devvm git-protect on&lt;/code&gt; after a VM was made without protection names none: it locks &lt;code&gt;.git&lt;/code&gt; as it is then, as trusted.&lt;/li&gt;
&lt;li&gt;Hooks in a hooks folder that wasn&amp;rsquo;t locked, because it wasn&amp;rsquo;t there to lock or belongs to a new submodule (&lt;code&gt;git_hooks_unlocked&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;devvm also reports these, the first two on every launch and the last two when they change:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;commondir&lt;/code&gt; (&lt;code&gt;git_commondir&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Linked worktrees whose &lt;code&gt;commondir&lt;/code&gt; leads elsewhere (&lt;code&gt;git_worktree_stray&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Includes and hook links into the project folder (&lt;code&gt;git_include_inside&lt;/code&gt;, &lt;code&gt;git_hook_link_inside&lt;/code&gt;), which &lt;a href="https://next.devvm.dev/docs/safety/git-protection/#not-covered"&gt;not covered&lt;/a&gt; describes.&lt;/li&gt;
&lt;li&gt;Submodules whose git folder, in the working tree, isn&amp;rsquo;t a git folder (&lt;code&gt;git_gitdir_not_git&lt;/code&gt;), which devvm doesn&amp;rsquo;t lock.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="nested-repos"&gt;Nested repos&lt;span class="hx:absolute hx:-mt-20" id="nested-repos"&gt;&lt;/span&gt;
&lt;a href="#nested-repos" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm protects each git repo nested in the project folder as it protects the folder&amp;rsquo;s own: it locks the same paths of each, checks each at every launch, pins each on Linux and watches each where the host can&amp;rsquo;t lock (&lt;a href="https://next.devvm.dev/docs/safety/git-protection/#nested-repos"&gt;nested repos&lt;/a&gt;).&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-walk"&gt;The walk&lt;span class="hx:absolute hx:-mt-20" id="the-walk"&gt;&lt;/span&gt;
&lt;a href="#the-walk" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;devvm finds the nested repos by walking the project folder when it creates the VM, at each launch that finds the VM stopped and at &lt;code&gt;devvm stop&lt;/code&gt;, at &lt;code&gt;devvm git-protect&lt;/code&gt; on a stopped VM, and when &lt;code&gt;devvm clone off&lt;/code&gt; mounts the folder again. It&amp;rsquo;s one walk that also finds the set-id files on a Linux host, which only the start runs (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-checks-on-owners"&gt;the checks on owners&lt;/a&gt;), and a launch into a running VM never walks. The walk stays on the project folder&amp;rsquo;s file system, follows no symlink and never enters a &lt;code&gt;.git&lt;/code&gt; folder, so it never finds the repos of &lt;code&gt;.git/modules&lt;/code&gt;, which are the folder&amp;rsquo;s own repo&amp;rsquo;s to protect. It takes a folder for a repo when the folder has anything named &lt;code&gt;.git&lt;/code&gt;, a folder, a file, which a linked worktree or a repo with its git folder elsewhere has, a symlink or anything else, whether git takes it for a repo&amp;rsquo;s now or not, because the VM can make it one at any time. On macOS, whose file systems fold case, &lt;code&gt;.GIT&lt;/code&gt; is &lt;code&gt;.git&lt;/code&gt; to git, so the walk takes any case of the name there. It looks for repos at most four folders below the project folder, and not in &lt;code&gt;node_modules&lt;/code&gt;, &lt;code&gt;vendor&lt;/code&gt;, &lt;code&gt;.venv&lt;/code&gt;, &lt;code&gt;__pycache__&lt;/code&gt; or &lt;code&gt;.terraform&lt;/code&gt;, which package managers and build tools fill with what they fetch, so on macOS, where there are no set-id files to look for, the walk doesn&amp;rsquo;t enter those folders at all. On Linux it walks them for set-id files anyway, and counts the &lt;code&gt;.git&lt;/code&gt; it sees there and below four folders (&lt;code&gt;git_nested_skipped&lt;/code&gt;). It counts the folders it doesn&amp;rsquo;t enter because they&amp;rsquo;re on another file system (&lt;code&gt;git_nested_devices&lt;/code&gt;). It keeps the first 100 repos it finds, in the walk&amp;rsquo;s order, and counts the rest, keeping the names of the first ten of those (&lt;code&gt;git_nested_past_bound&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;The walk also names each folder up to four folders down that git could take for a bare repo (&lt;code&gt;git_nested_bare&lt;/code&gt;), one shaped like a git folder by git&amp;rsquo;s own test: a &lt;code&gt;HEAD&lt;/code&gt;, and &lt;code&gt;objects&lt;/code&gt; and &lt;code&gt;refs&lt;/code&gt;, files or folders, in the folder or in the folder its &lt;code&gt;commondir&lt;/code&gt; names. A git folder that a repo&amp;rsquo;s scan locks, or that a nested repo&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt; file names, isn&amp;rsquo;t named. &lt;code&gt;devvm doctor&lt;/code&gt; reads &lt;code&gt;safe.bareRepository&lt;/code&gt; from git&amp;rsquo;s global and system config, the files that &lt;code&gt;GIT_CONFIG_GLOBAL&lt;/code&gt; and &lt;code&gt;GIT_CONFIG_SYSTEM&lt;/code&gt; name included, which it reads by name because devvm&amp;rsquo;s host git ignores every &lt;code&gt;GIT_*&lt;/code&gt; variable, and it gives a tip unless the setting is &lt;code&gt;explicit&lt;/code&gt; (&lt;code&gt;doctor_git_bare&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;A check takes the repos the walk found, the ones the VM&amp;rsquo;s state records first. A recorded repo stays protected, whether the walk found it or not, while its folder is a real folder of the project with anything at its &lt;code&gt;.git&lt;/code&gt;, because the VM can make a &lt;code&gt;.git&lt;/code&gt; that the walk or git&amp;rsquo;s own test passes over while git still takes it: objects and refs renamed with a &lt;code&gt;commondir&lt;/code&gt; that leads to a git folder of its own, a &lt;code&gt;.GIT&lt;/code&gt;, or a &lt;code&gt;.git&lt;/code&gt; it can&amp;rsquo;t read, which devvm can&amp;rsquo;t lock and names (&lt;code&gt;git_not_locked&lt;/code&gt;). A check without a walk, such as &lt;code&gt;devvm rm&lt;/code&gt; and the start that pins, takes the repos the state records. A launch into a running VM checks the folder&amp;rsquo;s own repo alone and keeps the nested repos&amp;rsquo; records as they are, because it locks nothing and the VM can change them until it stops, so it never pays for scanning them, and the check of a running VM&amp;rsquo;s pins goes by those records without scanning them. devvm scans each repo as it scans the folder&amp;rsquo;s own, eight at once, because each scan runs a few host git commands: a check of a stopped VM with 50 nested repos, the walk and the locks included, takes under a second on an M3 Max.&lt;/p&gt;
&lt;h3 data-hextra-search-id="two-bounds"&gt;Two bounds&lt;span class="hx:absolute hx:-mt-20" id="two-bounds"&gt;&lt;/span&gt;
&lt;a href="#two-bounds" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Each repo has two bounds. Its own top folder is where its &lt;code&gt;.git&lt;/code&gt; is, where &lt;code&gt;.git/modules&lt;/code&gt; and a relative &lt;code&gt;core.hooksPath&lt;/code&gt; are read from, and where its submodules&amp;rsquo; folders are. The project folder, which the VM mounts, is what the VM can write, so it&amp;rsquo;s the bound for everything else: devvm locks only a real path in the project folder, through no symlink, an include or a hooks path leads inside when it leads into the project folder, and a submodule&amp;rsquo;s git folder outside the project folder is one devvm can&amp;rsquo;t lock (&lt;code&gt;git_gitdir_outside&lt;/code&gt;). A nested repo&amp;rsquo;s hooks path that leads into a sibling repo is inside, because the VM can write it.&lt;/p&gt;
&lt;p&gt;A nested repo is left to another repo only when that repo&amp;rsquo;s scan locks its git folder whole: the git folder is that repo&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt;, one under its &lt;code&gt;.git/modules&lt;/code&gt; that reads its config from itself, with no &lt;code&gt;commondir&lt;/code&gt; that leads elsewhere, or one of its linked worktrees under &lt;code&gt;.git/worktrees&lt;/code&gt; whose &lt;code&gt;commondir&lt;/code&gt; leads back. Anything else below a &lt;code&gt;.git&lt;/code&gt;, such as a &lt;code&gt;.git/evil&lt;/code&gt; the VM made for a &lt;code&gt;src/.git&lt;/code&gt; file to name, isn&amp;rsquo;t locked by anything, so the repo is scanned on its own, and named as one that appeared and as one devvm doesn&amp;rsquo;t protect. A submodule in the working tree is scanned as a repo of its own as well as its parent&amp;rsquo;s submodule, because the index that names it is the VM&amp;rsquo;s to write: a gitlink the VM adds, whose &lt;code&gt;.git&lt;/code&gt; file names a nested repo&amp;rsquo;s git folder, would otherwise hide that repo&amp;rsquo;s own submodules and worktrees behind a scan from the wrong folder. Locking a path twice changes nothing, and unlocking goes by path once. A nested repo whose &lt;code&gt;.git&lt;/code&gt; is a file is locked as the folder&amp;rsquo;s own is when it&amp;rsquo;s a linked worktree, by its &lt;code&gt;.git&lt;/code&gt; file. When the git folder that file names is in the project folder and no repo&amp;rsquo;s scan locks it, devvm names the repo as one it doesn&amp;rsquo;t protect, and when it&amp;rsquo;s outside the project folder, it names the repo as one whose git folder it can&amp;rsquo;t lock (&lt;code&gt;git_nested_gitdir_outside&lt;/code&gt;), as it does a submodule&amp;rsquo;s.&lt;/p&gt;
&lt;p&gt;A scan follows each submodule git folder once, by its resolved path, and one check&amp;rsquo;s scans follow at most 1,000 of them across every repo, so gitlinks that the VM points back at a git folder already followed, or through a symlinked folder at the repo itself, or many repos full of submodules, can&amp;rsquo;t make a check run git without end. A repo whose scan stopped there is named at every check (&lt;code&gt;git_scan_bounded&lt;/code&gt;).&lt;/p&gt;
&lt;h3 data-hextra-search-id="whats-recorded"&gt;What&amp;rsquo;s recorded&lt;span class="hx:absolute hx:-mt-20" id="whats-recorded"&gt;&lt;/span&gt;
&lt;a href="#whats-recorded" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The VM&amp;rsquo;s state records each protected nested repo in the &lt;code&gt;git&lt;/code&gt; section&amp;rsquo;s &lt;code&gt;made.repos&lt;/code&gt;, by its folder relative to the project folder, with the same fields as the folder&amp;rsquo;s own repo: &lt;code&gt;.git&lt;/code&gt;&amp;rsquo;s identity, the git folders locked besides &lt;code&gt;.git&lt;/code&gt;, and a hash of what its locked files hand over. &lt;code&gt;made.nested&lt;/code&gt; is set once the VM protects its nested repos, which a new VM does, and so do &lt;code&gt;devvm git-protect on&lt;/code&gt; and the watch on a Linux host that can&amp;rsquo;t lock. A nested repo without a record is scanned for the first time, which records it as a new VM&amp;rsquo;s repo is recorded, without reporting its git folders. At a check of a VM whose &lt;code&gt;made.nested&lt;/code&gt; is set, devvm also reports it as one that appeared, such as a repo the VM cloned while it ran, naming each key of its config that runs a program or reads another config (&lt;code&gt;core.fsmonitor&lt;/code&gt;, &lt;code&gt;core.hooksPath&lt;/code&gt;, &lt;code&gt;core.sshCommand&lt;/code&gt;, &lt;code&gt;core.pager&lt;/code&gt;, filters, aliases that start with &lt;code&gt;!&lt;/code&gt;, includes and the like) and each hook that isn&amp;rsquo;t one of git&amp;rsquo;s samples (&lt;code&gt;git_nested_appeared_runs&lt;/code&gt;, else &lt;code&gt;git_nested_appeared&lt;/code&gt;), because it locks the repo as it is. A recorded repo with nothing at its &lt;code&gt;.git&lt;/code&gt;, or whose folder isn&amp;rsquo;t a real folder of the project any more, is reported (&lt;code&gt;git_nested_gone&lt;/code&gt;), and a recorded repo whose &lt;code&gt;.git&lt;/code&gt; is another one is reported as the folder&amp;rsquo;s own is (&lt;code&gt;git_replaced&lt;/code&gt;). The record of a repo devvm stops protecting, as it&amp;rsquo;s gone or another repo&amp;rsquo;s protection covers it, moves to &lt;code&gt;made.left&lt;/code&gt;, so &lt;code&gt;devvm rm&lt;/code&gt; and &lt;code&gt;devvm git-protect off&lt;/code&gt; take its locks off with the rest, and name one that isn&amp;rsquo;t in the folder any more (&lt;code&gt;git_locks_left&lt;/code&gt;), whose locks only &lt;code&gt;chflags&lt;/code&gt; can take off.&lt;/p&gt;
&lt;p&gt;A VM an earlier devvm made has no &lt;code&gt;made.nested&lt;/code&gt;, so it protects only the folder&amp;rsquo;s own repo. The first check of it that finds nested repos names them once (&lt;code&gt;git_nested_protectable&lt;/code&gt;, recorded as &lt;code&gt;nested_noticed&lt;/code&gt;), and &lt;code&gt;devvm git-protect on&lt;/code&gt; protects them. The nested repos that a check finds and the protection doesn&amp;rsquo;t cover are recorded in &lt;code&gt;nested&lt;/code&gt;, with &lt;code&gt;nested_more&lt;/code&gt; for how many more the walk counted, and named (&lt;code&gt;git_nested_unprotected&lt;/code&gt;, &lt;code&gt;git_nested_past_bound&lt;/code&gt;): on a host that locks, all of them when devvm creates the VM and at &lt;code&gt;devvm git-protect on&lt;/code&gt;, and at a check of a stopped VM those it hadn&amp;rsquo;t recorded, and how many are past the bound at every check, because the VM could keep their count and change which they are. On a Linux host that can&amp;rsquo;t lock, each launch names those the last walk recorded, after &lt;code&gt;git_unprotected&lt;/code&gt;, which a folder without a &lt;code&gt;.git&lt;/code&gt; of its own gets too when it has nested repos, and &lt;code&gt;devvm git-protect off&lt;/code&gt; quiets both.&lt;/p&gt;
&lt;p&gt;A VM that devvm 0.1.0 or 0.1.1-rc.1 made strict has &lt;code&gt;strict&lt;/code&gt; as its &lt;code&gt;mode&lt;/code&gt;, and its repos&amp;rsquo; configs have the &lt;code&gt;diff.ignoreSubmodules = all&lt;/code&gt; that strict set. devvm reads that mode as &lt;code&gt;on&lt;/code&gt;: it locks, pins and keeps the VM&amp;rsquo;s paths as it does for &lt;code&gt;on&lt;/code&gt;, and &lt;code&gt;devvm git-protect&lt;/code&gt;, its &lt;code&gt;--json&lt;/code&gt; and &lt;code&gt;devvm ls&lt;/code&gt; show &lt;code&gt;on&lt;/code&gt;. The first check that finds the VM stopped, at a launch, &lt;code&gt;devvm stop&lt;/code&gt;, &lt;code&gt;devvm clone on&lt;/code&gt; or the undo of a &lt;code&gt;devvm clone off&lt;/code&gt;, runs as an &lt;code&gt;on&lt;/code&gt; VM&amp;rsquo;s does, and then converts the VM. Under the host&amp;rsquo;s lock of &lt;code&gt;.git&lt;/code&gt; protection, it takes the value &lt;code&gt;all&lt;/code&gt; out of the &lt;code&gt;.git/config&lt;/code&gt; of each repo that the VM&amp;rsquo;s state recorded protecting before that check, the folder&amp;rsquo;s own and the nested ones, with &lt;code&gt;git config --unset-all diff.ignoreSubmodules '^all$'&lt;/code&gt;, and leaves any other value. It acts only on a repo whose &lt;code&gt;.git&lt;/code&gt; has the identity the state recorded (&lt;code&gt;git_id&lt;/code&gt;), so a &lt;code&gt;.git&lt;/code&gt; the VM replaced, which the check names and locks nothing in, and a VM with no record, as after &lt;code&gt;devvm adopt&lt;/code&gt;, keep their setting, which devvm names once when it&amp;rsquo;s &lt;code&gt;all&lt;/code&gt; (&lt;code&gt;git_strict_unknown&lt;/code&gt;). It reads the config through devvm&amp;rsquo;s reader of files a VM can write first, so a FIFO or a symlink there is never read, and after git writes it, it checks that the config is still a regular file in that &lt;code&gt;.git&lt;/code&gt;, else it names the path (&lt;code&gt;git_lock_raced&lt;/code&gt;). On a host that watches as well as locks, it leaves a config whose sum isn&amp;rsquo;t the one the check just recorded, and puts the new sum of each config it changed into the watch&amp;rsquo;s, so the next check doesn&amp;rsquo;t name devvm&amp;rsquo;s own change. It locks each config again even after an interrupt, on a context the interrupt doesn&amp;rsquo;t cancel, and an interrupt records nothing, so the next check goes again. Then it records &lt;code&gt;on&lt;/code&gt; in &lt;code&gt;mode&lt;/code&gt;, and in &lt;code&gt;next&lt;/code&gt; when an earlier devvm saved &lt;code&gt;strict&lt;/code&gt; there for the VM&amp;rsquo;s next stop, and warns once (&lt;code&gt;git_strict_converted&lt;/code&gt;), unless &lt;code&gt;next&lt;/code&gt; is &lt;code&gt;off&lt;/code&gt;. A config that git can&amp;rsquo;t change keeps the setting, and devvm names it (&lt;code&gt;git_strict_left&lt;/code&gt;). &lt;code&gt;devvm git-protect on&lt;/code&gt; and &lt;code&gt;off&lt;/code&gt; and the unlock at &lt;code&gt;devvm rm&lt;/code&gt; take the setting out the same way, without the warning (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt; names the code).&lt;/p&gt;
&lt;h3 data-hextra-search-id="two-vms-one-repo"&gt;Two VMs, one repo&lt;span class="hx:absolute hx:-mt-20" id="two-vms-one-repo"&gt;&lt;/span&gt;
&lt;a href="#two-vms-one-repo" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A nested repo with a VM of its own is protected by two VMs, the parent folder&amp;rsquo;s and its own. On macOS both set the same flag on the same files, so when one VM&amp;rsquo;s protection comes off, at &lt;code&gt;devvm rm&lt;/code&gt; or &lt;code&gt;devvm git-protect off&lt;/code&gt;, devvm leaves locked every path that another VM&amp;rsquo;s protection still covers, which is a git folder that VM recorded locking, of its own repo or of a nested one, and names that VM (&lt;code&gt;git_kept_locked&lt;/code&gt;). The inventory reads every VM&amp;rsquo;s state for that. It fails closed: a state it can&amp;rsquo;t read keeps locked every path in the folder whose hash names that state&amp;rsquo;s folder, and when it can&amp;rsquo;t read the VMs&amp;rsquo; folder at all, everything stays locked, each named with the state to fix (&lt;code&gt;git_kept_unread&lt;/code&gt;). Locking a VM&amp;rsquo;s repos and recording them, and unlocking another&amp;rsquo;s, take the host&amp;rsquo;s lock of &lt;code&gt;.git&lt;/code&gt; protection first, before any VM&amp;rsquo;s own lock, so one VM&amp;rsquo;s unlock never runs between another&amp;rsquo;s locks and their record. Taking a strict VM&amp;rsquo;s &lt;code&gt;diff.ignoreSubmodules&lt;/code&gt; out never unlocks a config another VM keeps locked, because that VM, running, could race the unlocked file, so the setting stays there, and devvm names the file, that VM and how to take it out by hand (&lt;code&gt;git_strict_kept&lt;/code&gt;). The repo goes in the state&amp;rsquo;s &lt;code&gt;strict_left&lt;/code&gt;, as does one whose config changed since the check, and each later check that finds the VM stopped tries again, until none is left. When git can&amp;rsquo;t change a config, devvm locks it again all the same. On Linux each VM&amp;rsquo;s pins are in its own QEMU&amp;rsquo;s namespace, and the watch locks nothing, so neither needs this.&lt;/p&gt;
&lt;h2 data-hextra-search-id="on-linux-hosts"&gt;On Linux hosts&lt;span class="hx:absolute hx:-mt-20" id="on-linux-hosts"&gt;&lt;/span&gt;
&lt;a href="#on-linux-hosts" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Linux hosts have no immutable flag that a user can set, so devvm makes what it locks read-only where the VM sees it, in the VM&amp;rsquo;s QEMU process, which serves the project folder to the guest over 9p. Lima starts QEMU through devvm&amp;rsquo;s wrapper (&lt;code&gt;devvm _qemu exec&lt;/code&gt;), and a start of a VM that&amp;rsquo;s on gives the wrapper what to pin in a file of its own, &lt;code&gt;run/git-pins.json&lt;/code&gt; in the VM&amp;rsquo;s folder, written private, which &lt;code&gt;DEVVM_QEMU_PINS&lt;/code&gt; names, because a VM with many nested repos has more pins than one environment variable holds. The wrapper reads the file through no symlink, and it pins, for the folder&amp;rsquo;s own repo and each nested repo the VM&amp;rsquo;s state records protecting, &lt;code&gt;.git&lt;/code&gt; and each git folder it locks besides, which stay writable, and every path of &lt;a href="#whats-locked"&gt;what&amp;rsquo;s locked&lt;/a&gt; that&amp;rsquo;s there, which become read-only. They&amp;rsquo;re the paths the check before the start found and checked, each a real path in the project folder with no symlink, and the check made a missing hooks folder and &lt;code&gt;config.worktree&lt;/code&gt; first, so each has a place to pin. devvm then starts &lt;code&gt;devvm _qemu pinned&lt;/code&gt; in a user and mount namespace of its own, as you, with only &lt;code&gt;CAP_SYS_ADMIN&lt;/code&gt;, and only in that namespace. It makes the namespace&amp;rsquo;s mounts private, so nothing it mounts reaches this machine&amp;rsquo;s, and pins each path in order, a folder before what&amp;rsquo;s under it. It opens each path once, by the kernel, below the project folder and through no symlink (&lt;code&gt;openat2&lt;/code&gt; with &lt;code&gt;RESOLVE_BENEATH&lt;/code&gt; and &lt;code&gt;RESOLVE_NO_SYMLINKS&lt;/code&gt;), refuses anything but a file or a folder, and refuses a file with another name, or a folder holding a regular file with one, because a bind covers one name and macOS&amp;rsquo;s flag covers the file itself (&lt;code&gt;git_pin_linked&lt;/code&gt;, which the check before the start names first). Then it binds what it opened over itself with &lt;code&gt;open_tree&lt;/code&gt;, &lt;code&gt;mount_setattr&lt;/code&gt; and &lt;code&gt;move_mount&lt;/code&gt;, which act on that file descriptor and never on a path again, because &lt;code&gt;mount(2)&lt;/code&gt; would follow a symlink that the VM planted. A path it can&amp;rsquo;t pin, or folders it can&amp;rsquo;t watch, stop the start (&lt;code&gt;qemu_pins_failed&lt;/code&gt;), so the VM never runs unlocked. Then it starts &lt;code&gt;devvm _qemu drop&lt;/code&gt; as its child, which clears every capability it has, ambient, permitted, effective and inheritable, sets no-new-privileges and replaces itself with QEMU, which runs as you with no capability at all. Its bounding set stays whole, which only &lt;code&gt;CAP_SETPCAP&lt;/code&gt; could change, and gives nothing with no new privileges. QEMU is killed if &lt;code&gt;devvm _qemu pinned&lt;/code&gt; ends (&lt;code&gt;PR_SET_PDEATHSIG&lt;/code&gt;), which runs as long as QEMU does, keeping the pins, so QEMU never outlives what keeps them. &lt;code&gt;devvm _qemu exec&lt;/code&gt; waits for both and passes them the signals Lima sends, and if it&amp;rsquo;s killed, QEMU is killed with it, an unclean stop for the guest, as if its power went.&lt;/p&gt;
&lt;p&gt;The guest reaches the project folder only through QEMU, so a write to a pinned path gets &lt;code&gt;EROFS&lt;/code&gt;, and a rename or a removal of one, &lt;code&gt;.git&lt;/code&gt; itself included, gets &lt;code&gt;EBUSY&lt;/code&gt;, because it&amp;rsquo;s a mount point. A mount can&amp;rsquo;t be undone from the guest, and QEMU, which has no capability, can&amp;rsquo;t undo it either. A bind mount over a folder is a file system of its own to the guest, so a rename between the working tree and &lt;code&gt;.git&lt;/code&gt; gets &lt;code&gt;EXDEV&lt;/code&gt;. The namespace ends with QEMU, so nothing persists once the VM stops, and nothing changes on this machine&amp;rsquo;s side, where git works as usual.&lt;/p&gt;
&lt;p&gt;A git command on this machine that writes &lt;code&gt;.git/config&lt;/code&gt; writes a new file and renames it over the old one, and the new file isn&amp;rsquo;t pinned in the namespace. &lt;code&gt;devvm _qemu pinned&lt;/code&gt; watches each pinned path&amp;rsquo;s folder with inotify, a few folders for each repo, so the 100 nested repos devvm protects at most stay far below the kernel&amp;rsquo;s limit of watches, and it pins again whatever lost its pin as soon as one changes, and every two seconds besides. A pin can race the rename, because the kernel takes the old file&amp;rsquo;s mount away before the new file has its name, so the pin may open the old file and find it gone by the time it binds (&lt;code&gt;move_mount&lt;/code&gt;&amp;rsquo;s &lt;code&gt;ENOENT&lt;/code&gt;). &lt;code&gt;devvm _qemu pinned&lt;/code&gt; then opens the path again and pins what the rename left, up to 50 times, so on a busy host it never mistakes a rename for a lost pin. Until then the guest can write the new file, rename it away and put its own in its place, which then gets the pin, open it for writing, a handle the pin doesn&amp;rsquo;t take back, or give it another name. So each pin it makes again, and each it can&amp;rsquo;t, it records in the VM&amp;rsquo;s run folder (&lt;code&gt;run/git-pins.jsonl&lt;/code&gt;), a JSON object a line, after a first line that says it keeps the pins from then on, which it writes before QEMU starts and without which QEMU doesn&amp;rsquo;t start (&lt;code&gt;qemu_pins_failed&lt;/code&gt;). The next check of the stopped VM, at &lt;code&gt;devvm stop&lt;/code&gt; or at the next launch, names them before anything else, one line for each path and kind however often it happened (&lt;code&gt;git_pin_again&lt;/code&gt;, &lt;code&gt;git_pin_linked_run&lt;/code&gt;, &lt;code&gt;git_pin_lost&lt;/code&gt;), then removes the file. An event &lt;code&gt;devvm _qemu pinned&lt;/code&gt; can&amp;rsquo;t add goes to Lima&amp;rsquo;s log, with a warning, and to the file as a mark if it still takes one. A record the check can&amp;rsquo;t trust is named (&lt;code&gt;git_pins_unrecorded&lt;/code&gt;): one it can&amp;rsquo;t read, which it keeps, a line that isn&amp;rsquo;t an event, a mark, or a file that doesn&amp;rsquo;t start with a run&amp;rsquo;s first line, as when it was removed while the VM ran and made again. The check also sums what a lock covers, as the &lt;a href="#the-watch"&gt;watch&lt;/a&gt; does, and names what changed since the VM&amp;rsquo;s last check, so a file the guest changed in that window, or through a handle it kept, is named too. macOS&amp;rsquo;s flag has no window, because a locked config can&amp;rsquo;t be replaced on the host either.&lt;/p&gt;
&lt;p&gt;Each launch of a running VM that&amp;rsquo;s on, and &lt;code&gt;devvm stop&lt;/code&gt; before it stops it, read QEMU&amp;rsquo;s mounts (&lt;code&gt;/proc/&amp;lt;pid&amp;gt;/mountinfo&lt;/code&gt;, QEMU&amp;rsquo;s pid from Lima&amp;rsquo;s &lt;code&gt;qemu.pid&lt;/code&gt;) and name what of &lt;code&gt;.git&lt;/code&gt; and of the git folders it locked QEMU lacks (&lt;code&gt;git_pins_missing&lt;/code&gt;): &lt;code&gt;.git&lt;/code&gt; and each git folder that isn&amp;rsquo;t a mount point of its own, and each read-only path that QEMU doesn&amp;rsquo;t see read-only,, such as all of them for a VM that &lt;code&gt;limactl start&lt;/code&gt; started. A VM that&amp;rsquo;s on whose &lt;code&gt;.git&lt;/code&gt; has nothing devvm can pin, such as one whose &lt;code&gt;.git&lt;/code&gt; is a symlink, is named at its start (&lt;code&gt;git_pins_none&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;devvm checks that the host can pin by doing it: it pins a file in a namespace of its own, with its own binary, and checks that writing it fails (&lt;code&gt;devvm _qemu probe&lt;/code&gt;). Lima&amp;rsquo;s &lt;code&gt;read-only-paths&lt;/code&gt; feature is native where that works and none elsewhere, and a VM that&amp;rsquo;s on needs it to start, so where the kernel stops letting devvm in, the start is refused (&lt;code&gt;backend_lacks&lt;/code&gt;) and never goes on unlocked. Where the probe fails, new VMs get &lt;code&gt;off&lt;/code&gt;, devvm watches &lt;code&gt;.git&lt;/code&gt; instead, and &lt;code&gt;devvm doctor&lt;/code&gt; says why: Ubuntu&amp;rsquo;s &lt;code&gt;kernel.apparmor_restrict_unprivileged_userns&lt;/code&gt;, &lt;code&gt;kernel.unprivileged_userns_clone&lt;/code&gt; or &lt;code&gt;user.max_user_namespaces&lt;/code&gt; at 0, or the probe&amp;rsquo;s own error. devvm offers no AppArmor profile for Ubuntu, because a profile for a binary in a folder you can write gives any program running as you what Ubuntu&amp;rsquo;s restriction holds back (&lt;a href="https://next.devvm.dev/docs/safety/git-protection/#ubuntu"&gt;Ubuntu&lt;/a&gt;). devvm makes the namespace itself rather than through &lt;code&gt;unshare(1)&lt;/code&gt;, so the program that asks for it is devvm.&lt;/p&gt;
&lt;p&gt;devvm doesn&amp;rsquo;t pin &lt;code&gt;.git/commondir&lt;/code&gt; against the VM making one, which would point git on this machine at another config: a file has to be there to be pinned, and devvm puts no file in &lt;code&gt;.git&lt;/code&gt; that git doesn&amp;rsquo;t, so it reports a &lt;code&gt;commondir&lt;/code&gt; at each check, as on macOS.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-watch"&gt;The watch&lt;span class="hx:absolute hx:-mt-20" id="the-watch"&gt;&lt;/span&gt;
&lt;a href="#the-watch" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Where the host can&amp;rsquo;t pin, devvm locks nothing, and every VM that mounts its folder gets &lt;code&gt;off&lt;/code&gt; as its mode. devvm watches the paths it would lock instead, and names what changed after the fact (&lt;code&gt;git_changed&lt;/code&gt;), which &lt;a href="https://next.devvm.dev/docs/safety/git-protection/#when-devvm-names-a-change"&gt;Linux hosts&lt;/a&gt; tells the user how to check.&lt;/p&gt;
&lt;p&gt;devvm hashes the same paths that &lt;a href="#whats-locked"&gt;what&amp;rsquo;s locked&lt;/a&gt; lists, found in the same way, and &lt;code&gt;.git/commondir&lt;/code&gt;, there or not, the files that &lt;code&gt;include.path&lt;/code&gt; and &lt;code&gt;includeIf.*.path&lt;/code&gt; lead to in the project folder, and the folder that &lt;code&gt;core.hooksPath&lt;/code&gt; names in it. For a hooks folder, it hashes each entry below it, except git&amp;rsquo;s &lt;code&gt;.sample&lt;/code&gt; files, which git never runs, starting with the entries at its top that have a hook&amp;rsquo;s name (githooks(5)), which git runs, and then the rest. It hashes a regular file&amp;rsquo;s contents with SHA-256, opened with &lt;code&gt;O_NOFOLLOW&lt;/code&gt; and &lt;code&gt;O_NONBLOCK&lt;/code&gt; and checked to be a regular file once it&amp;rsquo;s open, as devvm reads every file a VM can write. It records a symlink by where it points, and a path under a symlink, such as &lt;code&gt;.git/config&lt;/code&gt; when &lt;code&gt;.git&lt;/code&gt; is a symlink, by that fact. When the link resolves to a file or folder inside the project folder, it adds that file&amp;rsquo;s hash, or a hash of that folder&amp;rsquo;s hashes, and it never follows a link out of the project folder. Anything else, such as a FIFO, is recorded by its type. The work is bounded: past 1,000 entries, a hooks folder is recorded by that count, its inode and its change time, a file larger than 16 MiB by its size, inode and change time, and a watch keeps at most 2,000 hashes of the folder&amp;rsquo;s own repo and 200 of each nested repo, so a folder with many nested repos never overflows it. The VM can&amp;rsquo;t set a change time back over 9p, so a change that keeps a large file&amp;rsquo;s size is still named. Each check names, in its own warning (&lt;code&gt;git_watch_blind&lt;/code&gt;), every path that is a symlink or under one, past a bound, or past the 2,000, because the watch can&amp;rsquo;t see every change there.&lt;/p&gt;
&lt;p&gt;The same checks first run what a lock&amp;rsquo;s check reports, without locking (&lt;code&gt;protect&lt;/code&gt; with &lt;code&gt;watching&lt;/code&gt;): a &lt;code&gt;.git&lt;/code&gt; replaced since the last check (&lt;code&gt;git_replaced&lt;/code&gt;), after which the next check compares with the new one, a &lt;code&gt;commondir&lt;/code&gt; (&lt;code&gt;git_commondir&lt;/code&gt;), linked worktrees whose &lt;code&gt;commondir&lt;/code&gt; leads elsewhere, a repo or submodule git folder that appeared, a submodule&amp;rsquo;s folder that isn&amp;rsquo;t a git folder (&lt;code&gt;git_gitdir_not_git&lt;/code&gt;), which the watch doesn&amp;rsquo;t hash as one and where devvm creates nothing, and includes, hook links and &lt;code&gt;core.hooksPath&lt;/code&gt; into the project folder. They don&amp;rsquo;t report hooks in folders that aren&amp;rsquo;t locked, because nothing is, and the watch names their changes. &lt;code&gt;.git&lt;/code&gt;&amp;rsquo;s identity and the git folders and delegations found are recorded in the &lt;code&gt;git&lt;/code&gt; section&amp;rsquo;s &lt;code&gt;made&lt;/code&gt;, as a lock&amp;rsquo;s check records them. A VM whose &lt;code&gt;made&lt;/code&gt; isn&amp;rsquo;t set yet reports as a new VM does.&lt;/p&gt;
&lt;p&gt;The watch reads &lt;code&gt;.git&lt;/code&gt; only when the VM is stopped, so it misses a change the VM made and undid before it stopped. It&amp;rsquo;s a report, not a security boundary.&lt;/p&gt;
&lt;p&gt;The hashes go in the VM&amp;rsquo;s state, in the &lt;code&gt;git&lt;/code&gt; section&amp;rsquo;s &lt;code&gt;watched&lt;/code&gt;, by each path relative to the project folder, with &lt;code&gt;scanned&lt;/code&gt; set once a check has recorded them. devvm records them when it creates the VM, and checks them again on each launch that finds the VM stopped and on &lt;code&gt;devvm stop&lt;/code&gt;, the same places that check the locks on macOS. Each check names every path whose hash changed, appeared or went since the last one, in one warning, at most ten of them and then how many more (&lt;code&gt;git_changed_more&lt;/code&gt;), and then records the new hashes. A launch of a running VM checks nothing. A VM whose state has no &lt;code&gt;watched&lt;/code&gt; yet, such as one an older devvm made, or one that &lt;code&gt;devvm adopt&lt;/code&gt; gave this folder, records its first hashes without naming anything.&lt;/p&gt;
&lt;p&gt;Each launch also warns that the VM can change &lt;code&gt;.git&lt;/code&gt; (&lt;code&gt;git_unprotected&lt;/code&gt;), unless the folder has no &lt;code&gt;.git&lt;/code&gt; or the VM is a &lt;code&gt;--clone&lt;/code&gt; VM. The warning stops once the user has chosen the mode, which devvm records as the &lt;code&gt;git&lt;/code&gt; section&amp;rsquo;s &lt;code&gt;chosen&lt;/code&gt;: &lt;code&gt;devvm git-protect off&lt;/code&gt; sets it, and so does &lt;code&gt;--no-git-protect&lt;/code&gt; when devvm creates the VM.&lt;/p&gt;
&lt;h2 data-hextra-search-id="what-a-lock-cant-stop"&gt;What a lock can&amp;rsquo;t stop&lt;span class="hx:absolute hx:-mt-20" id="what-a-lock-cant-stop"&gt;&lt;/span&gt;
&lt;a href="#what-a-lock-cant-stop" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The VM can rename &lt;code&gt;.git&lt;/code&gt; and put a new one in its place, add &lt;code&gt;.git/commondir&lt;/code&gt; to point git at another config, or do the same with a linked worktree&amp;rsquo;s folder in &lt;code&gt;.git/worktrees&lt;/code&gt;. When devvm creates the VM, and &lt;a href="#on-each-launch"&gt;on each launch&lt;/a&gt;, it reports a &lt;code&gt;commondir&lt;/code&gt; that&amp;rsquo;s there, linked worktrees whose &lt;code&gt;commondir&lt;/code&gt; leads somewhere else, and paths it couldn&amp;rsquo;t lock because they&amp;rsquo;re symlinks. devvm reads git&amp;rsquo;s own small files, a &lt;code&gt;.git&lt;/code&gt; file, a &lt;code&gt;commondir&lt;/code&gt; and a linked worktree&amp;rsquo;s &lt;code&gt;gitdir&lt;/code&gt;, through a symbolic link as git does, but only when each is a regular file of at most 16 MiB, opened without blocking, so a FIFO the VM leaves there can&amp;rsquo;t hang devvm. devvm doesn&amp;rsquo;t repair anything, so check what it names before you run git in the folder. When you don&amp;rsquo;t trust what runs in the VM, use &lt;a href="https://next.devvm.dev/docs/using/clone/"&gt;&lt;code&gt;--clone&lt;/code&gt;&lt;/a&gt;, which mounts no &lt;code&gt;.git&lt;/code&gt; at all.&lt;/p&gt;
&lt;p&gt;The VM writes &lt;code&gt;.git/index&lt;/code&gt;, because it has to in order to commit, so it can also add a submodule with its own config, which &lt;code&gt;git status&lt;/code&gt; on the host reads. A submodule&amp;rsquo;s &lt;code&gt;core.fsmonitor&lt;/code&gt; therefore also runs on the host. devvm names a new submodule at the next check that finds the VM stopped, but git on the host reads it before that. No setting in the locked config keeps git on the host out of it. The VM writes &lt;code&gt;.gitmodules&lt;/code&gt;, whose &lt;code&gt;ignore&lt;/code&gt; line for a submodule beats &lt;code&gt;diff.ignoreSubmodules&lt;/code&gt;, and git falls back to the index&amp;rsquo;s and &lt;code&gt;HEAD&lt;/code&gt;&amp;rsquo;s copies of the file when the working tree has none. &lt;code&gt;git add -A&lt;/code&gt;, &lt;code&gt;-u&lt;/code&gt; and &lt;code&gt;.&lt;/code&gt; enter a submodule whatever any setting says, and &lt;code&gt;git diff-index&lt;/code&gt;, &lt;code&gt;git diff-files&lt;/code&gt; and &lt;code&gt;git describe --dirty&lt;/code&gt; enter one that &lt;code&gt;.gitmodules&lt;/code&gt; doesn&amp;rsquo;t name. A setting for a submodule&amp;rsquo;s name in &lt;code&gt;.git/config&lt;/code&gt; holds only for the name the VM chooses in &lt;code&gt;.gitmodules&lt;/code&gt;. Only &lt;a href="https://next.devvm.dev/docs/using/clone/"&gt;&lt;code&gt;--clone&lt;/code&gt;&lt;/a&gt; keeps the VM&amp;rsquo;s code away from git on the host.&lt;/p&gt;
&lt;p&gt;devvm&amp;rsquo;s own git commands on the host run no program that a repo&amp;rsquo;s config or &lt;code&gt;.git&lt;/code&gt; names, a submodule&amp;rsquo;s included, whatever the VM wrote there. devvm runs each one with these settings, given as &lt;code&gt;GIT_CONFIG_COUNT&lt;/code&gt; pairs, which git takes over any config file:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;core.fsmonitor=false&lt;/code&gt;, &lt;code&gt;core.hooksPath=/dev/null&lt;/code&gt; and &lt;code&gt;core.alternateRefsCommand=true&lt;/code&gt;, so git runs no fsmonitor, no hook from a hooks folder and no command for an alternate object store&amp;rsquo;s refs.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;hook.EVENT.enabled=false&lt;/code&gt; for every event githooks(5) lists, and &lt;code&gt;hook.NAME.enabled=false&lt;/code&gt; for each hook the repo&amp;rsquo;s config names, so git 2.54 and newer run no hook that a config defines.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;filter.NAME.clean&lt;/code&gt;, &lt;code&gt;smudge&lt;/code&gt; and &lt;code&gt;process&lt;/code&gt; emptied, and &lt;code&gt;filter.NAME.required=false&lt;/code&gt;, for each filter driver the repo&amp;rsquo;s config names, so git hashes files without running a filter and doesn&amp;rsquo;t fail on a required one.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;protocol.allow=never&lt;/code&gt; and &lt;code&gt;protocol.ssh.allow=always&lt;/code&gt;, so git reaches nothing but ssh, not a path, &lt;code&gt;file://&lt;/code&gt;, &lt;code&gt;ext::&lt;/code&gt;, &lt;code&gt;git://&lt;/code&gt; or &lt;code&gt;http&lt;/code&gt;. A repo&amp;rsquo;s config could still allow one protocol by its own key, such as &lt;code&gt;protocol.ext.allow=always&lt;/code&gt;, which git takes over &lt;code&gt;protocol.allow&lt;/code&gt;, so devvm also sets &lt;code&gt;GIT_ALLOW_PROTOCOL=ssh&lt;/code&gt;, which git takes over every &lt;code&gt;protocol&lt;/code&gt; setting.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;maintenance.auto=false&lt;/code&gt; and &lt;code&gt;gc.auto=0&lt;/code&gt;, so a fetch starts no maintenance or gc.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;log.showSignature=false&lt;/code&gt;, and &lt;code&gt;gpg.program&lt;/code&gt;, &lt;code&gt;gpg.ssh.program&lt;/code&gt; and &lt;code&gt;gpg.x509.program&lt;/code&gt; all &lt;code&gt;false&lt;/code&gt;, so no log or reflog command runs the signing program a repo&amp;rsquo;s config names to check a signed commit.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;advice.graftFileDeprecated=false&lt;/code&gt;, so git doesn&amp;rsquo;t warn about the grafts file that the next paragraph sets.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Its ssh is &lt;code&gt;false&lt;/code&gt;, which reaches nothing, in place of a repo&amp;rsquo;s &lt;code&gt;core.sshCommand&lt;/code&gt; (&lt;code&gt;GIT_SSH_COMMAND=false&lt;/code&gt;, with &lt;code&gt;GIT_SSH_VARIANT=ssh&lt;/code&gt; over a repo&amp;rsquo;s &lt;code&gt;ssh.variant&lt;/code&gt;), unless the command is a &lt;code&gt;--clone&lt;/code&gt; VM&amp;rsquo;s fetch, and it fetches nothing lazily (&lt;code&gt;GIT_NO_LAZY_FETCH=1&lt;/code&gt;), so a repo that says it&amp;rsquo;s a partial clone can&amp;rsquo;t make &lt;code&gt;git rev-list&lt;/code&gt; or &lt;code&gt;git status&lt;/code&gt; connect anywhere for an object it lacks. It sees a repo&amp;rsquo;s real objects and history, not what its replace refs (&lt;code&gt;GIT_NO_REPLACE_OBJECTS=1&lt;/code&gt;) or a grafts file (&lt;code&gt;GIT_GRAFT_FILE=/dev/null&lt;/code&gt;) would show, so what it walks, packs or looks up is what the repo holds.&lt;/p&gt;
&lt;p&gt;It runs without any &lt;code&gt;GIT_*&lt;/code&gt; variable of devvm&amp;rsquo;s own environment, such as &lt;code&gt;GIT_DIR&lt;/code&gt;, &lt;code&gt;GIT_WORK_TREE&lt;/code&gt; or &lt;code&gt;GIT_CONFIG_GLOBAL&lt;/code&gt;, so a hook or a rebase you run devvm from can&amp;rsquo;t point it at another repo or config, and it reads your global config from its usual place. It keeps only the absolute folders of &lt;code&gt;PATH&lt;/code&gt;, because git looks programs up, ssh among them, from the repo&amp;rsquo;s folder, and it runs with &lt;code&gt;GIT_TERMINAL_PROMPT=0&lt;/code&gt;. Its &lt;code&gt;git status&lt;/code&gt; adds &lt;code&gt;--no-optional-locks&lt;/code&gt;, so it writes no index, and &lt;code&gt;--ignore-submodules=all&lt;/code&gt;, so it never enters a submodule, whose own config could name filters of its own.&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;--clone&lt;/code&gt; VM&amp;rsquo;s fetch adds &lt;code&gt;--no-recurse-submodules&lt;/code&gt; and an empty &lt;code&gt;--refmap=&lt;/code&gt;, so it updates only the branches its own refspecs name, never those of a remote that the repo&amp;rsquo;s config names after the clone&amp;rsquo;s address. It runs git with devvm&amp;rsquo;s own &lt;code&gt;GIT_SSH_COMMAND&lt;/code&gt;, which ignores the host, port and options git passes to ssh. It always connects to the VM&amp;rsquo;s own address and port, the host&amp;rsquo;s loopback port that the VM&amp;rsquo;s backend gives, as the VM&amp;rsquo;s user with the VM&amp;rsquo;s own key, and it reads no ssh config (&lt;code&gt;-F none&lt;/code&gt;). It checks the host keys devvm pinned for the VM&amp;rsquo;s current start, with the VM&amp;rsquo;s own known hosts file and no global one, &lt;code&gt;-o HostKeyAlias=&lt;/code&gt; the VM&amp;rsquo;s name and &lt;code&gt;-o StrictHostKeyChecking=yes&lt;/code&gt;, and it runs with &lt;code&gt;-o BatchMode=yes&lt;/code&gt;, &lt;code&gt;-o ForwardAgent=no&lt;/code&gt; and &lt;code&gt;-o ClearAllForwardings=yes&lt;/code&gt;. In the VM it runs only &lt;code&gt;git-receive-pack&lt;/code&gt; or &lt;code&gt;git-upload-pack&lt;/code&gt;, whichever git asks for, on the clone&amp;rsquo;s path, and it refuses any other command. So no &lt;code&gt;url.*.insteadOf&lt;/code&gt; or remote URL in the repo&amp;rsquo;s config can send the fetch to another host or to another path, and it forwards neither your agent nor any port. devvm&amp;rsquo;s own copy into the VM uses no git transport at all (&lt;a href="#the-copy-into-a-clone-vm"&gt;the copy into a clone VM&lt;/a&gt;). A repo&amp;rsquo;s &lt;code&gt;core.sshCommand&lt;/code&gt; doesn&amp;rsquo;t apply, because devvm sets &lt;code&gt;GIT_SSH_COMMAND&lt;/code&gt;, and its &lt;code&gt;diff.external&lt;/code&gt;, textconv drivers and pager never run, because none of devvm&amp;rsquo;s commands shows a diff or writes to a terminal.&lt;/p&gt;
&lt;p&gt;Before a &lt;code&gt;--clone&lt;/code&gt; VM is made, and again before its copy, devvm checks that what git reads in the folder is the repo&amp;rsquo;s own, so the copy can&amp;rsquo;t take another repo into the VM. The folder&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt; is a folder with no &lt;code&gt;commondir&lt;/code&gt;, or it&amp;rsquo;s the &lt;code&gt;.git&lt;/code&gt; file of a linked worktree whose link git made both ways. That &lt;code&gt;.git&lt;/code&gt; file names &lt;code&gt;&amp;lt;repo&amp;gt;/.git/worktrees/&amp;lt;name&amp;gt;&lt;/code&gt;, that entry&amp;rsquo;s &lt;code&gt;gitdir&lt;/code&gt; file names the folder&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt; back, and its &lt;code&gt;commondir&lt;/code&gt; leads to that &lt;code&gt;&amp;lt;repo&amp;gt;/.git&lt;/code&gt;, which has no &lt;code&gt;commondir&lt;/code&gt; of its own. Or it&amp;rsquo;s the &lt;code&gt;.git&lt;/code&gt; file of a submodule, whose git dir is below its parent repo&amp;rsquo;s: the parent is the nearest folder above with a &lt;code&gt;.git&lt;/code&gt;, itself its own repo by these same checks, and the &lt;code&gt;.git&lt;/code&gt; file names a folder &lt;code&gt;modules/&amp;lt;name&amp;gt;&lt;/code&gt; below the parent&amp;rsquo;s git dir, a nested submodule&amp;rsquo;s below its parent submodule&amp;rsquo;s, where it resolves, so no symbolic link leads it out of that git dir, with no &lt;code&gt;commondir&lt;/code&gt;, and whose config&amp;rsquo;s one &lt;code&gt;core.worktree&lt;/code&gt;, in a file that includes no other, leads back to the folder. Neither the git dir nor the common dir has &lt;code&gt;objects/info/alternates&lt;/code&gt;, or a &lt;code&gt;packed-refs&lt;/code&gt; or &lt;code&gt;reftable&lt;/code&gt; that&amp;rsquo;s a symlink, or anything in &lt;code&gt;objects&lt;/code&gt; or &lt;code&gt;refs&lt;/code&gt; that&amp;rsquo;s a symlink, such as a pack folder or a loose object&amp;rsquo;s folder that leads to another repo&amp;rsquo;s objects. Then &lt;code&gt;git rev-parse --absolute-git-dir --git-common-dir&lt;/code&gt; must name the same two folders. The common dir has no &lt;code&gt;info/grafts&lt;/code&gt;, because the copy carries each commit with its own parents. A partial clone&amp;rsquo;s copy carries every object the repo has that its tips reach, and leaves the rest to its promisor remote (&lt;a href="#the-copy-into-a-clone-vm"&gt;below&lt;/a&gt;). A worktree&amp;rsquo;s copy sends its branch, that branch&amp;rsquo;s upstream when the upstream is one ref, the repo&amp;rsquo;s default branch, the remote-tracking branches and the tags, so the repo&amp;rsquo;s other local branches stay on this machine. A &lt;code&gt;branch.&amp;lt;name&amp;gt;.merge&lt;/code&gt; that&amp;rsquo;s a pattern, such as &lt;code&gt;refs/heads/*&lt;/code&gt;, would make the upstream every branch, so devvm then copies no upstream.&lt;/p&gt;
&lt;p&gt;devvm finds the hook and filter names to turn off with one &lt;code&gt;git config&lt;/code&gt; before each command, so a VM that keeps swapping the repo&amp;rsquo;s config could show that &lt;code&gt;git config&lt;/code&gt; one config and the command another. Every hook event is turned off by its name as well, which covers config hooks on git that has the event setting, so the gap is a filter that the swap hides, which &lt;code&gt;git status&lt;/code&gt; could then run on a file whose stat changed. It needs a VM that writes the repo&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt;, so on macOS, where &lt;code&gt;.git/config&lt;/code&gt; is locked, it needs a repo devvm doesn&amp;rsquo;t lock, such as a nested repo past the walk&amp;rsquo;s bounds (&lt;a href="#nested-repos"&gt;nested repos&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Two things a repo&amp;rsquo;s config can still do, and neither runs code. An &lt;code&gt;include.path&lt;/code&gt; can make devvm&amp;rsquo;s &lt;code&gt;git config --get user.name&lt;/code&gt; read your name and email from another file in git&amp;rsquo;s config format, which then go into the VM as its git identity. A config file or included file that is a FIFO makes git, and so devvm, wait until you press Ctrl+C.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-copy-into-a-clone-vm"&gt;The copy into a clone VM&lt;span class="hx:absolute hx:-mt-20" id="the-copy-into-a-clone-vm"&gt;&lt;/span&gt;
&lt;a href="#the-copy-into-a-clone-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm copies a repo into a &lt;code&gt;--clone&lt;/code&gt; VM without &lt;code&gt;git push&lt;/code&gt;, because &lt;code&gt;git receive-pack&lt;/code&gt; in the VM refuses repos that users have: a shallow clone&amp;rsquo;s push fails with &lt;code&gt;shallow update not allowed&lt;/code&gt;, and a SHA-256 repo&amp;rsquo;s push into a SHA-1 repo fails with &lt;code&gt;the receiving end does not support this repository's hash algorithm&lt;/code&gt;. The copy is a snapshot instead, made by devvm&amp;rsquo;s own git on this machine and applied by plain git in the VM, through the backend&amp;rsquo;s command channel, which also carries the VM&amp;rsquo;s agent. The structure test keeps git push out of devvm&amp;rsquo;s code, so the copy can&amp;rsquo;t drift back to a second transport (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;where the code is&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The copy takes three commands in the VM:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;One script makes every repo&lt;/strong&gt; the clone has. For each repo, it gets the repo&amp;rsquo;s path and the host repo&amp;rsquo;s object format. A repo that&amp;rsquo;s copied already is printed as landed and left alone. That&amp;rsquo;s a repo whose &lt;code&gt;.git/devvm-seeded&lt;/code&gt; says &lt;code&gt;done&lt;/code&gt;, or one with no such file whose &lt;code&gt;HEAD&lt;/code&gt; resolves, which an older devvm&amp;rsquo;s push made. A repo that isn&amp;rsquo;t there yet is made with &lt;code&gt;git init&lt;/code&gt;, with &lt;code&gt;--object-format=sha256&lt;/code&gt; only for a SHA-256 repo, because git before 2.29 doesn&amp;rsquo;t know the option. One that&amp;rsquo;s there, from a copy that didn&amp;rsquo;t finish, isn&amp;rsquo;t made again, because git 2.54&amp;rsquo;s &lt;code&gt;git init&lt;/code&gt; in a reftable repo drops its &lt;code&gt;extensions.refStorage&lt;/code&gt; setting and breaks the repo. It takes &lt;code&gt;receive.denyCurrentBranch=updateInstead&lt;/code&gt; and &lt;code&gt;receive.shallowUpdate=true&lt;/code&gt;, for your own &lt;code&gt;git push devvm BRANCH&lt;/code&gt; later, and &lt;code&gt;.git/devvm-seeded&lt;/code&gt; says &lt;code&gt;pending&lt;/code&gt;. A &lt;code&gt;git init&lt;/code&gt; that fails for a SHA-256 repo prints the VM&amp;rsquo;s &lt;code&gt;git --version&lt;/code&gt;, and devvm stops before it sends anything (&lt;code&gt;clone_vm_git_old&lt;/code&gt;), showing the version only when it reads as git prints one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A tar of small files&lt;/strong&gt; goes into &lt;code&gt;.git/devvm-seed&lt;/code&gt; in the VM&amp;rsquo;s repo, never &lt;code&gt;/tmp&lt;/code&gt;, which is in memory on some systems. It holds the refs to set, each an object and its name, the symbolic refs, such as &lt;code&gt;refs/remotes/origin/HEAD&lt;/code&gt;, each with the ref it points to, what to check out, a branch&amp;rsquo;s name or, for a detached HEAD, its commit, and the host repo&amp;rsquo;s &lt;code&gt;shallow&lt;/code&gt; file, read from the repo&amp;rsquo;s common dir as a regular file only, never through a link, so a link there can&amp;rsquo;t send another file. It also holds the working tree (&lt;a href="#the-working-tree-in-the-copy"&gt;the working tree&lt;/a&gt;): the repo&amp;rsquo;s index, normalised, the paths to check out from it, and the working copies of the tracked files that differ from it. And it holds the repo&amp;rsquo;s state (&lt;a href="#the-state-in-the-copy"&gt;the state in the copy&lt;/a&gt;): an operation in progress, the stash, and the &lt;code&gt;info&lt;/code&gt; files.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The pack&lt;/strong&gt; of the objects those refs and a detached HEAD reach, with the index&amp;rsquo;s blobs and the commits the state names, from &lt;code&gt;git pack-objects --revs --stdout&lt;/code&gt;, goes straight into &lt;code&gt;git index-pack --stdin&lt;/code&gt; in the VM, which checks every object it writes, so devvm doesn&amp;rsquo;t run &lt;code&gt;git fsck&lt;/code&gt; as well. &lt;code&gt;pack-objects --revs&lt;/code&gt; walks with the repo&amp;rsquo;s commit-graph and bitmaps when it has them, so a VM that once wrote this repo&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt;, through a mount before &lt;code&gt;.git&lt;/code&gt; protection, could have forged one to put objects in the pack that the refs don&amp;rsquo;t reach, which are this repo&amp;rsquo;s own objects, never another repo&amp;rsquo;s or a file&amp;rsquo;s. Neither end holds the whole pack in memory, and when the command in the VM ends early, devvm closes the pipe so &lt;code&gt;pack-objects&lt;/code&gt; stops. The same command then copies the &lt;code&gt;shallow&lt;/code&gt; file and sets the refs with &lt;code&gt;git update-ref --stdin&lt;/code&gt;, and each symbolic ref with &lt;code&gt;git symbolic-ref&lt;/code&gt;, unless a ref of that name is there already. It points &lt;code&gt;HEAD&lt;/code&gt; at the branch, with &lt;code&gt;git symbolic-ref&lt;/code&gt;, or detaches it at the commit, with &lt;code&gt;git update-ref --no-deref&lt;/code&gt;, and puts the host&amp;rsquo;s index in place, with the working copies sent where the VM has no file. It does that only when &lt;code&gt;HEAD&lt;/code&gt; was unborn, is on the branch the copy just set, or is detached at the commit or at one an earlier try set, so a VM that checked out a branch of its own keeps it, and one that moved its detached &lt;code&gt;HEAD&lt;/code&gt; keeps it too. A &lt;code&gt;HEAD&lt;/code&gt; left where the VM put it, away from this machine&amp;rsquo;s, is named (&lt;code&gt;clone_kept_head&lt;/code&gt;), which covers a repo here switched between a branch and a detached &lt;code&gt;HEAD&lt;/code&gt; since the copy that didn&amp;rsquo;t finish. It checks out the listed paths with &lt;code&gt;git checkout-index -u -z --stdin&lt;/code&gt;, or every path with &lt;code&gt;-a&lt;/code&gt; when it kept the VM&amp;rsquo;s &lt;code&gt;HEAD&lt;/code&gt;, without &lt;code&gt;-f&lt;/code&gt;, so it writes only the files that aren&amp;rsquo;t there. It removes &lt;code&gt;.git/devvm-seed&lt;/code&gt; and writes &lt;code&gt;done&lt;/code&gt; to &lt;code&gt;.git/devvm-seeded&lt;/code&gt; last.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The refs are those of &lt;code&gt;refs/heads&lt;/code&gt;, &lt;code&gt;refs/tags&lt;/code&gt;, &lt;code&gt;refs/notes&lt;/code&gt;, &lt;code&gt;refs/replace&lt;/code&gt; and &lt;code&gt;refs/remotes&lt;/code&gt;, read in one &lt;code&gt;git for-each-ref&lt;/code&gt;, less the remote-tracking branches of each remote any of whose URLs, as git resolves them (&lt;code&gt;git remote get-url --all&lt;/code&gt;), reaches a devvm VM by its full name or its shorter one, in any URL form or case, and less a branch that&amp;rsquo;s no commit, which git won&amp;rsquo;t set. A linked worktree&amp;rsquo;s copy takes the smaller set above, and its upstream and default branch pass the same rules, so neither can be another VM&amp;rsquo;s remote-tracking branch or a ref outside the namespaces, such as &lt;code&gt;refs/stash&lt;/code&gt; through &lt;code&gt;branch.&amp;lt;name&amp;gt;.remote=.&lt;/code&gt;. A symbolic ref goes only when the ref it points to goes. Nothing outside those namespaces goes, such as &lt;code&gt;refs/original&lt;/code&gt;, &lt;code&gt;refs/prefetch&lt;/code&gt; or &lt;code&gt;refs/stash&lt;/code&gt;. The pack carries what a push of the same refs would: the commits, trees, blobs and tags they reach, and nothing unreachable. devvm&amp;rsquo;s git runs &lt;code&gt;pack-objects&lt;/code&gt; with replace refs and grafts off, so each commit goes with its own parents, and a repo with a grafts file is refused before the VM is made (&lt;code&gt;clone_grafts&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;A partial clone, one whose config names a promisor remote (&lt;code&gt;remote.&amp;lt;name&amp;gt;.promisor&lt;/code&gt;, or an older git&amp;rsquo;s &lt;code&gt;extensions.partialClone&lt;/code&gt;), lacks objects its remote has, and &lt;code&gt;pack-objects --revs&lt;/code&gt; would want them in its walk, which fails with &lt;code&gt;GIT_NO_LAZY_FETCH=1&lt;/code&gt;, missing trees and all. Its pack is made from a list instead: &lt;code&gt;git rev-list --objects --missing=allow-promisor --stdin&lt;/code&gt; of the tips the repo has, which &lt;code&gt;git cat-file --batch-check&lt;/code&gt; picks, as a sparse checkout&amp;rsquo;s index can name blobs the repo never fetched, piped into &lt;code&gt;git pack-objects --stdout&lt;/code&gt; through a pipe of their own, whose ends devvm closes once both have started, so when pack-objects ends early, rev-list&amp;rsquo;s next write fails and it ends too. devvm holds back the pack&amp;rsquo;s last 64 bytes, more than its trailing hash, until the pack ends, then waits for rev-list, and when rev-list failed, it ends the pack there, so the VM&amp;rsquo;s &lt;code&gt;git index-pack&lt;/code&gt; gets a pack cut short and refuses it, and the copy fails with rev-list&amp;rsquo;s error, never with a pack that lacks objects and says nothing. The VM reads the pack with &lt;code&gt;git index-pack --promisor&lt;/code&gt;, so it&amp;rsquo;s a promisor pack, and the settings give the VM&amp;rsquo;s clone the promisor remote, with its filter, and &lt;code&gt;promisor&lt;/code&gt; as git reads it, so &lt;code&gt;yes&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt; or no value at all goes as &lt;code&gt;true&lt;/code&gt;. Its git then fetches a missing object from that remote when a command needs one. That fetch goes through the VM&amp;rsquo;s own network policy, with no credential of this machine&amp;rsquo;s, as the remote&amp;rsquo;s URL has none, so a private remote needs the VM&amp;rsquo;s own login.&lt;/p&gt;
&lt;p&gt;devvm reads each ref&amp;rsquo;s object type with &lt;code&gt;git cat-file --batch-check&lt;/code&gt; after listing the refs, because &lt;code&gt;git for-each-ref&lt;/code&gt;&amp;rsquo;s &lt;code&gt;%(objecttype)&lt;/code&gt; fails on a ref whose object the repo lacks, such as a partial clone&amp;rsquo;s tag of a blob it never fetched. Such a ref stays out of the copy, named (&lt;code&gt;clone_partial_refs_kept&lt;/code&gt;), and in a repo that isn&amp;rsquo;t partial, it fails the copy, as that repo is broken (&lt;code&gt;clone_ref_no_object&lt;/code&gt;). devvm reads the promisor remotes as git here reads them, includes followed, each &lt;code&gt;remote.&amp;lt;name&amp;gt;.promisor&lt;/code&gt; on its own, so one value git can&amp;rsquo;t read as a boolean drops only its own remote, and a remote&amp;rsquo;s last value wins. It names those whose settings don&amp;rsquo;t go, as their URL is of a kind that stays or reaches a devvm VM (&lt;code&gt;clone_partial_promisor_kept&lt;/code&gt;), and copies the repo anyway, as the VM&amp;rsquo;s clone works with what it has. For each promisor remote that goes, in name order, it compares the remote&amp;rsquo;s host and port with the VM&amp;rsquo;s tier: on the none tier it names the host with how to reach it (&lt;code&gt;clone_partial_blocked_none&lt;/code&gt;), on the allowlist tier one the allowlist doesn&amp;rsquo;t allow (&lt;code&gt;clone_partial_blocked&lt;/code&gt;), and on the internet tier one a deny rule blocks or an address that isn&amp;rsquo;t public, which that tier never reaches (&lt;code&gt;clone_partial_denied&lt;/code&gt;). A host it names on a port other than 80 or 443, such as an ssh remote&amp;rsquo;s 22, is named as the rule that allows that port alone, such as &lt;code&gt;github.com:22&lt;/code&gt;, which &lt;code&gt;devvm network allow&lt;/code&gt; takes. When devvm can&amp;rsquo;t read the VM&amp;rsquo;s policies, it judges nothing against them, and names only the none tier&amp;rsquo;s hosts and private addresses. A name that resolves to a private address isn&amp;rsquo;t reached either, which devvm can&amp;rsquo;t tell before the VM looks it up. It also names a remote on this machine, a &lt;code&gt;file://&lt;/code&gt; URL or a path, which the VM can&amp;rsquo;t reach (&lt;code&gt;clone_partial_unreachable&lt;/code&gt;). A scp-like URL&amp;rsquo;s host is read as git reads it, up to its first colon, past a bracketed one such as &lt;code&gt;[::1]&lt;/code&gt;, and a URL whose port isn&amp;rsquo;t a number names no host.&lt;/p&gt;
&lt;p&gt;devvm&amp;rsquo;s own fetch from the VM keeps &lt;code&gt;GIT_NO_LAZY_FETCH=1&lt;/code&gt;, so a VM can&amp;rsquo;t make this machine&amp;rsquo;s git fetch anything, and the VM&amp;rsquo;s &lt;code&gt;git upload-pack&lt;/code&gt; fetches no missing object to send it, as git 2.45.1 and newer turn that off. So when the VM&amp;rsquo;s work names an object its partial clone lacks, such as a blob restored from an old commit, the fetch fails, and devvm says to have git in the VM read the work&amp;rsquo;s objects first, which fetches them, then fetch again (&lt;code&gt;clone_fetch_partial&lt;/code&gt;). devvm doesn&amp;rsquo;t turn lazy fetching on in the VM&amp;rsquo;s upload-pack.&lt;/p&gt;
&lt;p&gt;A copy that fails before its end leaves &lt;code&gt;pending&lt;/code&gt;, so the next launch copies again in full. &lt;code&gt;git index-pack&lt;/code&gt; of a pack the repo has, &lt;code&gt;git symbolic-ref&lt;/code&gt; and the checkout are all safe to run again. The refs follow one rule, so a copy never moves a branch the VM moved: before it sets a ref, the script records its name and the commit in &lt;code&gt;.git/devvm-seeded-refs&lt;/code&gt;, and it then sets a ref that&amp;rsquo;s missing, at the host&amp;rsquo;s commit already, or at a commit an earlier try recorded. It leaves any other as it is and prints it, and devvm names those branches (&lt;code&gt;clone_kept_branches&lt;/code&gt;). After the checkout, &lt;code&gt;git update-index --refresh&lt;/code&gt; and &lt;code&gt;git diff-files -z&lt;/code&gt; list the files whose content isn&amp;rsquo;t the index&amp;rsquo;s. devvm leaves out the paths that the copy itself sent or deleted, adds the VM&amp;rsquo;s own files at those paths, and names what&amp;rsquo;s left as the files the VM wrote (&lt;code&gt;clone_kept_files&lt;/code&gt;). What the VM prints is untrusted, so devvm reads at most 1 MiB of it, shows at most 20 names, each cut to 200 bytes and quoted, and acts on none of it. &lt;code&gt;devvm rm&lt;/code&gt; and &lt;code&gt;devvm clone off&lt;/code&gt; check a clone whose copy didn&amp;rsquo;t finish as any other, so the VM&amp;rsquo;s work there is offered for fetching too.&lt;/p&gt;
&lt;p&gt;An older devvm made each VM&amp;rsquo;s repo with plain &lt;code&gt;git init&lt;/code&gt;, so with SHA-1 object names. In such a VM whose copy failed, a SHA-256 repo&amp;rsquo;s empty repo has the wrong object format, which the script prints. devvm then asks whether to make that repo again (&lt;code&gt;clone_repo_format&lt;/code&gt;). The repo has no commit, but it may hold the VM&amp;rsquo;s own hooks or config, so only you can say, and no flag answers the question. Without a terminal devvm refuses, saying what to run (&lt;code&gt;clone_repo_format_kept&lt;/code&gt;). On yes, the script deletes that &lt;code&gt;.git&lt;/code&gt; only when it still has no &lt;code&gt;HEAD&lt;/code&gt; and no ref, and makes it again.&lt;/p&gt;
&lt;h3 data-hextra-search-id="submodules-in-the-copy"&gt;Submodules in the copy&lt;span class="hx:absolute hx:-mt-20" id="submodules-in-the-copy"&gt;&lt;/span&gt;
&lt;a href="#submodules-in-the-copy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Once a repo&amp;rsquo;s copy is in, and before devvm records it as copied, each of its initialised submodules gets a clone of its own in the VM, nested ones after their parent, so a copy that didn&amp;rsquo;t finish copies the rest on the next launch. devvm takes the list from this machine&amp;rsquo;s repo alone, never from the VM or &lt;code&gt;.gitmodules&lt;/code&gt;: a submodule is one whose name the repo&amp;rsquo;s own config gives a URL (&lt;code&gt;submodule.&amp;lt;name&amp;gt;.url&lt;/code&gt;, as &lt;code&gt;git submodule init&lt;/code&gt; sets it), whose git dir is &lt;code&gt;modules/&amp;lt;name&amp;gt;&lt;/code&gt; in the repo&amp;rsquo;s common dir, whose &lt;code&gt;core.worktree&lt;/code&gt; there leads to a folder below the repo where its index has a submodule (a gitlink), and which is its own repo there by &lt;a href="#the-copy-into-a-clone-vm"&gt;the checks above&lt;/a&gt;, at a path a terminal can show. An uninitialised submodule has no such git dir, so its folder stays as the parent&amp;rsquo;s copy left it, empty, and so does one initialised after the copy, or in a VM made before devvm copied submodules. One that&amp;rsquo;s initialised but fails a check stays on this machine, named (&lt;code&gt;clone_submodule_kept&lt;/code&gt;), and so does each of a linked worktree&amp;rsquo;s, whose submodules&amp;rsquo; git dirs are in the common dir, which devvm doesn&amp;rsquo;t read for them. Each submodule&amp;rsquo;s copy is a repo&amp;rsquo;s, checked again just before, as a folder of repos&amp;rsquo; repo is: still its own repo&amp;rsquo;s top, with no grafts and a &lt;code&gt;HEAD&lt;/code&gt;, and no other VM mounting it. One that fails that, or any step of its copy, such as a VM that refuses it, is named (&lt;code&gt;clone_submodule_kept&lt;/code&gt;), with its own submodules left out, and the repo&amp;rsquo;s copy goes on without it and is recorded as done, so it&amp;rsquo;s tried again only on a launch before that, when the repo&amp;rsquo;s copy didn&amp;rsquo;t finish. Its record is taken out only when nothing of it can be in the VM: it failed before this launch recorded it, with no record from an earlier launch. Otherwise its record stays, not copied, so whatever of it the VM has is still fetched from and checked by &lt;code&gt;devvm rm&lt;/code&gt;, which checks a repo that wasn&amp;rsquo;t copied when the VM has it, and &lt;code&gt;devvm clone fetch&lt;/code&gt; adds its remote. Its remote is chosen as a repo&amp;rsquo;s is, recorded with its path in the VM&amp;rsquo;s state before its copy (&lt;code&gt;submodules&lt;/code&gt;, in its repo&amp;rsquo;s entry, nested ones in theirs). The submodule is then made in the VM, in the folder the parent&amp;rsquo;s checkout left empty, as a repo with a &lt;code&gt;.git&lt;/code&gt; folder of its own, which &lt;code&gt;git submodule status&lt;/code&gt; reads as a submodule&amp;rsquo;s, and copied, so its &lt;code&gt;HEAD&lt;/code&gt; is detached at the commit the submodule has checked out here, with its refs, its changes, its state and its settings; then its remote added in its repo here, which is its git dir&amp;rsquo;s config, and the copy recorded. The parent&amp;rsquo;s settings give it &lt;code&gt;submodule.&amp;lt;name&amp;gt;.url&lt;/code&gt; and &lt;code&gt;active&lt;/code&gt; (&lt;a href="#the-settings-in-the-copy"&gt;the settings in the copy&lt;/a&gt;), so git in the VM takes it for initialised.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm clone fetch&lt;/code&gt;, &lt;code&gt;devvm rm&lt;/code&gt;&amp;rsquo;s and &lt;code&gt;devvm clone off&lt;/code&gt;&amp;rsquo;s check and the remotes&amp;rsquo; removal go over each submodule the state records, each named by its path in the folder, as a folder of repos&amp;rsquo; repos are, so a submodule you remove or deinitialise here later isn&amp;rsquo;t passed over: as one another VM mounts, it&amp;rsquo;s named as one devvm can&amp;rsquo;t check (&lt;code&gt;clone_submodule_unchecked&lt;/code&gt;), and &lt;code&gt;devvm rm&lt;/code&gt; and &lt;code&gt;devvm clone off&lt;/code&gt; ask before the VM goes, while &lt;code&gt;devvm clone fetch&lt;/code&gt; names it and leaves it. &lt;code&gt;devvm clone add&lt;/code&gt; of a recorded submodule says it&amp;rsquo;s the clone&amp;rsquo;s already. An older devvm ignores the record, so its &lt;code&gt;devvm rm&lt;/code&gt; wouldn&amp;rsquo;t check a submodule, which matters only after a downgrade. A folder of repos&amp;rsquo; walk passes over a repo that&amp;rsquo;s a submodule of a repo in the folder, among that repo&amp;rsquo;s initialised submodules, which its clone has.&lt;/p&gt;
&lt;p&gt;A submodule&amp;rsquo;s own folder isn&amp;rsquo;t a repo that &lt;code&gt;--clone&lt;/code&gt; takes by itself: its &lt;code&gt;.git&lt;/code&gt; file leads into the parent&amp;rsquo;s &lt;code&gt;.git/modules&lt;/code&gt;, or for a parent that&amp;rsquo;s a linked worktree, into the main repo&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt;, and a VM that mounts the folder of either could swap that git dir under host git, which the check for a VM mounting the repo, looking at the folder and a worktree&amp;rsquo;s common dir, wouldn&amp;rsquo;t see. So &lt;code&gt;devvm --clone&lt;/code&gt; there, and a folder of repos&amp;rsquo; copy of one, refuses it as a &lt;code&gt;.git&lt;/code&gt; that points into another repo (&lt;code&gt;clone_git_elsewhere&lt;/code&gt;). Only as a submodule of a &lt;code&gt;--clone&lt;/code&gt; repo is it copied, and every check of it as one, before its copy, before a fetch and in the clone check, takes that shape.&lt;/p&gt;
&lt;h3 data-hextra-search-id="git-lfs-in-the-copy"&gt;Git LFS in the copy&lt;span class="hx:absolute hx:-mt-20" id="git-lfs-in-the-copy"&gt;&lt;/span&gt;
&lt;a href="#git-lfs-in-the-copy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Base&amp;rsquo;s image has &lt;code&gt;git-lfs&lt;/code&gt;, pinned like every other download, but nothing in the image sets its filter, so a VM that mounts its folder sees each LFS file as the pointer git stores. The copy sets the filter in each clone repo it makes, submodules included, with &lt;code&gt;git lfs install --local --skip-repo&lt;/code&gt;, which writes the repo&amp;rsquo;s own config and no hooks, and when that fails, devvm says the clone&amp;rsquo;s LFS files may be pointers there (&lt;code&gt;clone_lfs_setup_failed&lt;/code&gt;). No &lt;code&gt;git-lfs&lt;/code&gt; runs on this machine for the copy or for what comes back, and when the repo&amp;rsquo;s &lt;code&gt;lfs.storage&lt;/code&gt; puts its objects outside &lt;code&gt;.git&lt;/code&gt;, devvm copies none either way and says so (&lt;code&gt;clone_lfs_storage&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Every object file devvm reads or writes on this machine is opened beneath the repo&amp;rsquo;s common dir through a root that no path can leave, and before that, each folder on the way, &lt;code&gt;lfs&lt;/code&gt;, &lt;code&gt;lfs/objects&lt;/code&gt;, both two-character folders and &lt;code&gt;lfs/tmp&lt;/code&gt;, must be a folder, never a link, as such a root still follows a link that stays inside it. So a link planted in &lt;code&gt;.git/lfs&lt;/code&gt; can&amp;rsquo;t make devvm send a file from elsewhere on this machine or write the VM&amp;rsquo;s content anywhere else.&lt;/p&gt;
&lt;p&gt;On the way in, devvm reads the pointers among the index&amp;rsquo;s blobs: those of at most 1,024 bytes, &lt;code&gt;git cat-file --batch-check&lt;/code&gt; says, which, read with &lt;code&gt;git cat-file --batch&lt;/code&gt;, are a pointer as git-lfs&amp;rsquo;s spec has it, with its version line first, an &lt;code&gt;oid sha256:&lt;/code&gt; of 64 lowercase hex characters and a &lt;code&gt;size&lt;/code&gt;, each once, and a newline at its end. Both outputs are read as they come, and at most 200,000 blobs are taken as maybe pointers. Each object the repo has, at &lt;code&gt;lfs/objects/&amp;lt;oid[0:2]&amp;gt;/&amp;lt;oid[2:4]&amp;gt;/&amp;lt;oid&amp;gt;&lt;/code&gt; in its common dir, a regular file of its pointer&amp;rsquo;s size, is hashed before anything is sent, and one whose SHA-256 isn&amp;rsquo;t its oid stays on this machine, named (&lt;code&gt;clone_lfs_bad&lt;/code&gt;), while the copy goes on. The rest go in the tar as &lt;code&gt;lfs/&amp;lt;oid&amp;gt;&lt;/code&gt;, hashed again as they&amp;rsquo;re sent, so one that changed in between fails the copy, its tar cut short. The VM moves each into its repo&amp;rsquo;s &lt;code&gt;lfs/objects&lt;/code&gt;, where it has no file of that name, before the checkout. The checkout runs with &lt;code&gt;GIT_LFS_SKIP_SMUDGE=1&lt;/code&gt;, so &lt;code&gt;git-lfs&lt;/code&gt; never fetches during the copy, then &lt;code&gt;git lfs checkout&lt;/code&gt;, which reads only the objects the repo has, writes each file&amp;rsquo;s content; a file whose object isn&amp;rsquo;t there stays a pointer.&lt;/p&gt;
&lt;p&gt;On the way back, once each fetch from the VM is in, &lt;code&gt;devvm clone fetch&lt;/code&gt;&amp;rsquo;s and &lt;code&gt;devvm rm&lt;/code&gt;&amp;rsquo;s and &lt;code&gt;devvm clone off&lt;/code&gt;&amp;rsquo;s, devvm lists the objects that what it fetched (&lt;code&gt;FETCH_HEAD&lt;/code&gt;) reaches past this repo&amp;rsquo;s own refs, with &lt;code&gt;git rev-list --objects --missing=allow-promisor&lt;/code&gt;, and reads the pointers among them as above. Its own refs are every ref but the &lt;code&gt;saved/&lt;/code&gt; branches and the remote-tracking branches of a devvm VM&amp;rsquo;s remote, so a commit that a plain &lt;code&gt;git fetch devvm&lt;/code&gt; brought earlier, without its LFS objects, still has them looked for. Once that work is merged into a branch of this repo, though, its commits are past that branch, so devvm also has the script in the VM list the files in the clone&amp;rsquo;s &lt;code&gt;lfs/objects&lt;/code&gt;, by name and size, none followed through a link, and takes those this repo lacks whose pointer the history of what it fetched names since the copy. That walk stops at what the copy set the clone&amp;rsquo;s refs to, which the VM keeps in &lt;code&gt;.git/devvm-seed-tips&lt;/code&gt;, so an object the VM fetched for the history it was given isn&amp;rsquo;t taken for its work, and a long history never has every blob read, or, for a clone an older devvm made, at this repo&amp;rsquo;s own refs, as above. When the objects this repo lacks come to more than 2 GiB in all, a total that can&amp;rsquo;t overflow, devvm asks first (&lt;code&gt;clone_lfs_large&lt;/code&gt;), and refuses without a terminal. A script in the VM then writes all of them in one stream, its connection carrying no SSH agent: for each, a line with the oid and its size and then the clone&amp;rsquo;s own &lt;code&gt;.git/lfs/objects/…/&amp;lt;oid&amp;gt;&lt;/code&gt;, a regular file that isn&amp;rsquo;t a link, or a line that says the clone lacks it or has it at another size. devvm reads exactly the pointer&amp;rsquo;s size of each into a new file in this repo&amp;rsquo;s &lt;code&gt;lfs/tmp&lt;/code&gt; and moves it into &lt;code&gt;lfs/objects&lt;/code&gt; only when its SHA-256 is the oid. One that the VM lacks, or that isn&amp;rsquo;t what its pointer names, stays out, named (&lt;code&gt;clone_lfs_kept&lt;/code&gt;), and its file is a pointer here until &lt;code&gt;git lfs pull&lt;/code&gt; fetches it. A failure is named too (&lt;code&gt;clone_lfs_failed&lt;/code&gt;), with its reason in the run log.&lt;/p&gt;
&lt;p&gt;An object that the VM&amp;rsquo;s clone has and that didn&amp;rsquo;t come back, for a reason other than its content, such as a link in &lt;code&gt;.git/lfs&lt;/code&gt; or a stream cut short, would go with the VM, so &lt;code&gt;devvm rm&lt;/code&gt; and &lt;code&gt;devvm clone off&lt;/code&gt; keep the VM then, as for a commit they couldn&amp;rsquo;t fetch. Their check also looks for the objects that only the VM&amp;rsquo;s clone has, of commits this repo has already: it lists them as above from the clone&amp;rsquo;s refs, merged ones included, asks the script in the VM which it has, sizes only, stopping the script once it writes more than a line for each, or more than 64 MiB of the list, and names them (&lt;code&gt;clone_lfs_unfetched&lt;/code&gt;), then asks before the VM goes, which &lt;code&gt;devvm clone fetch&lt;/code&gt; answers by bringing them here.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-working-tree-in-the-copy"&gt;The working tree in the copy&lt;span class="hx:absolute hx:-mt-20" id="the-working-tree-in-the-copy"&gt;&lt;/span&gt;
&lt;a href="#the-working-tree-in-the-copy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The copy sends your uncommitted changes as git&amp;rsquo;s own index and the working copies of the files that differ from it, so &lt;code&gt;git status&lt;/code&gt; in the VM shows what it shows here. devvm reads the repo&amp;rsquo;s index, at the path &lt;code&gt;git rev-parse --git-path index&lt;/code&gt; gives, as a regular file only, never through a link, into a temporary file of its own, registered for removal before any git command runs, so it goes however the copy ends. The copy keeps the index&amp;rsquo;s modification time, so git tells a file changed in the second the index was written from one that wasn&amp;rsquo;t, as it would with the repo&amp;rsquo;s own index. devvm&amp;rsquo;s git then refreshes the copy, so a file whose stat changed but not its content isn&amp;rsquo;t sent, without entering any submodule (&lt;code&gt;--ignore-submodules&lt;/code&gt;), and rewrites it as version 3, even when it&amp;rsquo;s that already (&lt;code&gt;--force-write-index&lt;/code&gt;), with no split index, no sparse directories, no untracked cache, no fsmonitor data, no resolve-undo and a real trailing hash. The untracked cache names untracked files and the repo&amp;rsquo;s path on this machine, so none of that goes, and any git since 1.7 reads the result. Resolve-undo, which &lt;code&gt;git checkout -m&lt;/code&gt; uses to bring back a conflict you resolved, can name blobs that no ref reaches and that the pack doesn&amp;rsquo;t carry, so the VM&amp;rsquo;s repo would fail &lt;code&gt;git fsck&lt;/code&gt; with it. What&amp;rsquo;s staged is staged in the VM, conflicts, intent-to-add entries and skip-worktree bits included, and the pack carries every blob the index names, but no gitlink&amp;rsquo;s commit, which isn&amp;rsquo;t this repo&amp;rsquo;s. An index with a path that git never checks out, one with a &lt;code&gt;.git&lt;/code&gt; part in any case, as macOS and Windows also read one, or with an empty, &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;..&lt;/code&gt; part, fails the copy.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;git ls-files -s -z&lt;/code&gt; on the copy lists the paths, and &lt;code&gt;git diff-files --ignore-submodules=all --name-only -z&lt;/code&gt; on it lists those whose working copy differs. Without &lt;code&gt;--ignore-submodules&lt;/code&gt;, git diff-files runs &lt;code&gt;git status&lt;/code&gt; in each submodule and embedded repo, where that repo&amp;rsquo;s own config can name a filter that devvm&amp;rsquo;s git hasn&amp;rsquo;t turned off, so devvm runs diff-files only through the helper that adds it. Each path that differs is sorted out through a root opened at the repo, and each folder on the way to it is opened from its parent, refusing a symbolic link, so neither a link out of the repo nor one inside it, such as a tracked folder replaced by a link to an ignored folder or to &lt;code&gt;.git&lt;/code&gt;, sends another file:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A regular file or a symbolic link, where the index has one of those, goes as it is, under &lt;code&gt;changed/&lt;/code&gt; in the tar, with its permissions and modification time, read without following a link. A file that&amp;rsquo;s a link now goes as the link, so &lt;code&gt;git status&lt;/code&gt; in the VM shows the same type change.&lt;/li&gt;
&lt;li&gt;A path that&amp;rsquo;s gone, or whose folder is a symbolic link here, which git takes for a deletion, goes as gone: the VM doesn&amp;rsquo;t check it out, so it&amp;rsquo;s deleted there too.&lt;/li&gt;
&lt;li&gt;Anything else, such as a tracked file that&amp;rsquo;s a folder now, goes as gone, and devvm names it (&lt;code&gt;clone_typechange_kept&lt;/code&gt;), so nothing inside that folder goes.&lt;/li&gt;
&lt;li&gt;A gitlink, a submodule&amp;rsquo;s or an embedded repo&amp;rsquo;s, is checked out as git does, as an empty folder, without its &lt;code&gt;.git&lt;/code&gt; or anything in it.&lt;/li&gt;
&lt;li&gt;A path that a &lt;code&gt;filter&lt;/code&gt; attribute names a filter for, in the working tree&amp;rsquo;s attributes or the index&amp;rsquo;s, such as git-crypt&amp;rsquo;s or Git LFS&amp;rsquo;s, is checked out from the index, as git stores it, and named as one that may differ (&lt;code&gt;clone_filtered_kept&lt;/code&gt;). devvm&amp;rsquo;s git runs no filter, so it can&amp;rsquo;t tell a real change from the filter&amp;rsquo;s own. Such a file that&amp;rsquo;s gone goes as gone.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the VM, when the copy sets &lt;code&gt;HEAD&lt;/code&gt;, it puts the index in place, notes which of the paths sent or gone it already has a file at, copies each working copy sent where the VM has no file, with &lt;code&gt;cp -P -p&lt;/code&gt;, and checks out the other paths from the index, without &lt;code&gt;-f&lt;/code&gt;, except a conflict&amp;rsquo;s, which has no entry to check out, and a path with the skip-worktree bit that the working tree doesn&amp;rsquo;t have, which a sparse checkout leaves out, in the VM as here. A skip-worktree path that the working tree has, marked by hand with &lt;code&gt;git update-index --skip-worktree&lt;/code&gt; or left by a git older than 2.37 outside a sparse checkout, is checked out from the index, never sent as it is here, because git hides its edits, which are often local settings or secrets: the VM turns the bit off for those paths (&lt;code&gt;skip.list&lt;/code&gt;), checks them out and turns it on again, and devvm names them (&lt;code&gt;clone_skip_worktree_kept&lt;/code&gt;). An assume-unchanged file&amp;rsquo;s edits are hidden from &lt;code&gt;git diff-files&lt;/code&gt; too, so it goes as the index has it. The VM&amp;rsquo;s files that the copy didn&amp;rsquo;t write over are named (&lt;code&gt;clone_kept_files&lt;/code&gt;): those at a path you changed or deleted here, and those elsewhere that differ from the index. When the copy keeps the VM&amp;rsquo;s &lt;code&gt;HEAD&lt;/code&gt;, the VM&amp;rsquo;s index stays, nothing of the working tree is applied, because your changes would apply to something else, and devvm says so (&lt;code&gt;clone_uncommitted_kept&lt;/code&gt;) instead of naming the files it would have left out.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-state-in-the-copy"&gt;The state in the copy&lt;span class="hx:absolute hx:-mt-20" id="the-state-in-the-copy"&gt;&lt;/span&gt;
&lt;a href="#the-state-in-the-copy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The copy sends what git keeps beside the refs and the index that you&amp;rsquo;d miss in the VM. Every file is read from the repo&amp;rsquo;s git dir, at the path &lt;code&gt;git rev-parse --git-path&lt;/code&gt; gives, so a linked worktree&amp;rsquo;s own are read, as a regular file only, never through a link, at most 16 MiB each and 64 MiB in all, and a folder is opened from its parent, refusing a link. &lt;code&gt;info/sparse-checkout&lt;/code&gt; and &lt;code&gt;info/attributes&lt;/code&gt; always go. &lt;code&gt;info/exclude&lt;/code&gt; goes too, added below the VM&amp;rsquo;s own, which holds the lines that keep a folder of repos&amp;rsquo; other repos out of each one&amp;rsquo;s &lt;code&gt;git status&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;An operation&amp;rsquo;s files go only while it&amp;rsquo;s in progress, and an operation is never told by a file that a reftable repo keeps as a ref:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A rebase, by its folder, &lt;code&gt;rebase-merge&lt;/code&gt; or &lt;code&gt;rebase-apply&lt;/code&gt;: the folder&amp;rsquo;s files, the pseudo-refs &lt;code&gt;REBASE_HEAD&lt;/code&gt; and &lt;code&gt;AUTO_MERGE&lt;/code&gt;, and the refs below &lt;code&gt;refs/rewritten/&lt;/code&gt;, with &lt;code&gt;ORIG_HEAD&lt;/code&gt; only during &lt;code&gt;git am&lt;/code&gt; (&lt;code&gt;rebase-apply/applying&lt;/code&gt;), whose &lt;code&gt;--abort&lt;/code&gt; needs it.&lt;/li&gt;
&lt;li&gt;A merge, by its &lt;code&gt;MERGE_HEAD&lt;/code&gt; file: &lt;code&gt;MERGE_HEAD&lt;/code&gt;, &lt;code&gt;MERGE_MSG&lt;/code&gt;, &lt;code&gt;MERGE_MODE&lt;/code&gt;, &lt;code&gt;MERGE_AUTOSTASH&lt;/code&gt; and &lt;code&gt;SQUASH_MSG&lt;/code&gt;, and the pseudo-ref &lt;code&gt;AUTO_MERGE&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A cherry-pick or a revert, by the pseudo-ref &lt;code&gt;CHERRY_PICK_HEAD&lt;/code&gt; or &lt;code&gt;REVERT_HEAD&lt;/code&gt;, or by the &lt;code&gt;sequencer&lt;/code&gt; folder: &lt;code&gt;MERGE_MSG&lt;/code&gt;, the folder&amp;rsquo;s files, and the pseudo-refs &lt;code&gt;CHERRY_PICK_HEAD&lt;/code&gt;, &lt;code&gt;REVERT_HEAD&lt;/code&gt; and &lt;code&gt;AUTO_MERGE&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Bisect, by its &lt;code&gt;BISECT_START&lt;/code&gt; file: the &lt;code&gt;BISECT_*&lt;/code&gt; files, &lt;code&gt;BISECT_FIRST_PARENT&lt;/code&gt; included, the pseudo-ref &lt;code&gt;BISECT_HEAD&lt;/code&gt;, and the refs below &lt;code&gt;refs/bisect/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A pseudo-ref is read with &lt;code&gt;git rev-parse -q --verify&lt;/code&gt;, and only when &lt;code&gt;--symbolic-full-name&lt;/code&gt; gives its own name back, so a branch or tag named &lt;code&gt;CHERRY_PICK_HEAD&lt;/code&gt; isn&amp;rsquo;t taken for one. It&amp;rsquo;s set in the VM with &lt;code&gt;git update-ref&lt;/code&gt;, never copied as a file, so a reftable repo, which keeps &lt;code&gt;CHERRY_PICK_HEAD&lt;/code&gt; and the rest as refs, works as a files one does. &lt;code&gt;ORIG_HEAD&lt;/code&gt; never goes otherwise, not even while an operation is in progress, because a reset made meanwhile points it at what it took back, such as a commit that held a secret, and a stopped rebase or a &lt;code&gt;sequencer&lt;/code&gt; folder left behind would carry it along.&lt;/p&gt;
&lt;p&gt;The pack carries the commits the operation needs, and only those that its files hold as object ids: the first word of &lt;code&gt;rebase-merge&lt;/code&gt;&amp;rsquo;s &lt;code&gt;onto&lt;/code&gt;, &lt;code&gt;orig-head&lt;/code&gt;, &lt;code&gt;stopped-sha&lt;/code&gt;, &lt;code&gt;amend&lt;/code&gt;, &lt;code&gt;autostash&lt;/code&gt; and &lt;code&gt;squash-onto&lt;/code&gt;, every id in its &lt;code&gt;update-refs&lt;/code&gt;, the first two of each line of its &lt;code&gt;rewritten-list&lt;/code&gt; and &lt;code&gt;rewritten-pending&lt;/code&gt;, &lt;code&gt;rebase-apply&lt;/code&gt;&amp;rsquo;s &lt;code&gt;onto&lt;/code&gt;, &lt;code&gt;orig-head&lt;/code&gt; and &lt;code&gt;abort-safety&lt;/code&gt;, each line of &lt;code&gt;MERGE_HEAD&lt;/code&gt;, &lt;code&gt;MERGE_AUTOSTASH&lt;/code&gt;, &lt;code&gt;sequencer&lt;/code&gt;&amp;rsquo;s &lt;code&gt;head&lt;/code&gt; and &lt;code&gt;abort-safety&lt;/code&gt;, &lt;code&gt;BISECT_EXPECTED_REV&lt;/code&gt;, and the ids on &lt;code&gt;BISECT_LOG&lt;/code&gt;&amp;rsquo;s lines that mark a commit good, bad, skipped, or with the terms &lt;code&gt;BISECT_TERMS&lt;/code&gt; names. Each must be an object the repo has, which &lt;code&gt;git cat-file --batch-check&lt;/code&gt; says. Free text never counts, so a commit that only a merge message or a revert&amp;rsquo;s message names stays on this machine. A new state file that holds object ids needs its entry in that list. The commits the todo lists still have to pick, &lt;code&gt;rebase-merge/git-rebase-todo&lt;/code&gt; and &lt;code&gt;sequencer/todo&lt;/code&gt;, are never scanned into the pack: devvm resolves each and names those that the copy&amp;rsquo;s refs and the ids above don&amp;rsquo;t reach (&lt;code&gt;clone_todo_missing&lt;/code&gt;), as that step will fail in the VM.&lt;/p&gt;
&lt;p&gt;The stash goes as its entries, oldest first, each with its message, read with &lt;code&gt;git reflog show --format='%H %gs' refs/stash&lt;/code&gt;, the newest 1,000, the rest named (&lt;code&gt;clone_stash_over_kept&lt;/code&gt;), and the VM stores each with &lt;code&gt;git stash store -m&lt;/code&gt;, the commits it was made on with it. An entry with untracked files, a third parent, is taken for one of &lt;code&gt;git stash --all&lt;/code&gt; and stays, named (&lt;code&gt;clone_stash_all_kept&lt;/code&gt;), because it may hold ignored files, such as &lt;code&gt;.env&lt;/code&gt;, when any of those files is a &lt;code&gt;.gitignore&lt;/code&gt;, when the entry changes a &lt;code&gt;.gitignore&lt;/code&gt; (&lt;code&gt;git stash --all&lt;/code&gt; takes back an uncommitted edit of one, so the rules that ignored a file are gone from the working tree), or when the ignore rules ignore any of its untracked files (&lt;code&gt;git check-ignore --no-index&lt;/code&gt;), as they are now or as the entry&amp;rsquo;s own &lt;code&gt;.gitignore&lt;/code&gt; files had them, which devvm writes into a folder of their own to check against. The check errs toward keeping an entry back. A linked worktree&amp;rsquo;s copy sends no stash, which is the whole repo&amp;rsquo;s. The VM records each entry it stores in &lt;code&gt;.git/devvm-seeded-stash&lt;/code&gt;, so a copy that runs again skips as many as the record has, an entry that the stash holds twice is stored twice, and the clone check leaves those entries out of the VM&amp;rsquo;s own.&lt;/p&gt;
&lt;p&gt;The script that reads the clone&amp;rsquo;s state prints every other entry as &lt;code&gt;SHA stash@{N}&lt;/code&gt;, devvm names it as &lt;code&gt;stash-N&lt;/code&gt; when this repo doesn&amp;rsquo;t have its commit, and fetches it by that commit. &lt;code&gt;devvm clone fetch&lt;/code&gt; does the same, with a script of its own whose lines devvm takes only for a detached &lt;code&gt;HEAD&lt;/code&gt;&amp;rsquo;s commit and stash entries, so the VM can&amp;rsquo;t have it save a branch of another name, and an entry it can&amp;rsquo;t fetch is named, the others saved. For rm and &lt;code&gt;clone off&lt;/code&gt;, an entry that can&amp;rsquo;t be fetched keeps the VM. A stash entry is never saved with its untracked files, because &lt;code&gt;git stash apply&lt;/code&gt; writes them, ignored ones too, such as a virtualenv&amp;rsquo;s &lt;code&gt;sitecustomize.py&lt;/code&gt; that Python runs on its own, while &lt;code&gt;git stash show&lt;/code&gt; doesn&amp;rsquo;t list them. devvm makes the entry again with &lt;code&gt;git commit-tree&lt;/code&gt;, from its tree and its first two parents, with its own message, author and committer, so the same entry is always the same commit, and saves that as &lt;code&gt;saved/devvm/stash-N&lt;/code&gt;. The untracked files go to &lt;code&gt;saved/devvm/stash-N-untracked&lt;/code&gt;, and devvm names them, and those that git on this machine ignores (&lt;code&gt;clone_stash_untracked&lt;/code&gt;, &lt;code&gt;clone_stash_untracked_ignored&lt;/code&gt;). Every fetch from a VM checks each object it receives (&lt;code&gt;transfer.fsckObjects&lt;/code&gt;). No ref names an older entry, and devvm&amp;rsquo;s ssh passes no &lt;code&gt;GIT_PROTOCOL&lt;/code&gt; to the VM, so its &lt;code&gt;git upload-pack&lt;/code&gt; speaks protocol v0, which refuses a commit no ref names unless the fetch runs it with &lt;code&gt;uploadpack.allowAnySHA1InWant&lt;/code&gt;, as devvm&amp;rsquo;s does. That only lets the host ask the VM for its own objects. The stubs drop &lt;code&gt;GIT_PROTOCOL&lt;/code&gt; too, so the tests fetch over v0.&lt;/p&gt;
&lt;p&gt;The state goes in only when the copy sets &lt;code&gt;HEAD&lt;/code&gt;, as the working tree does, since an operation applies to the commit it started from, and so do the refs of an operation, below &lt;code&gt;refs/rewritten/&lt;/code&gt; and &lt;code&gt;refs/bisect/&lt;/code&gt;. The stash goes in either way.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-settings-in-the-copy"&gt;The settings in the copy&lt;span class="hx:absolute hx:-mt-20" id="the-settings-in-the-copy"&gt;&lt;/span&gt;
&lt;a href="#the-settings-in-the-copy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The copy reads the repo&amp;rsquo;s own config with &lt;code&gt;git config --local --no-includes --null --list&lt;/code&gt;, and, when &lt;code&gt;extensions.worktreeConfig&lt;/code&gt; is on, the worktree&amp;rsquo;s &lt;code&gt;config.worktree&lt;/code&gt; after it with &lt;code&gt;--worktree&lt;/code&gt;, where &lt;code&gt;git sparse-checkout&lt;/code&gt; writes its settings, so neither your global config nor an included file goes. It sends only the keys of an allowlist, each value checked, never the config as a file, and a key written with no value, which git reads as true, goes as &lt;code&gt;true&lt;/code&gt;. The VM sets them with &lt;code&gt;git config --add&lt;/code&gt;, each key unset first, then writes &lt;code&gt;.git/devvm-seeded-config&lt;/code&gt;, so a copy that runs again sets nothing over what the VM changed since:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;remote.&amp;lt;name&amp;gt;.url&lt;/code&gt;, as &lt;code&gt;git remote get-url --all&lt;/code&gt; gives them, with &lt;code&gt;insteadOf&lt;/code&gt; applied, and &lt;code&gt;pushurl&lt;/code&gt;, when &lt;code&gt;git remote get-url --push --all&lt;/code&gt; gives other URLs, as it does with a push URL or a &lt;code&gt;pushInsteadOf&lt;/code&gt;. Each URL is cleaned: an &lt;code&gt;http&lt;/code&gt; or &lt;code&gt;https&lt;/code&gt; URL without its user name, password, query or fragment, any of which can be a token; an &lt;code&gt;ssh://&lt;/code&gt;, &lt;code&gt;git+ssh://&lt;/code&gt; or &lt;code&gt;ssh+git://&lt;/code&gt; URL without its password, query or fragment, its user kept, as &lt;code&gt;git@&lt;/code&gt; is a name, not a secret; a scp-like &lt;code&gt;[user@]host:path&lt;/code&gt; as it is; and a &lt;code&gt;file://&lt;/code&gt; URL or a path as it is. git reads a scp-like URL&amp;rsquo;s host up to its first colon, past a bracketed host such as &lt;code&gt;[::1]&lt;/code&gt;, so its user, before an &lt;code&gt;@&lt;/code&gt; there, holds no colon, and one whose path has an &lt;code&gt;@&lt;/code&gt; and then a colon, as in &lt;code&gt;user:token@host:path&lt;/code&gt;, which git reads as the host &lt;code&gt;user&lt;/code&gt; and a path holding the token, stays. Any other kind, such as &lt;code&gt;git://&lt;/code&gt; or a transport helper&amp;rsquo;s &lt;code&gt;ext::&lt;/code&gt;, stays, named (&lt;code&gt;clone_urls_kept&lt;/code&gt;), and a remote with no URL that goes stays with the rest of its settings. A remote that reaches a devvm VM stays, as its refs do, and so does a push URL that reaches one. A remote whose push URLs all stay goes without them, so &lt;code&gt;git push&lt;/code&gt; in the VM pushes to its URL, named (&lt;code&gt;clone_push_urls_kept&lt;/code&gt;). A remote whose URLs &lt;code&gt;git remote get-url&lt;/code&gt; can&amp;rsquo;t give stays, named (&lt;code&gt;clone_urls_unread&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;remote.&amp;lt;name&amp;gt;.fetch&lt;/code&gt;, &lt;code&gt;promisor&lt;/code&gt;, &lt;code&gt;partialclonefilter&lt;/code&gt; and &lt;code&gt;tagOpt&lt;/code&gt;, for a remote that goes.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;branch.&amp;lt;name&amp;gt;.remote&lt;/code&gt;, &lt;code&gt;merge&lt;/code&gt;, &lt;code&gt;rebase&lt;/code&gt; and &lt;code&gt;pushRemote&lt;/code&gt;, for a branch the copy sends, so the VM of a worktree learns no other branch&amp;rsquo;s name, but an upstream on a remote that stays.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;submodule.&amp;lt;name&amp;gt;.url&lt;/code&gt;, resolved with &lt;code&gt;git ls-remote --get-url&lt;/code&gt; and cleaned as a remote&amp;rsquo;s, and its &lt;code&gt;active&lt;/code&gt;, &lt;code&gt;branch&lt;/code&gt; and &lt;code&gt;update&lt;/code&gt;, but an &lt;code&gt;update&lt;/code&gt; that runs a command (&lt;code&gt;!command&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;core.sparseCheckout&lt;/code&gt;, &lt;code&gt;core.sparseCheckoutCone&lt;/code&gt; and &lt;code&gt;index.sparse&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;core.hooksPath&lt;/code&gt;, the last one, when it&amp;rsquo;s a relative folder inside the repo, never through &lt;code&gt;..&lt;/code&gt; or a &lt;code&gt;.git&lt;/code&gt; part, and not one that git expands, as it does &lt;code&gt;~/&lt;/code&gt; and &lt;code&gt;%(prefix)/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;user.name&lt;/code&gt; and &lt;code&gt;user.email&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Nothing else goes, such as &lt;code&gt;credential.*&lt;/code&gt;, &lt;code&gt;http.*&lt;/code&gt; and its extra headers, &lt;code&gt;url.*.insteadOf&lt;/code&gt;, which the URLs have applied already, &lt;code&gt;core.sshCommand&lt;/code&gt;, &lt;code&gt;core.fsmonitor&lt;/code&gt;, &lt;code&gt;filter.*&lt;/code&gt;, &lt;code&gt;include*&lt;/code&gt;, &lt;code&gt;alias.*&lt;/code&gt;, or the keys that describe this machine&amp;rsquo;s filesystem, &lt;code&gt;core.ignorecase&lt;/code&gt;, &lt;code&gt;precomposeunicode&lt;/code&gt;, &lt;code&gt;filemode&lt;/code&gt; and &lt;code&gt;symlinks&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The hooks go as they are, and only as git here runs them, from the common dir&amp;rsquo;s &lt;code&gt;hooks&lt;/code&gt; folder, which &lt;code&gt;git rev-parse --git-path hooks&lt;/code&gt; can&amp;rsquo;t give, as it gives &lt;code&gt;/dev/null&lt;/code&gt; under devvm&amp;rsquo;s own git&amp;rsquo;s &lt;code&gt;core.hooksPath&lt;/code&gt;. They go when the &lt;code&gt;core.hooksPath&lt;/code&gt; git uses is none, &lt;code&gt;.git/hooks&lt;/code&gt; or that folder. It&amp;rsquo;s the last of the repo&amp;rsquo;s own config and its worktree&amp;rsquo;s, includes followed (&lt;code&gt;git config --includes --show-scope --get-all&lt;/code&gt;, its &lt;code&gt;local&lt;/code&gt; and &lt;code&gt;worktree&lt;/code&gt; ones), so an include after the repo&amp;rsquo;s own wins, as in git, else your global or system config&amp;rsquo;s, read from the files that &lt;code&gt;GIT_CONFIG_GLOBAL&lt;/code&gt; and &lt;code&gt;GIT_CONFIG_SYSTEM&lt;/code&gt; name when they&amp;rsquo;re set. In a linked worktree, whose &lt;code&gt;.git&lt;/code&gt; is a file, a relative &lt;code&gt;.git/hooks&lt;/code&gt; names no folder, so git there runs no hook, and none goes. A &lt;code&gt;core.hooksPath&lt;/code&gt; elsewhere inside the repo goes as the setting alone: the hooks in it are files of the working tree, so the tracked ones reach the VM with the checkout, and the untracked ones, such as husky&amp;rsquo;s &lt;code&gt;_&lt;/code&gt; folder, stay, as every untracked file does. One outside the repo, or one an included file sets, stays, named (&lt;code&gt;clone_hooks_path_kept&lt;/code&gt;), and no hook goes. The &lt;code&gt;hooks&lt;/code&gt; folder is opened from the common dir, never through a link, and one that&amp;rsquo;s missing, a link or unreadable is named (&lt;code&gt;clone_hooks_dir_kept&lt;/code&gt;). Only files named as git&amp;rsquo;s hooks go, the names devvm&amp;rsquo;s own git turns off, each a regular file of at most 1 MiB and 16 MiB in all. A link, a folder or a bigger file stays, named (&lt;code&gt;clone_hooks_kept&lt;/code&gt;). In the VM, a hook goes into the git dir&amp;rsquo;s &lt;code&gt;hooks&lt;/code&gt; folder only where the VM has no file of that name, with its executable bit.&lt;/p&gt;
&lt;p&gt;The settings and hooks go in last, after the checkout, and the script&amp;rsquo;s git runs with &lt;code&gt;core.hooksPath=/dev/null&lt;/code&gt;, so neither a hook the copy brings nor one of the VM&amp;rsquo;s own runs during the copy, and none can fail it or a copy that runs again.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-record-of-what-was-copied"&gt;The record of what was copied&lt;span class="hx:absolute hx:-mt-20" id="the-record-of-what-was-copied"&gt;&lt;/span&gt;
&lt;a href="#the-record-of-what-was-copied" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;So that &lt;code&gt;devvm rm&lt;/code&gt; and &lt;code&gt;devvm clone off&lt;/code&gt; don&amp;rsquo;t take your own uncommitted changes for the VM&amp;rsquo;s work, the copy leaves a record of them in the VM&amp;rsquo;s repo, &lt;code&gt;.git/devvm-seeded-tree&lt;/code&gt;, written with the index. It covers each path that &lt;code&gt;git status&lt;/code&gt; in the VM would list once the copy is in: those whose staged entry isn&amp;rsquo;t &lt;code&gt;HEAD&lt;/code&gt;&amp;rsquo;s, found with &lt;code&gt;git diff-index --cached&lt;/code&gt; on the normalised index, and those whose working copy differs. For each path it holds what devvm put there: the blob of the working copy, which devvm hashes as it sends the file, with a mark for an executable file, &lt;code&gt;=&lt;/code&gt; for one checked out from the index, &lt;code&gt;dir&lt;/code&gt; for a gitlink&amp;rsquo;s empty folder or &lt;code&gt;-&lt;/code&gt; for none, and the path&amp;rsquo;s index entries, each with its mode, blob and stage.&lt;/p&gt;
&lt;p&gt;The clone check reads the record back in the VM. For each path, git in the VM hashes the working copy with &lt;code&gt;git hash-object --no-filters&lt;/code&gt;, or the link&amp;rsquo;s target for a symbolic link, or, for one checked out from the index, asks &lt;code&gt;git diff-files --quiet&lt;/code&gt; after a refresh whether it&amp;rsquo;s still the index&amp;rsquo;s, so a file that &lt;code&gt;info/attributes&lt;/code&gt; converts, such as with &lt;code&gt;eol=crlf&lt;/code&gt;, matches as git checked it out, and it lists the index entries with &lt;code&gt;git ls-files --format&lt;/code&gt;, and the VM prints the paths whose state matches the record. devvm leaves the &lt;code&gt;git status&lt;/code&gt; lines that name only those paths out of what it counts and shows, so a path counts once the VM changes its content, its executable bit or what&amp;rsquo;s staged for it. A deletion that&amp;rsquo;s still deleted matches. Untracked files&amp;rsquo; lines always count, as the copy sends none.&lt;/p&gt;
&lt;p&gt;The record is the VM&amp;rsquo;s side of the copy, not a comparison with the repo here, so it stays right when your working copy changes after the copy, and it needs nothing in devvm&amp;rsquo;s own state. The VM can write the record, and it can answer for it anything it likes, but all a forged record or answer can do is make the VM&amp;rsquo;s own work look unchanged, so that &lt;code&gt;devvm rm&lt;/code&gt; deletes it without asking, which hurts only the VM&amp;rsquo;s work. A VM without the record, such as one an older devvm made, or whose git has no &lt;code&gt;ls-files --format&lt;/code&gt; (before 2.38), counts every change as before.&lt;/p&gt;</description></item><item><title>Security model</title><link>https://next.devvm.dev/docs/internals/security/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/security/</guid><description>
&lt;p&gt;devvm treats everything in a VM as untrusted, including a coding agent with root, because the VM&amp;rsquo;s user has passwordless sudo. This page explains how devvm keeps that code away from the rest of your machine. &lt;a href="https://next.devvm.dev/docs/safety/"&gt;Staying safe&lt;/a&gt; lists &lt;a href="https://next.devvm.dev/docs/safety/#what-a-vm-can-reach"&gt;what a VM can reach&lt;/a&gt; and the habits that &lt;a href="https://next.devvm.dev/docs/safety/#the-habits"&gt;keep you safe&lt;/a&gt;, and &lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/"&gt;Attack vectors&lt;/a&gt; goes through common attacks one by one and lists what devvm leaves open.&lt;/p&gt;
&lt;p&gt;All of it rests on the VM&amp;rsquo;s boundary. &lt;a href="https://next.devvm.dev/docs/internals/processes/"&gt;Processes&lt;/a&gt; goes through each process on this machine that a VM&amp;rsquo;s bytes reach, what it holds and how it&amp;rsquo;s confined, and lists the listeners a VM reaches.&lt;/p&gt;
&lt;h2 data-hextra-search-id="what-devvm-protects-and-how"&gt;What devvm protects, and how&lt;span class="hx:absolute hx:-mt-20" id="what-devvm-protects-and-how"&gt;&lt;/span&gt;
&lt;a href="#what-devvm-protects-and-how" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;h3 data-hextra-search-id="only-the-project-folder"&gt;Only the project folder&lt;span class="hx:absolute hx:-mt-20" id="only-the-project-folder"&gt;&lt;/span&gt;
&lt;a href="#only-the-project-folder" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A VM mounts its project folder read-write at the same path. The only other things it mounts from the host are the shared tools and its &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#mounts"&gt;agents&amp;rsquo; config folders&lt;/a&gt;, both read-only, so it never mounts your home folder, which Lima&amp;rsquo;s own templates do. A &lt;a href="https://next.devvm.dev/docs/using/clone/"&gt;&lt;code&gt;--clone&lt;/code&gt;&lt;/a&gt; VM doesn&amp;rsquo;t mount the project folder either. It has its own clone, and its work reaches the repo only when you fetch it. When you run devvm in a subfolder and it uses the project folder&amp;rsquo;s VM, that VM mounts nothing more than it already did (&lt;a href="https://next.devvm.dev/docs/internals/overview/#a-subfolders-vm"&gt;a subfolder&amp;rsquo;s VM&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;devvm refuses a project folder that would hand the VM more than the project:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A folder that is or holds your home folder, devvm&amp;rsquo;s settings (&lt;code&gt;~/.config/devvm&lt;/code&gt;), its state (&lt;code&gt;~/.local/share/devvm&lt;/code&gt;, which holds its binaries and other VMs&amp;rsquo; disks) or its Lima home (&lt;code&gt;unsafe_folder&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;A folder inside devvm&amp;rsquo;s own folders (&lt;code&gt;unsafe_folder_inside&lt;/code&gt;). A VM in &lt;code&gt;~/.config/devvm/layers&lt;/code&gt; could rewrite the scripts that every image build runs, and a VM in devvm&amp;rsquo;s data folder could rewrite the files devvm runs on the host.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;devvm compares each of these folders with the project folder both by path and by the folder itself, so it also catches a project folder, or a folder above it, that is the same folder as one of devvm&amp;rsquo;s by device and inode, or the other way round. So on a volume that ignores case, as a Mac&amp;rsquo;s does by default, a project at &lt;code&gt;~/.Config/devvm/layers&lt;/code&gt; is inside &lt;code&gt;~/.config/devvm&lt;/code&gt;, although the two paths differ. &lt;code&gt;--unsafe-folder&lt;/code&gt; mounts such a folder anyway, and devvm says so. A &lt;code&gt;--clone&lt;/code&gt; VM mounts nothing, so devvm doesn&amp;rsquo;t refuse its folder.&lt;/p&gt;
&lt;p&gt;A project folder inside a coding agent&amp;rsquo;s folder in your home folder, such as &lt;code&gt;~/.claude/skills/mine&lt;/code&gt;, or one that holds an agent&amp;rsquo;s folder, such as &lt;code&gt;~/.pi&lt;/code&gt; for pi&amp;rsquo;s &lt;code&gt;~/.pi/agent&lt;/code&gt;, gives its VM read-write access to that agent&amp;rsquo;s settings on this machine, such as Claude Code&amp;rsquo;s hooks, which run on the host. devvm doesn&amp;rsquo;t refuse such a folder, because working on a skill in place is common, but each launch of a VM that mounts it warns once, naming every agent&amp;rsquo;s folder it overlaps (&lt;code&gt;project_agent_folder&lt;/code&gt;). devvm finds them by the same comparison and also by the agent folder&amp;rsquo;s name, so a folder that the VM could make later counts. A &lt;code&gt;--clone&lt;/code&gt; VM gets no warning.&lt;/p&gt;
&lt;h3 data-hextra-search-id="one-vm-per-folder"&gt;One VM per folder&lt;span class="hx:absolute hx:-mt-20" id="one-vm-per-folder"&gt;&lt;/span&gt;
&lt;a href="#one-vm-per-folder" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A VM belongs to the folder it was made for, which devvm knows by its path and by the folder itself: its device and inode, and its birth time where the file system keeps one. macOS numbers its disks&amp;rsquo; devices in the order they appear at boot, so after a restart an unchanged folder can be on a device with another number. devvm still takes it as the same folder when it&amp;rsquo;s at the same path, with no link on that path, and has the same inode and birth time on a file system that never gives a new folder a deleted one&amp;rsquo;s inode number. That&amp;rsquo;s safe because nothing in a VM can give a folder an inode and a birth time, and a copy that keeps both, such as a snapshot, is at another path unless you mount it at the folder&amp;rsquo;s own. devvm reads the folder&amp;rsquo;s identity from the folder opened at its path with no link followed, so a link that a VM puts there for a moment can&amp;rsquo;t pass such a copy off as the folder. For a VM whose state records the folder&amp;rsquo;s volume (below), the folder on the renumbered disk must also be on that volume when devvm can tell it, so a copy of the disk that has a volume ID of its own but keeps the folder&amp;rsquo;s inode and birth time, mounted at the folder&amp;rsquo;s own path, is another folder. A copy that keeps the volume ID too, as &lt;code&gt;dd&lt;/code&gt; makes, still matches, as below. The VM&amp;rsquo;s next start records the folder on its device as it is now, before the start mounts it, and never when the folder is on another volume (&lt;a href="https://next.devvm.dev/docs/internals/overview/#an-existing-vm"&gt;an existing VM&lt;/a&gt;). When you delete a folder and make it again at the same path, or clone another repo where an old one was, devvm refuses to give the new folder the old folder&amp;rsquo;s VM, so the new folder never quietly gets what&amp;rsquo;s in the old VM&amp;rsquo;s disk. &lt;code&gt;devvm rm&lt;/code&gt; deletes the old VM and &lt;code&gt;devvm adopt&lt;/code&gt; gives it to the new folder, and each does so only after you confirm (&lt;a href="https://next.devvm.dev/docs/using/vms/#a-folder-made-again"&gt;a folder made again&lt;/a&gt;). When you move or rename the folder, the folder at its new path is the same folder, so devvm offers it the VM, and moves the VM only after you confirm (&lt;a href="https://next.devvm.dev/docs/using/vms/#a-moved-or-renamed-folder"&gt;a moved or renamed folder&lt;/a&gt;). It never offers a VM to a copy, to a folder another user owns, or on a file system that may give a new folder the inode number of a deleted one, so a VM never moves to a folder that only looks like its own. The folders that get the offer are those whose file system records a birth time: on macOS, folders on APFS and HFS+, and on Linux, folders on ext4, XFS, Btrfs, tmpfs, ZFS, F2FS and bcachefs. Folders on network shares, FUSE file systems and USB drives formatted with FAT or exFAT never get the offer.&lt;/p&gt;
&lt;p&gt;A folder that moved, and whose disk was numbered anew since, is on another device at another path, so its device, inode and birth time alone don&amp;rsquo;t name it. So the VM&amp;rsquo;s state also records the folder&amp;rsquo;s volume, which no renumbering changes. On macOS that&amp;rsquo;s its volume UUID, as &lt;code&gt;diskutil info&lt;/code&gt; gives it for the folder&amp;rsquo;s mount point, and on Linux it&amp;rsquo;s the file system&amp;rsquo;s own ID (&lt;code&gt;f_fsid&lt;/code&gt;) on ext4, Btrfs, where each subvolume has its own, and ZFS. XFS, F2FS and tmpfs derive that ID from the device or the mount, so a folder on them, or on any other file system, records no volume and keeps the rule above. devvm reads the folder&amp;rsquo;s mount point, its device and its file system&amp;rsquo;s ID from the folder opened with no link on its path, and on macOS it takes &lt;code&gt;diskutil&lt;/code&gt;&amp;rsquo;s answer only when it names that mount point and that device, so a volume mounted there meanwhile isn&amp;rsquo;t taken for it. A folder on a volume mounted read-only, or a snapshot, records no volume and matches none. The state records the volume bound to the folder&amp;rsquo;s inode and birth time, so a record that an older devvm left beside a folder it moved, whose inode is another, names no volume and is recorded again. devvm offers a moved folder the VM when its volume, inode and birth time are the recorded ones and the conditions above hold. When the record&amp;rsquo;s volume is marked unchecked, devvm offers the VM only once it has read the volume and found the one recorded. It looks the volume up only once the inode and birth time match. A command looks each mount&amp;rsquo;s volume up once, and looks up none after one lookup fails. A lookup has 1 second when a launch records it or when &lt;code&gt;devvm ls&lt;/code&gt; and &lt;code&gt;devvm space&lt;/code&gt; check whether a folder is gone, and 5 seconds when devvm makes, adopts or moves a VM, offers a move, or checks a renumbered folder at its own path. A lookup that fails or takes longer records nothing, and a later launch tries again. When devvm can&amp;rsquo;t tell a renumbered folder&amp;rsquo;s volume, it judges the folder by the rule above, as one whose state records no volume. The launch then records the folder&amp;rsquo;s new device with the volume it had, marked unchecked (&lt;code&gt;folder_unchecked&lt;/code&gt; in &lt;code&gt;vm.json&lt;/code&gt;), so each later launch looks the volume up again and takes the folder for another one when it&amp;rsquo;s on another volume, until a lookup finds the volume recorded and clears the mark. On Linux, where the folder&amp;rsquo;s volume is read in the process at no cost, every launch compares it with the volume recorded, so a copy with a volume ID of its own, such as a Btrfs snapshot or a ZFS clone, mounted at the folder&amp;rsquo;s path is another folder even on the device the original had. A copy made with &lt;code&gt;dd&lt;/code&gt; or an LVM snapshot of ext4 keeps the volume&amp;rsquo;s UUID, and so its ID, as above. A Btrfs snapshot rolled back at the folder&amp;rsquo;s path is another subvolume, with an ID of its own, so its folder is another folder, which &lt;code&gt;devvm adopt&lt;/code&gt; gives the VM, and so is the folder after you give its volume a new UUID, as &lt;code&gt;tune2fs -U&lt;/code&gt; does. devvm reads the folder&amp;rsquo;s owner, which the offer of a move needs, from the same open folder as its identity, so the folder that&amp;rsquo;s checked as yours is the one whose identity devvm matches and records. It reads the owner as the system reports it, so on a macOS volume that ignores ownership, as disk images and external disks often do, every folder is yours, and that check tells nothing there. A clone of a disk, by &lt;code&gt;asr&lt;/code&gt; or &lt;code&gt;dd&lt;/code&gt;, or an LVM snapshot mounted for writing, keeps the volume, inode and birth time, so its copy of the folder at another path matches too, when nothing is left at the old path, as at the same path it already did. A volume ID can also be forged by anyone who can write a volume&amp;rsquo;s metadata, which takes root, or a disk or disk image that someone crafted and you attach. Such a forgery gets no more than a copy that keeps all three does, which is an offer of the VM that you confirm at another path, and the VM itself at the folder&amp;rsquo;s own path, where it has to be mounted. Nothing in a VM can make one (&lt;a href="https://next.devvm.dev/docs/contributing/design/#a-folders-volume"&gt;a folder&amp;rsquo;s volume&lt;/a&gt;). A folder whose state records its volume is also on its disk when the first folder above its old path is on that volume, so a renumbered disk isn&amp;rsquo;t taken for an unmounted one (&amp;ldquo;not connected&amp;rdquo;). The state records the volume when the VM is made, adopted or moved, and, for a VM whose state doesn&amp;rsquo;t record one yet, at its first launch that finds its folder.&lt;/p&gt;
&lt;h3 data-hextra-search-id="a-projects-devcontainerjson"&gt;A project&amp;rsquo;s devcontainer.json&lt;span class="hx:absolute hx:-mt-20" id="a-projects-devcontainerjson"&gt;&lt;/span&gt;
&lt;a href="#a-projects-devcontainerjson" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A project&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/using/devcontainer/"&gt;&lt;code&gt;devcontainer.json&lt;/code&gt;&lt;/a&gt; belongs to the project, and so to the VM, which can rewrite it for the folder&amp;rsquo;s next VM, or for the VM itself when you run &lt;code&gt;devvm update&lt;/code&gt;. devvm reads it only when it makes a VM, new or again, and uses only what it can do inside the VM. Nothing in it runs on this machine, so &lt;code&gt;initializeCommand&lt;/code&gt; never runs. Nothing in it reaches this machine&amp;rsquo;s files, because devvm doesn&amp;rsquo;t follow a link out of the folder, or this machine&amp;rsquo;s environment, because devvm refuses &lt;code&gt;${localEnv:…}&lt;/code&gt; before it makes anything. It can&amp;rsquo;t add a mount or change the VM&amp;rsquo;s network tier or other confinement.&lt;/p&gt;
&lt;p&gt;Its commands run in the VM as the VM&amp;rsquo;s user, confined like anything else in it. Its features can only be devvm&amp;rsquo;s own layers, so devvm never fetches or runs a feature&amp;rsquo;s script, and it refuses &lt;code&gt;docker-outside-of-docker&lt;/code&gt;. devvm uses its &lt;code&gt;image&lt;/code&gt; only when the image&amp;rsquo;s registry gives it to anyone who asks anonymously, so it never uses a container image that only your Docker has or that only your registry login reaches. It refuses a registry named &lt;code&gt;localhost&lt;/code&gt; or by an address that isn&amp;rsquo;t the internet&amp;rsquo;s, and its lookup connects only to the internet&amp;rsquo;s addresses, so it never uses an image on this machine or its network, except through a company proxy, which resolves the registry&amp;rsquo;s name itself (&lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#spreading-beyond-the-vm"&gt;attack vectors&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;An existing VM never changes when the file does, until you run &lt;code&gt;devvm update&lt;/code&gt;, which says it reads the file again and asks before it makes the VM again. The file read again is held to the same refusals as a new VM&amp;rsquo;s, and it can&amp;rsquo;t replace a base you chose with &lt;code&gt;--from&lt;/code&gt;, bring back a port you took out with &lt;code&gt;devvm ports rm&lt;/code&gt;, or change its network tier, size, SSH agent or &lt;code&gt;.git&lt;/code&gt; protection, which devvm keeps.&lt;/p&gt;
&lt;p&gt;Its &lt;code&gt;forwardPorts&lt;/code&gt; are added to the VM&amp;rsquo;s ports, as &lt;code&gt;devvm ports add&lt;/code&gt; adds them, even beyond a list you narrowed, both when devvm makes the VM and when &lt;code&gt;devvm update&lt;/code&gt; reads the file again. They go through the one port forwarder, so they listen on this machine&amp;rsquo;s loopback alone (127.0.0.1 and ::1), never take a port that a program on this machine has, and never take a port another VM forwards (&lt;a href="https://next.devvm.dev/docs/internals/ports/"&gt;port forwarding&lt;/a&gt;). What a cloned repo&amp;rsquo;s file opens is so only what &lt;code&gt;devvm ports add&lt;/code&gt; could open, but it reaches whatever on this machine connects to those ports, a browser&amp;rsquo;s pages included (&lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#network"&gt;attack vectors&lt;/a&gt;).&lt;/p&gt;
&lt;h3 data-hextra-search-id="read-only-and-confined-builds"&gt;Read-only and confined builds&lt;span class="hx:absolute hx:-mt-20" id="read-only-and-confined-builds"&gt;&lt;/span&gt;
&lt;a href="#read-only-and-confined-builds" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;devvm builds images with nothing from the host mounted, and it confines their builds (&lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;details&lt;/a&gt;). Every build reaches the internet. On macOS it can&amp;rsquo;t reach the host&amp;rsquo;s loopback, but it reaches your LAN, the host&amp;rsquo;s own address on it included, and on Linux it reaches the host&amp;rsquo;s loopback too. Credentials never go into images.&lt;/p&gt;
&lt;p&gt;A tool build writes into a folder of its own and never into the shared tools, and devvm checks each tool image, moves it in and writes its record, with its hash (&lt;a href="https://next.devvm.dev/docs/internals/images/#building-tools"&gt;details&lt;/a&gt;). Tool images for glibc, which any VM may mount, build only in devvm&amp;rsquo;s own Ubuntu base, never in a &lt;code&gt;--from&lt;/code&gt; image, and musl ones are keyed by the digest of the &lt;code&gt;--from&lt;/code&gt; base they build in, so a container image&amp;rsquo;s code never reaches another VM&amp;rsquo;s tools. devvm&amp;rsquo;s VMs live in a Lima home of their own, so Lima settings you made for other VMs never reach them. devvm also refuses a VM with a network it didn&amp;rsquo;t give the VM, because that network would reach around the proxy (&lt;a href="https://next.devvm.dev/docs/internals/lima/#a-lima-home-of-its-own"&gt;details&lt;/a&gt;).&lt;/p&gt;
&lt;h3 data-hextra-search-id="git-protection"&gt;&lt;code&gt;.git&lt;/code&gt; protection&lt;span class="hx:absolute hx:-mt-20" id="git-protection"&gt;&lt;/span&gt;
&lt;a href="#git-protection" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The VM can&amp;rsquo;t change the parts of &lt;code&gt;.git&lt;/code&gt; that run code on the host, because devvm locks hooks and config. On macOS it sets a flag the VM can&amp;rsquo;t clear, and on Linux it makes them read-only in the user namespace that QEMU runs in. A Linux host whose kernel doesn&amp;rsquo;t let devvm use a user namespace has no locks, and devvm only watches &lt;code&gt;.git&lt;/code&gt; there (&lt;a href="https://next.devvm.dev/docs/internals/git-protection/"&gt;details&lt;/a&gt;).&lt;/p&gt;
&lt;h3 data-hextra-search-id="network-tiers"&gt;Network tiers&lt;span class="hx:absolute hx:-mt-20" id="network-tiers"&gt;&lt;/span&gt;
&lt;a href="#network-tiers" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A VM on a confined tier, internet, allowlist or none, reaches nothing but its own proxy on the host and the &lt;a href="https://next.devvm.dev/docs/internals/ports/#links-between-vms"&gt;links&lt;/a&gt; you added to it. On macOS its Lima process runs under a macOS sandbox, and on Linux QEMU&amp;rsquo;s network is restricted (&lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;details&lt;/a&gt;). Even root in the VM can&amp;rsquo;t get around that. A link&amp;rsquo;s connections don&amp;rsquo;t use the VM&amp;rsquo;s network, because this machine carries them over ssh, and only to a port that another VM on the same tier or a stricter one publishes. An open VM runs on its backend&amp;rsquo;s own network, and its proxy applies no rules.&lt;/p&gt;
&lt;p&gt;The proxy applies the tier&amp;rsquo;s rules, and it refuses the host&amp;rsquo;s own addresses and internal addresses unless a rule names them (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-proxy"&gt;the proxy&lt;/a&gt;). The one thing that VMs share through their proxies is the &lt;a href="https://next.devvm.dev/docs/internals/network/#the-shared-nix-cache"&gt;shared Nix cache&lt;/a&gt;, for those with the nix layer. Only the host writes it, with packages from cache.nixos.org whose signature it checked, and nothing a VM sends is stored, so a VM can make the host fetch but can&amp;rsquo;t change what another VM gets. After each start, devvm checks that the VM still runs confined and can&amp;rsquo;t connect out directly, and it stops a VM that fails the check instead of opening it (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-self-check"&gt;the self-check&lt;/a&gt;).&lt;/p&gt;
&lt;h3 data-hextra-search-id="ssh-into-vms"&gt;ssh into VMs&lt;span class="hx:absolute hx:-mt-20" id="ssh-into-vms"&gt;&lt;/span&gt;
&lt;a href="#ssh-into-vms" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;ssh and editors reach a running VM by name through the entries that devvm writes (&lt;a href="https://next.devvm.dev/docs/using/ssh/#ssh-access-by-name"&gt;ssh access by name&lt;/a&gt;). Each entry is built so that ssh connects only to that VM and the connection gives the VM nothing else of this machine&amp;rsquo;s:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Each entry checks the VM&amp;rsquo;s own host keys,&lt;/strong&gt; which devvm keeps in the VM&amp;rsquo;s folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/known_hosts&lt;/code&gt;, as a record of the VM&amp;rsquo;s current start. devvm reads them from the VM through its backend, instead of over the network, once each start, after the VM runs, whatever ports the VM forwards, and the record names the start it was read for, so the keys of an earlier start are read again rather than trusted, whoever started the VM. devvm also removes the record before each start of its own. A VM whose Lima config changed gets new host keys when it boots. A VM whose keys devvm can&amp;rsquo;t read gets no entry, and ssh refuses a host key that doesn&amp;rsquo;t match. devvm&amp;rsquo;s port forwarder, the sessions of links between VMs and a &lt;code&gt;--clone&lt;/code&gt; VM&amp;rsquo;s git all check the VM against the same record.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Only host keys go into the record.&lt;/strong&gt; devvm keeps a line the VM shows only when its key decodes and names its own type, which works for every key type ssh has, and it drops certificates, markers such as &lt;code&gt;@cert-authority&lt;/code&gt;, patterns and anything else. So the VM can&amp;rsquo;t add a line that would make ssh trust another host, or trust a key for another name.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Each connection is its own.&lt;/strong&gt; The entries set &lt;code&gt;ControlMaster no&lt;/code&gt;, so a session never rides on a connection that another program opened. Of Lima&amp;rsquo;s own ssh settings for the VM, devvm copies only the address, port, user and login key, because Lima&amp;rsquo;s settings turn host key checks off.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The entries turn off everything else your ssh could share with the VM.&lt;/strong&gt; They set &lt;code&gt;ForwardX11 no&lt;/code&gt;, &lt;code&gt;ForwardX11Trusted no&lt;/code&gt;, &lt;code&gt;Tunnel no&lt;/code&gt;, &lt;code&gt;PermitRemoteOpen none&lt;/code&gt;, &lt;code&gt;AddKeysToAgent no&lt;/code&gt;, &lt;code&gt;ProxyJump none&lt;/code&gt;, &lt;code&gt;ProxyCommand none&lt;/code&gt;, &lt;code&gt;UpdateHostKeys no&lt;/code&gt; and &lt;code&gt;HashKnownHosts no&lt;/code&gt;, whatever your own &lt;code&gt;Host *&lt;/code&gt; says. That turns off X11, tunnels, remote SOCKS forwards and adding keys to an agent. &lt;code&gt;PermitRemoteOpen&lt;/code&gt; needs OpenSSH 8.7 or newer (&lt;code&gt;ssh -V&lt;/code&gt;), and an older ssh refuses the entries.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Of your environment, the entries send only &lt;code&gt;COLORTERM&lt;/code&gt;&lt;/strong&gt; (&lt;code&gt;SendEnv COLORTERM&lt;/code&gt;), which says whether your terminal shows 24-bit color. The VM gets it only where its sshd accepts it, as Ubuntu&amp;rsquo;s does in devvm&amp;rsquo;s base. devvm doesn&amp;rsquo;t set that up itself, so a VM made &lt;code&gt;--from&lt;/code&gt; a container image whose sshd doesn&amp;rsquo;t accept it, such as Alpine&amp;rsquo;s, gets none. ssh sends it as your terminal has it, and it adds to the variables your own &lt;code&gt;Host *&lt;/code&gt; sends, such as macOS&amp;rsquo;s &lt;code&gt;LANG&lt;/code&gt; and &lt;code&gt;LC_*&lt;/code&gt;, rather than replacing them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Your agent is forwarded only as the VM&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/using/ssh/#agent-forwarding"&gt;SSH agent&lt;/a&gt; choice says.&lt;/strong&gt; devvm&amp;rsquo;s own connections to a VM follow the same choice, the one the VM&amp;rsquo;s current start was made with, and each carries that VM&amp;rsquo;s agent alone. devvm finds the VM&amp;rsquo;s agent, which is yours, devvm&amp;rsquo;s own or none, and the VM&amp;rsquo;s proxy relays it on a socket of the VM&amp;rsquo;s own, passing on only listing keys, signing and binding a session to a host, so the VM can&amp;rsquo;t remove the agent&amp;rsquo;s keys, lock it or add keys to it (&lt;a href="https://next.devvm.dev/docs/internals/processes/#the-ssh-agents"&gt;the SSH agents&lt;/a&gt;). devvm gives that socket to the backend&amp;rsquo;s start of the VM, to its shell and to the commands that set it up, such as the setup devvm sends and the &lt;code&gt;devcontainer.json&lt;/code&gt; commands. The backend&amp;rsquo;s other commands get no agent, and neither do the reads of a VM&amp;rsquo;s host keys, the &lt;a href="https://next.devvm.dev/docs/internals/network/#the-self-check"&gt;self-check&lt;/a&gt;&amp;rsquo;s probe, the checks of a &lt;code&gt;--clone&lt;/code&gt; VM&amp;rsquo;s clone or &lt;code&gt;devvm paste&lt;/code&gt;&amp;rsquo;s writes and counts. devvm never changes its own environment, so when one run reaches several VMs, such as a group&amp;rsquo;s links, no VM gets another VM&amp;rsquo;s agent. devvm&amp;rsquo;s background processes, such as the proxy and the port forwarder, start without an agent in their environment, and the proxy reaches only the one its config names. devvm&amp;rsquo;s own ssh to a VM uses the VM&amp;rsquo;s login key alone. &lt;code&gt;devvm limactl&lt;/code&gt; runs without your agent too, because Lima&amp;rsquo;s ssh shares one connection per VM, kept open after the command ends, and an agent forwarded over it is the agent of whichever command opened it. With your agent, a &lt;code&gt;devvm limactl shell&lt;/code&gt; could open that connection and pass your agent to devvm&amp;rsquo;s later sessions of a VM whose choice is devvm&amp;rsquo;s agent or none.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A session carries the VM&amp;rsquo;s connections through your machine only where your ssh asks for it. The entries can&amp;rsquo;t turn off a &lt;code&gt;RemoteForward&lt;/code&gt; of yours without also refusing an &lt;code&gt;ssh -R&lt;/code&gt; you type, so a &lt;code&gt;RemoteForward&lt;/code&gt; still applies. The VM&amp;rsquo;s sshd allows local forwarding (&lt;code&gt;-L&lt;/code&gt; and &lt;code&gt;-D&lt;/code&gt;, which VS Code uses), and it allows remote forwards only on addresses in &lt;code&gt;127.77.0.0/16&lt;/code&gt;, which devvm keeps for links between VMs, so a remote forward on the VM&amp;rsquo;s &lt;code&gt;localhost&lt;/code&gt;, as &lt;code&gt;ssh -R&lt;/code&gt; asks by default, is refused. It allows no tunnels or X11. Root in the VM can change all of that, so it&amp;rsquo;s your ssh that decides, and &lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#the-network"&gt;remote forwards you add&lt;/a&gt; says what&amp;rsquo;s left open.&lt;/p&gt;
&lt;h3 data-hextra-search-id="secrets-stay-on-the-host"&gt;Secrets stay on the host&lt;span class="hx:absolute hx:-mt-20" id="secrets-stay-on-the-host"&gt;&lt;/span&gt;
&lt;a href="#secrets-stay-on-the-host" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;devvm saves secrets in the macOS Keychain, or elsewhere in files only you can read, and it never puts a secret in a process&amp;rsquo;s arguments (&lt;a href="https://next.devvm.dev/docs/internals/network/#where-secrets-are-saved"&gt;where secrets are saved&lt;/a&gt;). A VM uses only the Claude Code token, when its image has &lt;code&gt;claude&lt;/code&gt;, and the secrets you bind to it. On every tier, a VM&amp;rsquo;s secrets and its agents&amp;rsquo; logins stay on your machine, and its proxy puts them only into requests for their own hosts.&lt;/p&gt;
&lt;p&gt;The secrets work only for that VM. Its proxy needs the VM&amp;rsquo;s own password, and the VM&amp;rsquo;s placeholders end in a random value of the VM&amp;rsquo;s own, which isn&amp;rsquo;t the password, so a placeholder that the VM sends elsewhere gives nothing away. Another VM, or a program on the host that reaches the proxy&amp;rsquo;s port, gets no secret. The password is in files only you can read, and never in a process&amp;rsquo;s arguments or in devvm&amp;rsquo;s run logs, and only you can read the proxy&amp;rsquo;s logs.&lt;/p&gt;
&lt;p&gt;Each VM&amp;rsquo;s proxy reads traffic to the hosts it puts secrets in for with the VM&amp;rsquo;s own CA, which devvm keeps in the VM&amp;rsquo;s run folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/ca/&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-vms-ca"&gt;the VM&amp;rsquo;s CA&lt;/a&gt;). Your machine never trusts it, but inside its VM it vouches for any site, and no other VM trusts it. Only you can read the keys, they never leave this machine, and devvm keeps them out of Time Machine. Each CA lasts 30 days, and the next one, which the VM already trusts, takes over a week before the current one ends. The certificates that the proxy makes never outlast their CA. What a copy of a key could do, and for how long, is under &lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#this-machine"&gt;the proxy&amp;rsquo;s CA keys&lt;/a&gt;.&lt;/p&gt;
&lt;h3 data-hextra-search-id="set-id-files-on-linux-hosts"&gt;Set-id files on Linux hosts&lt;span class="hx:absolute hx:-mt-20" id="set-id-files-on-linux-hosts"&gt;&lt;/span&gt;
&lt;a href="#set-id-files-on-linux-hosts" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Root in a VM can set the set-user-id and set-group-id bits on files in the project folder. On macOS these bits don&amp;rsquo;t reach the host, because virtiofs drops them, but on Linux they do. A file that a Lima VM writes is yours, so a set-user-id file runs as you for anyone else on the machine who runs it. A set-user-id file that your machine&amp;rsquo;s root owns runs as root for anyone who runs it, you included, and since the VM&amp;rsquo;s writes are yours, such a file came from something else on this machine.&lt;/p&gt;
&lt;p&gt;devvm names such files when it makes a VM and once a VM is stopped, by &lt;code&gt;devvm stop&lt;/code&gt; or found stopped at a launch, but not at a launch into a running VM, because the search reads every file&amp;rsquo;s metadata and takes about a second for 200,000 files. It skips &lt;code&gt;.git&lt;/code&gt; folders, which hold most of a big project&amp;rsquo;s files and whose files nothing runs by their path. It lists root&amp;rsquo;s files apart with &lt;code&gt;setid_root_files&lt;/code&gt;, and you shouldn&amp;rsquo;t run them but delete them with &lt;code&gt;sudo rm&lt;/code&gt;. It lists the rest with &lt;code&gt;setid_files&lt;/code&gt;, and &lt;code&gt;chmod u-s,g-s FILE&lt;/code&gt; clears their bits.&lt;/p&gt;
&lt;h2 data-hextra-search-id="what-it-doesnt-protect"&gt;What it doesn&amp;rsquo;t protect&lt;span class="hx:absolute hx:-mt-20" id="what-it-doesnt-protect"&gt;&lt;/span&gt;
&lt;a href="#what-it-doesnt-protect" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Each defense on this page leaves something open, such as what allowed hosts and secrets permit, open VMs, files the VM writes into the project folder, links between VMs, and escapes from the VM itself through bugs in Lima, Apple&amp;rsquo;s Virtualization framework or QEMU. &lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/"&gt;Attack vectors&lt;/a&gt; keeps the one list of them, under &lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#narrowed-not-closed"&gt;Narrowed, not closed&lt;/a&gt; and &lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#left-to-you"&gt;Left to you&lt;/a&gt;, and each entry there links back to its mechanism.&lt;/p&gt;
&lt;p&gt;Found a way out of a VM? See &lt;a href="https://github.com/devvmhq/devvm/blob/main/SECURITY.md" target="_blank" rel="noopener"&gt;SECURITY.md&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Backends</title><link>https://next.devvm.dev/docs/internals/backends/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/backends/</guid><description>
&lt;p&gt;This page explains how a backend gives devvm what it needs to run a VM, what devvm does when a backend lacks something, and how devvm names VMs. devvm runs its VMs on &lt;a href="https://next.devvm.dev/docs/backends/lima/"&gt;Lima&lt;/a&gt;, and another backend would plug in the same way, through the features below (&lt;a href="https://next.devvm.dev/docs/contributing/extending/#how-a-backend-plugs-in"&gt;how a backend plugs in&lt;/a&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="what-a-backend-does"&gt;What a backend does&lt;span class="hx:absolute hx:-mt-20" id="what-a-backend-does"&gt;&lt;/span&gt;
&lt;a href="#what-a-backend-does" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A backend has four roles, and every backend has all of them:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The host:&lt;/strong&gt; it says what it needs that this machine lacks, which &lt;code&gt;devvm doctor&lt;/code&gt; reports, how long a VM&amp;rsquo;s name can be, where its VMs live, and which folders hold their disks, so devvm can check the free space before a step that writes them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Images:&lt;/strong&gt; it builds images and the shared tools&amp;rsquo; images, keeps the images, and names the files of its own that it puts into base, which base&amp;rsquo;s key hashes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Machines:&lt;/strong&gt; it makes, starts, stops, renames and deletes VMs, runs commands and shells in them, and says how ssh and devvm&amp;rsquo;s port forwarder reach them. It also says how a VM runs now: which start it&amp;rsquo;s on, whether that start is confined to the VM&amp;rsquo;s proxy, and the file the VM&amp;rsquo;s proxy and forwarder follow, which ends them when the process that runs the VM ends.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Housekeeping:&lt;/strong&gt; it says how much disk its VMs and caches take for &lt;code&gt;devvm space&lt;/code&gt;, lists the VMs with devvm&amp;rsquo;s label that this devvm has no state for, and lists and deletes devvm&amp;rsquo;s share of its own caches for &lt;code&gt;devvm gc --caches&lt;/code&gt;. A backend that can&amp;rsquo;t tell one of these returns nothing, so devvm shows no size or deletes nothing.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A backend may also keep files of its own for a VM besides the VM, which &lt;code&gt;devvm gc --orphans&lt;/code&gt; deletes once the VM is gone. Lima keeps none.&lt;/p&gt;
&lt;h2 data-hextra-search-id="features"&gt;Features&lt;span class="hx:absolute hx:-mt-20" id="features"&gt;&lt;/span&gt;
&lt;a href="#features" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Each thing devvm needs from a backend is a feature, such as building images, mounting the project folder or confining a VM to its proxy. &lt;code&gt;devvm doctor&lt;/code&gt; lists them as &amp;ldquo;features&amp;rdquo; too, but they aren&amp;rsquo;t the base image features you choose with &lt;code&gt;devvm setup&lt;/code&gt;. Each backend declares how it has each feature:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;native&lt;/strong&gt;: the backend does it itself.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;emulated&lt;/strong&gt;: devvm builds it from other parts of the backend.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;none&lt;/strong&gt;: the backend can&amp;rsquo;t do it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A backend lists every feature, the ones it lacks too, and devvm refuses to use a backend that leaves one out, so a new feature makes each backend say how it has it. Some features are built on others: &lt;code&gt;read-only-paths&lt;/code&gt; and &lt;code&gt;mount-cache&lt;/code&gt; on &lt;code&gt;project-mount&lt;/code&gt;, &lt;code&gt;ports-all&lt;/code&gt; on &lt;code&gt;ports&lt;/code&gt;, &lt;code&gt;agent-toggle&lt;/code&gt; on &lt;code&gt;agent-forwarding&lt;/code&gt;, and &lt;code&gt;link&lt;/code&gt; on &lt;code&gt;ssh&lt;/code&gt;. A backend has such a feature no better than the one it&amp;rsquo;s built on, so the feature is emulated wherever its base is emulated, and none wherever its base is none.&lt;/p&gt;
&lt;p&gt;devvm uses an emulation only once its review has passed, and until then it refuses the emulation. A review takes a &lt;a href="https://next.devvm.dev/docs/contributing/design/#emulated-features"&gt;design note&lt;/a&gt;, a threat check with the security-audit skill, and end-to-end checks that prove the guarantee.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm doctor&lt;/code&gt; lists Lima&amp;rsquo;s features, and &lt;code&gt;devvm doctor --json&lt;/code&gt; those of every backend devvm has. Both show an emulation whose review hasn&amp;rsquo;t passed as &lt;code&gt;unreviewed&lt;/code&gt;.&lt;/p&gt;
&lt;h3 data-hextra-search-id="the-feature-table"&gt;The feature table&lt;span class="hx:absolute hx:-mt-20" id="the-feature-table"&gt;&lt;/span&gt;
&lt;a href="#the-feature-table" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;Lima&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;build-image&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;build images from the layer and feature scripts&lt;/td&gt;
&lt;td&gt;native&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;build-confinement&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;builds reach the internet but not the host&amp;rsquo;s loopback, or nothing&lt;/td&gt;
&lt;td&gt;native: Seatbelt on macOS. On Linux, QEMU&amp;rsquo;s &lt;code&gt;restrict=on&lt;/code&gt; confines a build with no network, but a build with the internet reaches the host&amp;rsquo;s loopback (&lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;details&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;from&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;base&lt;/code&gt; from a container image (&lt;code&gt;--from&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;native: devvm converts the image to a disk&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;clone&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a project VM from an image&lt;/td&gt;
&lt;td&gt;native: an APFS copy-on-write copy on macOS, and a qcow2 overlay on Linux (&lt;a href="https://next.devvm.dev/docs/internals/lima/#clones-and-overlays"&gt;details&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;project-mount&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the project folder, read-write&lt;/td&gt;
&lt;td&gt;native: virtiofs on macOS, and 9p on Linux&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;read-only-paths&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;paths in the project folder that the guest can&amp;rsquo;t change while the VM runs, which &lt;a href="https://next.devvm.dev/docs/internals/git-protection/#on-linux-hosts"&gt;.git protection&lt;/a&gt; asks for on Linux&lt;/td&gt;
&lt;td&gt;native on Linux where the kernel lets devvm use a user namespace: QEMU runs in one of its own, with the paths bound read-only over themselves (&lt;a href="https://next.devvm.dev/docs/contributing/design/#read-only-paths-on-linux"&gt;details&lt;/a&gt;). None on macOS, where &lt;code&gt;.git&lt;/code&gt; protection locks the host&amp;rsquo;s files itself, and none where devvm&amp;rsquo;s check of the kernel fails&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;mount-cache&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;choosing how the guest caches the project folder&amp;rsquo;s mount, which &lt;code&gt;devvm mount-cache&lt;/code&gt; sets&lt;/td&gt;
&lt;td&gt;native on Linux, where it&amp;rsquo;s 9p&amp;rsquo;s cache option, &lt;code&gt;none&lt;/code&gt; for new VMs (&lt;a href="https://next.devvm.dev/docs/contributing/design/#the-9p-cache-on-linux"&gt;details&lt;/a&gt;). None on macOS, where virtiofs has no such option&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agent-folders&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;agents&amp;rsquo; host folders, read-only&lt;/td&gt;
&lt;td&gt;native: read-only mounts, enforced by the host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tools-share&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the shared tools, read-only&lt;/td&gt;
&lt;td&gt;native: a read-only mount, enforced by the host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;egress-proxy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;network traffic only through devvm&amp;rsquo;s proxy&lt;/td&gt;
&lt;td&gt;native: Seatbelt on macOS, and on Linux QEMU&amp;rsquo;s &lt;code&gt;restrict=on&lt;/code&gt; with a &lt;code&gt;guestfwd&lt;/code&gt; to the proxy (&lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;details&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ssh&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ssh for editors&lt;/td&gt;
&lt;td&gt;native: Lima&amp;rsquo;s ssh forward and config&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ports&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the listed ports forwarded to the host&amp;rsquo;s loopback&lt;/td&gt;
&lt;td&gt;emulated (reviewed): devvm&amp;rsquo;s forwarder over Lima&amp;rsquo;s ssh, for the listed ports alone, with Lima&amp;rsquo;s own forwards off (&lt;a href="https://next.devvm.dev/docs/internals/lima/#ports"&gt;details&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ports-all&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;every port forwarded, servers on the VM&amp;rsquo;s loopback included&lt;/td&gt;
&lt;td&gt;emulated (reviewed): the same forwarder, for whatever listens in the VM from port 1024 up, and never a port the host has (&lt;a href="https://next.devvm.dev/docs/internals/lima/#ports"&gt;details&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agent-forwarding&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ssh-agent forwarding, chosen when the VM is made&lt;/td&gt;
&lt;td&gt;native&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;agent-toggle&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;turning a VM&amp;rsquo;s ssh-agent forwarding on or off later&lt;/td&gt;
&lt;td&gt;native&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;cpus&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a VM&amp;rsquo;s CPUs&lt;/td&gt;
&lt;td&gt;native&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;memory&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a VM&amp;rsquo;s memory&lt;/td&gt;
&lt;td&gt;native&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;disk&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a VM&amp;rsquo;s disk size&lt;/td&gt;
&lt;td&gt;native: it grows but never shrinks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;docker-layer&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the &lt;a href="https://next.devvm.dev/docs/using/images/#built-in-layers"&gt;docker layer&lt;/a&gt;: Docker&amp;rsquo;s engine running in the VM&lt;/td&gt;
&lt;td&gt;native&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;nix-layer&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the &lt;a href="https://next.devvm.dev/docs/using/images/#nix"&gt;nix layer&lt;/a&gt;: Nix&amp;rsquo;s daemon and its store in the VM, with builds in Nix&amp;rsquo;s sandbox&lt;/td&gt;
&lt;td&gt;native (&lt;a href="https://next.devvm.dev/docs/internals/images/#the-nix-layer"&gt;details&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;link&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;links between VMs: a program in one VM reaches a port another VM publishes, by name&lt;/td&gt;
&lt;td&gt;native: a link session of devvm&amp;rsquo;s own over Lima&amp;rsquo;s ssh, with remote forwards to &lt;code&gt;127.77.0.0/16&lt;/code&gt; alone (&lt;a href="https://next.devvm.dev/docs/internals/ports/#links-between-vms"&gt;details&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code&gt;egress-proxy&lt;/code&gt; is what every &lt;a href="https://next.devvm.dev/docs/safety/network/#network-tiers"&gt;network tier&lt;/a&gt; but open needs. The open tier needs no feature of its own: every backend must let a VM on its own network reach a port on the host&amp;rsquo;s loopback and set the guest&amp;rsquo;s proxy settings from what devvm confines the VM to, which the conformance suite checks (&lt;a href="https://next.devvm.dev/docs/contributing/extending/#how-a-backend-plugs-in"&gt;how a backend plugs in&lt;/a&gt;), because every VM&amp;rsquo;s proxy carries its requests. So a backend without &lt;code&gt;egress-proxy&lt;/code&gt; still has open VMs, and devvm refuses every other tier on it in one line (&lt;code&gt;net_tier_backend&lt;/code&gt;).&lt;/p&gt;
&lt;h3 data-hextra-search-id="what-each-backend-emulates"&gt;What each backend emulates&lt;span class="hx:absolute hx:-mt-20" id="what-each-backend-emulates"&gt;&lt;/span&gt;
&lt;a href="#what-each-backend-emulates" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;On Lima, devvm emulates forwarding ports, both the listed ones and every one, through its forwarder, and the emulation is reviewed (&lt;a href="https://next.devvm.dev/docs/internals/ports/"&gt;port forwarding&lt;/a&gt;). Everything else on Lima is Lima&amp;rsquo;s own.&lt;/p&gt;
&lt;p&gt;The forwarder is devvm&amp;rsquo;s own on every backend, never a backend&amp;rsquo;s. A backend that has &lt;code&gt;ports&lt;/code&gt; turns its own forwards off, and devvm&amp;rsquo;s forwarder reaches a running VM&amp;rsquo;s sshd the way the backend&amp;rsquo;s &lt;code&gt;SSH&lt;/code&gt; says, which is a user, a key and a port. devvm refuses that target unless it&amp;rsquo;s on this machine&amp;rsquo;s loopback, &lt;code&gt;127.0.0.1&lt;/code&gt;, with the same check it uses for links and the ssh config. devvm reads which ports the VM forwards from its state, chooses which of them are free, pins the VM&amp;rsquo;s host keys for its current start and starts the forwarder, which follows the backend&amp;rsquo;s lifeline for the VM.&lt;/p&gt;
&lt;h2 data-hextra-search-id="missing-and-unreviewed-features"&gt;Missing and unreviewed features&lt;span class="hx:absolute hx:-mt-20" id="missing-and-unreviewed-features"&gt;&lt;/span&gt;
&lt;a href="#missing-and-unreviewed-features" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm checks each feature an image or a VM needs this way:&lt;/p&gt;
&lt;div class="devvm-diagram" style="contain-intrinsic-block-size: auto 493px; --devvm-diagram-width: 617px"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" class="pele pele-flowchart" viewBox="0 0 617 493" width="617" height="493" style="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,&amp;quot;Departure Mono&amp;quot;, monospace);font:14px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,&amp;quot;Departure Mono&amp;quot;, monospace)" fill="var(--_fg)" role="graphics-document document" aria-roledescription="flowchart" aria-labelledby="dcd6d763e7700bcee--title" aria-describedby="dcd6d763e7700bcee--desc"&gt;&lt;title id="dcd6d763e7700bcee--title"&gt;How devvm checks a feature&lt;/title&gt;&lt;desc id="dcd6d763e7700bcee--desc"&gt;A feature that the image or the VM needs is allowed when the backend has it natively, or emulates it and the emulation is reviewed. An unreviewed emulation, or none, is refused, and devvm stops and names the VM, the feature and the backend, except egress-proxy for a new open VM, which is made open, as asked.&lt;/desc&gt;&lt;g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round"&gt;&lt;g class="pele-edge" data-id="L_need_how_0"&gt;&lt;path d="M154.23,68L154.23,106"/&gt;&lt;path class="pele-marker" d="M154.23,113L150.87,105L157.59,105Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_how_ok_0"&gt;&lt;path d="M84.23,158L84.23,164Q84.23,176 72.23,176L52.73,176Q40.73,176 40.73,188L40.73,236Q40.73,248 52.73,248L101.81,248Q113.81,248 113.81,260L113.81,266.5"/&gt;&lt;path class="pele-marker" d="M113.81,273.5L110.45,265.5L117.17,265.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_how_ok_2"&gt;&lt;path d="M175.64,158L175.64,236Q175.64,248 163.64,248L141.81,248Q129.81,248 129.81,260L129.81,266.5"/&gt;&lt;path class="pele-marker" d="M129.81,273.5L126.45,265.5L133.17,265.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_how_np_0"&gt;&lt;path d="M224.23,158L224.23,164Q224.23,176 236.23,176L365.36,176Q377.36,176 377.36,188L377.36,259"/&gt;&lt;path class="pele-marker" d="M377.36,266L374,258L380.72,258Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_np_refused_0"&gt;&lt;path d="M329.64,326L329.64,332Q329.64,344 317.64,344L222.77,344Q210.77,344 210.77,356L210.77,399.5"/&gt;&lt;path class="pele-marker" d="M210.77,406.5L207.41,398.5L214.13,398.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_np_warned_0"&gt;&lt;path d="M425.09,326L425.09,332Q425.09,344 437.09,344L489.14,344Q501.14,344 501.14,356L501.14,399.5"/&gt;&lt;path class="pele-marker" d="M501.14,406.5L497.78,398.5L504.5,398.5Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edge-labels" font-size="14"&gt;&lt;g class="pele-edge-label" data-id="L_how_ok_0"&gt;&lt;rect x="10" y="203" width="61.45" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="40.73" y="216.2" text-anchor="middle"&gt;native&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_how_ok_2"&gt;&lt;rect x="91.45" y="203" width="168.36" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="175.64" y="216.2" text-anchor="middle"&gt;emulated, reviewed&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_how_np_0"&gt;&lt;rect x="279.82" y="196" width="195.09" height="32" rx="3" fill="var(--_bg)"/&gt;&lt;text text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="377.36" y="208.2"&gt;emulated, unreviewed,&lt;/tspan&gt;&lt;tspan x="377.36" y="224.2"&gt;or none&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_np_refused_0"&gt;&lt;rect x="197.86" y="364" width="25.82" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="210.77" y="377.2" text-anchor="middle"&gt;no&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_np_warned_0"&gt;&lt;rect x="483.77" y="364" width="34.73" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="501.14" y="377.2" text-anchor="middle"&gt;yes&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-nodes"&gt;&lt;g class="pele-node pele-shape-rect" data-id="need" transform="translate(154.23,38)"&gt;&lt;rect x="-102.64" y="-30" width="205.27" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;a feature the image&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;or the VM needs&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-hex" data-id="how" transform="translate(154.23,135.5)"&gt;&lt;polygon points="-116,-22.5 116,-22.5 127.25,0 116,22.5 -116,22.5 -127.25,0" fill="var(--_s)" stroke="var(--_b)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;how the backend has it&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="ok" transform="translate(121.81,296)"&gt;&lt;rect x="-49.18" y="-22.5" width="98.36" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;allowed&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-hex" data-id="np" transform="translate(377.36,296)"&gt;&lt;polygon points="-93.73,-30 93.73,-30 108.73,0 93.73,30 -93.73,30 -108.73,0" fill="var(--_s)" stroke="var(--_b)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;egress-proxy, for&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;a new open VM?&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="refused" transform="translate(210.77,445.5)"&gt;&lt;rect x="-138.27" y="-39" width="276.55" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;refused: devvm stops&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;and names the VM,&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;the feature and the backend&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="warned" transform="translate(501.14,436.5)"&gt;&lt;rect x="-107.09" y="-30" width="214.18" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;the VM is made open,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;as asked&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/div&gt;&lt;p&gt;Before devvm builds an image, makes or starts a VM, or changes a VM&amp;rsquo;s settings, it checks that the backend has every feature the image or the VM needs. The backend itself is behind the same check: every time devvm asks it to build an image or the shared tools, make a VM or start one, devvm checks the features that request needs before the backend sees it, so a request that skipped the first check is refused too. When the backend lacks one, devvm stops and names the VM, the feature and the backend (&lt;code&gt;backend_lacks&lt;/code&gt;). It does the same for a feature the backend only emulates when that emulation&amp;rsquo;s review hasn&amp;rsquo;t passed (&lt;code&gt;backend_unreviewed&lt;/code&gt;). devvm never falls back to something weaker, so a VM on a confined tier never starts with an open network.&lt;/p&gt;
&lt;p&gt;To get the feature, use a backend that has it. A VM keeps its backend, so that means making a new VM.&lt;/p&gt;
&lt;p&gt;A new VM&amp;rsquo;s tier is the one exception, because allowlist is the default, and &lt;a href="https://next.devvm.dev/docs/backends/#when-a-backend-lacks-something"&gt;When a backend lacks something&lt;/a&gt; says what devvm does instead.&lt;/p&gt;
&lt;h2 data-hextra-search-id="what-a-start-changes"&gt;What a start changes&lt;span class="hx:absolute hx:-mt-20" id="what-a-start-changes"&gt;&lt;/span&gt;
&lt;a href="#what-a-start-changes" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A backend makes a VM as devvm asks, and then changes it only when it starts. Each time devvm starts a stopped VM, it tells the backend what the VM&amp;rsquo;s state asks for, which is its size, the agent folders in devvm&amp;rsquo;s agent store and whether it forwards your SSH agent, together with how the VM is confined. The backend compares that with the VM it has and changes only what differs, so a start that changes nothing leaves the VM&amp;rsquo;s config as it was. Nothing changes a stopped VM&amp;rsquo;s config between starts, so &lt;code&gt;devvm size&lt;/code&gt; and &lt;code&gt;devvm ssh-agent&lt;/code&gt; save what you ask for in the VM&amp;rsquo;s state, and the VM gets it when it next starts.&lt;/p&gt;
&lt;p&gt;A running VM is left as it is, and devvm says what changes when it next starts. Its ports aren&amp;rsquo;t the backend&amp;rsquo;s, so &lt;code&gt;devvm ports&lt;/code&gt; changes them at once, and a running VM&amp;rsquo;s forwarder starts again with the new ones (&lt;a href="https://next.devvm.dev/docs/internals/ports/#its-process-and-files"&gt;port forwarding&lt;/a&gt;). A disk can&amp;rsquo;t shrink, so a start that asks for a smaller disk than the VM has fails before the backend changes anything (&lt;code&gt;disk_shrink&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Which ports a VM forwards stays in the VM&amp;rsquo;s state alone, and the backend never hears of them. The backend keeps only what it needs for the start it made, such as Lima&amp;rsquo;s record of the hostagent it started confined (&lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;confinement&lt;/a&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="vm-names"&gt;VM names&lt;span class="hx:absolute hx:-mt-20" id="vm-names"&gt;&lt;/span&gt;
&lt;a href="#vm-names" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A project VM&amp;rsquo;s name is &lt;code&gt;devvm-&amp;lt;folder&amp;gt;-&amp;lt;hash&amp;gt;&lt;/code&gt;. The folder part is up to 20 characters of the folder&amp;rsquo;s name, in lowercase, with each run of characters other than letters and digits turned into one dash, because Lima refuses a name with separators in a row, so &lt;code&gt;foo (copy)&lt;/code&gt; gives &lt;code&gt;foo-copy&lt;/code&gt;. The hash part is 14 hex digits of a hash of the folder&amp;rsquo;s path. devvm takes a name as a project VM&amp;rsquo;s only when it has that form, so a name in a state file or a backend&amp;rsquo;s list whose folder part has any other character, starts or ends with a dash, or has two dashes in a row isn&amp;rsquo;t a project VM&amp;rsquo;s. A state file whose name has dashes in a row and no &lt;code&gt;created&lt;/code&gt; time belongs to a VM that Lima refused to make, so devvm reads it as no VM&amp;rsquo;s state and the folder&amp;rsquo;s next VM replaces it.&lt;/p&gt;
&lt;p&gt;A backend may need shorter names, and then devvm cuts the folder&amp;rsquo;s part to fit. When fewer than 4 characters of it would fit, devvm refuses (&lt;code&gt;vm_name_no_room&lt;/code&gt;). On Lima the room for a name depends on the Lima home&amp;rsquo;s path, because Lima keeps each VM&amp;rsquo;s ssh socket under it, so there the fix is a shorter Lima home (&lt;code&gt;lima_home_too_long&lt;/code&gt;, &lt;a href="https://next.devvm.dev/docs/backends/lima/#limits"&gt;limits&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Only a new VM gets a name, which fits the limit of the backend that makes it. devvm finds a folder&amp;rsquo;s VM by the state that records the folder&amp;rsquo;s path, in the VM&amp;rsquo;s folder in devvm&amp;rsquo;s data folder (&lt;code&gt;vms/&amp;lt;hash&amp;gt;/&lt;/code&gt;, named by the hash that ends the VM&amp;rsquo;s name), so an existing VM keeps the name and the backend its state records, whichever backend new VMs get, and keeps them when its folder moves (&lt;a href="https://next.devvm.dev/docs/internals/overview/#a-moved-folder"&gt;a moved folder&lt;/a&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="which-backends-a-launch-asks"&gt;Which backends a launch asks&lt;span class="hx:absolute hx:-mt-20" id="which-backends-a-launch-asks"&gt;&lt;/span&gt;
&lt;a href="#which-backends-a-launch-asks" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A launch asks a backend about its VMs only when some VM&amp;rsquo;s state names that backend. It asks them to write the &lt;a href="https://next.devvm.dev/docs/using/ssh/"&gt;ssh config&lt;/a&gt; and to check the SSH agent&amp;rsquo;s folders. So a backend that no VM uses never runs during a launch, even when it isn&amp;rsquo;t running or isn&amp;rsquo;t installed (&lt;a href="https://next.devvm.dev/docs/backends/#a-vms-backend"&gt;a VM&amp;rsquo;s backend&lt;/a&gt;).&lt;/p&gt;</description></item><item><title>Lima</title><link>https://next.devvm.dev/docs/internals/lima/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/lima/</guid><description>
&lt;p&gt;This page explains how devvm runs its VMs on Lima: the Lima home it keeps them in, how it builds images and clones VMs from them, what it sets in each VM&amp;rsquo;s config, how it confines VMs and builds, and how it forwards their ports. &lt;a href="https://next.devvm.dev/docs/backends/lima/"&gt;Lima&lt;/a&gt; covers what you need to run it, &lt;code&gt;devvm limactl&lt;/code&gt; and Lima&amp;rsquo;s limits.&lt;/p&gt;
&lt;h2 data-hextra-search-id="a-lima-home-of-its-own"&gt;A Lima home of its own&lt;span class="hx:absolute hx:-mt-20" id="a-lima-home-of-its-own"&gt;&lt;/span&gt;
&lt;a href="#a-lima-home-of-its-own" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Lima merges &lt;code&gt;_config/default.yaml&lt;/code&gt; and &lt;code&gt;_config/override.yaml&lt;/code&gt; from its home into every VM it creates or starts. A network you set there for your own VMs would give a devvm VM a second network card with a route around its proxy, and an extra mount set there would go unnoticed. So devvm keeps its VMs in a Lima home of their own, &lt;code&gt;~/.local/share/devvm/lima&lt;/code&gt;, whatever &lt;code&gt;LIMA_HOME&lt;/code&gt; says (&lt;a href="https://next.devvm.dev/docs/backends/lima/#devvms-lima-home"&gt;devvm&amp;rsquo;s Lima home&lt;/a&gt; says what that means for you).&lt;/p&gt;
&lt;p&gt;devvm refuses to start a VM while that home holds either file (&lt;code&gt;lima_global_config&lt;/code&gt;), and it refuses a VM that has a network devvm didn&amp;rsquo;t give it (&lt;code&gt;vm_has_networks&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;devvm runs &lt;code&gt;limactl&lt;/code&gt; from its own data folder. When a config is invalid, Lima writes &lt;code&gt;lima.REJECTED.yaml&lt;/code&gt; into the folder it runs in, and a project folder belongs to the VM to write.&lt;/p&gt;
&lt;h2 data-hextra-search-id="clones-and-overlays"&gt;Clones and overlays&lt;span class="hx:absolute hx:-mt-20" id="clones-and-overlays"&gt;&lt;/span&gt;
&lt;a href="#clones-and-overlays" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;An image is a stopped VM in devvm&amp;rsquo;s Lima home, named &lt;code&gt;devvm-img-&amp;lt;key&amp;gt;&lt;/code&gt;. devvm makes base&amp;rsquo;s from Ubuntu&amp;rsquo;s cloud image with &lt;code&gt;base.yaml&lt;/code&gt;, &lt;a href="https://next.devvm.dev/docs/internals/images/#bases-size"&gt;base&amp;rsquo;s size&lt;/a&gt; as &lt;code&gt;--cpus&lt;/code&gt;, &lt;code&gt;--memory&lt;/code&gt; and &lt;code&gt;--disk&lt;/code&gt;, and &lt;code&gt;--mount-none&lt;/code&gt;, and it gives &lt;code&gt;limactl create&lt;/code&gt; the template on its standard input (&lt;code&gt;-&lt;/code&gt;), from the binary, so no copy of &lt;code&gt;base.yaml&lt;/code&gt; is on disk. With &lt;code&gt;--from&lt;/code&gt;, it makes base&amp;rsquo;s from the converted disk instead, and boots its kernel and initrd directly (&lt;a href="https://next.devvm.dev/docs/internals/images/#how-its-converted"&gt;details&lt;/a&gt;). A layer&amp;rsquo;s image is a clone of its parent&amp;rsquo;s, also made with &lt;code&gt;--mount-none&lt;/code&gt;, so a build mounts nothing from the host. A project VM is a clone of its image&amp;rsquo;s VM, which devvm makes while the image is stopped.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;macOS:&lt;/strong&gt; the clone&amp;rsquo;s disk is an APFS copy-on-write copy. It shares the image&amp;rsquo;s blocks until the VM writes them, so &lt;code&gt;du&lt;/code&gt; overcounts it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Linux:&lt;/strong&gt; Lima&amp;rsquo;s disks are qcow2 files, and a clone would be a full copy. So a project VM&amp;rsquo;s disk is a qcow2 overlay of its image&amp;rsquo;s, readable only by you, which shares the image&amp;rsquo;s blocks and holds only the VM&amp;rsquo;s changes. An image&amp;rsquo;s disk is read-only once it&amp;rsquo;s built, and devvm can&amp;rsquo;t delete an image while VMs&amp;rsquo; disks are overlays of it (&lt;code&gt;image_in_use&lt;/code&gt;). devvm reads each VM disk&amp;rsquo;s backing file with &lt;code&gt;qemu-img info -U&lt;/code&gt;, which shares the disk with the QEMU of a running VM, because that QEMU&amp;rsquo;s write lock refuses &lt;code&gt;qemu-img info&lt;/code&gt; otherwise.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="what-devvm-sets-on-a-vm"&gt;What devvm sets on a VM&lt;span class="hx:absolute hx:-mt-20" id="what-devvm-sets-on-a-vm"&gt;&lt;/span&gt;
&lt;a href="#what-devvm-sets-on-a-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm sets these in each VM&amp;rsquo;s Lima config:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mounts:&lt;/strong&gt; the project folder (read-write), agents&amp;rsquo; folders (read-only), and the shared tools at &lt;code&gt;/mnt/devvm-tools&lt;/code&gt; (read-only). Each folder but the tools is mounted at its host path. devvm mounts nothing else, and it leaves out the home folder that Lima&amp;rsquo;s templates mount. On macOS, where Lima runs VMs with &lt;code&gt;vz&lt;/code&gt;, the project folder&amp;rsquo;s mount names the folder by the device and inode that devvm recorded when it made the VM, or recorded again at a start after a boot numbered the folder&amp;rsquo;s disk anew, as &lt;code&gt;location: /.vol/&amp;lt;device&amp;gt;/&amp;lt;inode&amp;gt;&lt;/code&gt; with &lt;code&gt;mountPoint&lt;/code&gt; set to the folder&amp;rsquo;s path. macOS&amp;rsquo;s &lt;code&gt;/.vol&lt;/code&gt; opens a folder by its device and inode, so Virtualization.framework shares the folder devvm made the VM for, wherever that folder is when the VM starts, and never follows a link put at its path (&lt;a href="https://next.devvm.dev/docs/internals/overview/#an-existing-vm"&gt;an existing VM&lt;/a&gt;). Virtualization.framework then serves the share by the path the folder had at the start, so a folder moved back while the VM runs answers &amp;ldquo;Operation not permitted&amp;rdquo; in the VM until its next start. QEMU&amp;rsquo;s 9p on Linux has nothing like &lt;code&gt;/.vol&lt;/code&gt;, so there the mount is by the folder&amp;rsquo;s path, with the cache mode the VM&amp;rsquo;s state records as its &lt;code&gt;9p: cache:&lt;/code&gt; option: &lt;code&gt;none&lt;/code&gt; for a new VM, and nothing for a VM whose mode nobody chose, which keeps Lima&amp;rsquo;s &lt;code&gt;mmap&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/contributing/design/#the-9p-cache-on-linux"&gt;why&lt;/a&gt;). The read-only mounts keep Lima&amp;rsquo;s &lt;code&gt;fscache&lt;/code&gt;, and a build VM&amp;rsquo;s writable output folder gets &lt;code&gt;none&lt;/code&gt;. The start that changes a VM&amp;rsquo;s cache mode mounts its folder again once the VM runs, because the guest mounted it with the old options before cloud-init wrote the new ones into its &lt;code&gt;/etc/fstab&lt;/code&gt;, and it then checks the mount: a folder left unmounted fails the start (&lt;a href="https://next.devvm.dev/docs/contributing/design/#the-9p-cache-on-linux"&gt;why&lt;/a&gt;). A start that rewrites the mounts, for a folder that moved, another cache mode or other agents&amp;rsquo; folders, keeps each mount&amp;rsquo;s settings that devvm doesn&amp;rsquo;t set, such as its other 9p and sshfs options, where they differ from Lima&amp;rsquo;s defaults, and leaves the defaults out for Lima to fill in.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ssh:&lt;/strong&gt; agent forwarding on or off, and the host port, which Lima always listens on at &lt;code&gt;127.0.0.1&lt;/code&gt;. devvm chooses the port and records it, so no other VM&amp;rsquo;s forwarded ports take it. It chooses only from the 17 ports on which every browser engine refuses every request, navigations and WebSockets included, which are the Fetch standard&amp;rsquo;s bad ports from 1024 up that Chromium also blocks (1719, 1720, 1723, 2049, 3659, 4045, 5060, 5061, 6000, 6566, 6665 to 6669, 6697 and 10080). Fetch also lists 4190 and 6679, but Chromium&amp;rsquo;s own list lacks them, and Chrome loads pages on them. Root in a VM can make what answers on its ssh port speak HTTP, and cookies ignore the port, so on any other port a page opened as &lt;code&gt;http://localhost:PORT&lt;/code&gt; would reach a server the VM controls with the cookies of the apps you use on &lt;code&gt;localhost&lt;/code&gt;, even in a VM that forwards no ports. So at most 17 VMs run at once, and a start past that fails, naming the VMs whose ports are in use (&lt;code&gt;ports_ssh_limit&lt;/code&gt;, or &lt;code&gt;ports_ssh_limit_all&lt;/code&gt; when they have all 17), or saying that VMs starting or building, ports a running VM lists to forward, or other programs on this machine have them all (&lt;code&gt;ports_ssh_limit_others&lt;/code&gt;). devvm&amp;rsquo;s other host ports, a VM&amp;rsquo;s proxy port and desktop port, are never one of these, and one an older devvm chose moves at the VM&amp;rsquo;s next start. A VM that forwards every port never forwards one of the 17 either. A VM that lists one does forward it, whatever set the list, and &lt;code&gt;devvm ports&lt;/code&gt; and each launch warn of it (&lt;code&gt;ports_ssh_listed&lt;/code&gt;), and while that VM runs, it keeps the port from VMs&amp;rsquo; ssh, as any program on this machine that holds one does. A stopped VM keeps its port at its next start while it&amp;rsquo;s free, and gets another when another program on the host has it, on any address, when the VM lists it to forward, when another start or a build holds it, when a VM that runs lists it, or when it isn&amp;rsquo;t one of the 17, because an older devvm chose it. A new port is one no VM&amp;rsquo;s state records, or else one a stopped VM&amp;rsquo;s state records, which that VM gives up, getting another at its own next start. A build VM&amp;rsquo;s port is never the one its clone kept from its image while another is free. The start&amp;rsquo;s one &lt;code&gt;limactl edit&lt;/code&gt; sets a new port, and the VM&amp;rsquo;s host keys are pinned again, as at every start. A start holds its port, kept or new, for a minute, in &lt;code&gt;run/ports.ssh-hold&lt;/code&gt; in the VM&amp;rsquo;s folder, so that no other start or build takes it before its backend binds it as the start begins. The hold lasts only that minute, so a start whose backend takes longer than that to bind the port can lose it to another start that chooses it then. The slower start then fails, and starting it again gives it another port. A running VM keeps its port until its next start, even one an older devvm chose, and each launch warns of the running VMs still on such a port (&lt;code&gt;ports_ssh_old&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ports:&lt;/strong&gt; none, because Lima&amp;rsquo;s own forwards are off and devvm&amp;rsquo;s forwarder forwards the VM&amp;rsquo;s ports instead (&lt;a href="#ports"&gt;below&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Size:&lt;/strong&gt; CPUs, memory and disk.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Guest environment:&lt;/strong&gt; Lima&amp;rsquo;s &lt;code&gt;env:&lt;/code&gt;, which Lima writes to &lt;code&gt;/etc/environment&lt;/code&gt; at every boot. On every tier it holds the VM&amp;rsquo;s proxy&amp;rsquo;s address and its settings, and Lima doesn&amp;rsquo;t pass the host&amp;rsquo;s proxy settings in. A confined VM reaches the proxy as Lima&amp;rsquo;s host address on macOS and as QEMU&amp;rsquo;s &lt;code&gt;guestfwd&lt;/code&gt; address on Linux, and an open VM reaches it at Lima&amp;rsquo;s host address on both, which is this machine&amp;rsquo;s loopback as Lima&amp;rsquo;s network has it, with &lt;code&gt;host.lima.internal&lt;/code&gt; added to its &lt;code&gt;NO_PROXY&lt;/code&gt;. &lt;code&gt;limactl edit&lt;/code&gt; sets the proxy&amp;rsquo;s URL with a stand-in for the password (&lt;code&gt;devvm-proxy-password&lt;/code&gt;), and devvm then replaces the stand-in in the VM&amp;rsquo;s &lt;code&gt;lima.yaml&lt;/code&gt;, which it rewrites with mode 600, so the password is in no process&amp;rsquo;s arguments. Its &lt;code&gt;NO_PROXY&lt;/code&gt; and &lt;code&gt;no_proxy&lt;/code&gt; name the VM alone, and never its &lt;a href="https://next.devvm.dev/docs/contributing/design/#links-between-vms"&gt;links&lt;/a&gt;, which its HTTP clients reach through the proxy, so links never change it. A start runs &lt;code&gt;limactl edit&lt;/code&gt; only when the environment differs from the one the VM has, because it compares them first. That edit gives the VM new ssh host keys at its next boot, as any edit does, and devvm forgets a VM&amp;rsquo;s host keys at every start and pins them again once it runs, so devvm&amp;rsquo;s ssh config, its own connections and your editors keep working.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Proxy settings and DNS:&lt;/strong&gt; Lima&amp;rsquo;s &lt;code&gt;propagateProxyEnv&lt;/code&gt;, which writes this machine&amp;rsquo;s proxy settings into the guest, is on only for a VM on Lima&amp;rsquo;s own network without devvm&amp;rsquo;s proxy, so they never reach a VM that goes through devvm&amp;rsquo;s proxy. A VM confined to its proxy has Lima&amp;rsquo;s host resolver off (&lt;code&gt;hostResolver.enabled: false&lt;/code&gt;) and &lt;code&gt;dns: [&amp;quot;127.0.0.1&amp;quot;]&lt;/code&gt;, because its names resolve in the proxy (&lt;a href="#confinement"&gt;confinement&lt;/a&gt;). An open VM keeps Lima&amp;rsquo;s own resolver and DNS.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Lima changes only a stopped VM&amp;rsquo;s config, so a change you make while the VM runs applies at its next start. When devvm makes a VM, the clone gets its mounts, agent forwarding, ssh port, ports rules and environment, and devvm then edits the VM&amp;rsquo;s size where it differs from its image&amp;rsquo;s. Each start of a stopped VM compares the VM&amp;rsquo;s config, as &lt;code&gt;limactl list&lt;/code&gt; shows it, with what the VM&amp;rsquo;s state asks for and with how the VM starts. That covers its size, its project folder&amp;rsquo;s path, which changes once the folder moved (&lt;a href="https://next.devvm.dev/docs/internals/overview/#a-moved-folder"&gt;a moved folder&lt;/a&gt;), on macOS the device and inode its mount names, which change in that same edit once a boot gave the folder&amp;rsquo;s disk another device number, and on Linux its cache mode where one was chosen, its agents&amp;rsquo; folders, its agent forwarding, its ssh port, its environment, Lima&amp;rsquo;s proxy settings (&lt;code&gt;propagateProxyEnv&lt;/code&gt;), its DNS (&lt;code&gt;hostResolver&lt;/code&gt; and &lt;code&gt;dns&lt;/code&gt;) and its ports rules. devvm then changes whatever differs in one &lt;code&gt;limactl edit&lt;/code&gt;, and runs none when nothing does, because each edit gives the VM new ssh host keys at its next boot. Lima can&amp;rsquo;t shrink a disk, so a start that asks for a smaller disk than the VM has fails before it changes anything (&lt;code&gt;disk_shrink&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;devvm leaves Lima&amp;rsquo;s &lt;code&gt;mountInotify&lt;/code&gt; off, so file watchers in the VM see only the changes made in the VM (&lt;a href="https://next.devvm.dev/docs/backends/lima/#file-watchers"&gt;file watchers&lt;/a&gt;). With it on, Lima&amp;rsquo;s hostagent watches the project folder on the host and, for each change there, changes the file&amp;rsquo;s times in the guest as root, which raises an inotify event for the guest&amp;rsquo;s watchers. The hostagent can&amp;rsquo;t tell the VM&amp;rsquo;s own writes from the host&amp;rsquo;s, so it does this to every file the VM writes too, and on macOS the guest then sees such a file as root&amp;rsquo;s for a moment. A command that writes a file and then changes its mode fails in that moment, and in a test on macOS, &lt;code&gt;git init&lt;/code&gt; in the project folder failed 13 times in 30 with it on and never with it off. Lima also passes on no deletions, and it marks the setting as experimental.&lt;/p&gt;
&lt;h2 data-hextra-search-id="a-shells-colors"&gt;A shell&amp;rsquo;s colors&lt;span class="hx:absolute hx:-mt-20" id="a-shells-colors"&gt;&lt;/span&gt;
&lt;a href="#a-shells-colors" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm opens a VM&amp;rsquo;s shell, and runs an agent&amp;rsquo;s login, with &lt;code&gt;limactl shell&lt;/code&gt;, which asks ssh to send your terminal&amp;rsquo;s &lt;code&gt;COLORTERM&lt;/code&gt;. That request never reaches the VM, because the session goes over the ssh connection that Lima shares between all of a VM&amp;rsquo;s sessions, which was opened without it (&lt;a href="https://github.com/lima-vm/lima/issues/2208" target="_blank" rel="noopener"&gt;lima-vm/lima#2208&lt;/a&gt;). Closing that connection would end every session and the VM&amp;rsquo;s SSH agent relay with it, so devvm sets &lt;code&gt;COLORTERM&lt;/code&gt; in the command it runs in the VM instead. It passes only &lt;code&gt;truecolor&lt;/code&gt; and &lt;code&gt;24bit&lt;/code&gt;, the two values that say a terminal shows 24-bit color, and it quotes them for the VM&amp;rsquo;s shell. Quoting alone would make any value safe, but devvm sends a VM only values it knows. It passes nothing for any other value or when &lt;code&gt;COLORTERM&lt;/code&gt; isn&amp;rsquo;t set, and then the shell starts as &lt;code&gt;limactl shell&lt;/code&gt; starts it by itself.&lt;/p&gt;
&lt;h2 data-hextra-search-id="a-stopped-vms-shell"&gt;A stopped VM&amp;rsquo;s shell&lt;span class="hx:absolute hx:-mt-20" id="a-stopped-vms-shell"&gt;&lt;/span&gt;
&lt;a href="#a-stopped-vms-shell" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Every &lt;code&gt;limactl shell&lt;/code&gt; that devvm runs says &lt;code&gt;--start=false&lt;/code&gt;. In a terminal, &lt;code&gt;limactl shell&lt;/code&gt; of a stopped VM asks whether to start it, and the question&amp;rsquo;s default is yes, but that start skips every check of devvm&amp;rsquo;s own start. A VM on a confined tier would run unconfined, without its proxy, and any VM would mount whatever is at the project folder&amp;rsquo;s path, a folder that replaced it included, and Lima would make the folder again if it&amp;rsquo;s gone. So a VM that stops while devvm works with it, such as one whose guest shut itself down, makes devvm&amp;rsquo;s shell or command fail, and devvm&amp;rsquo;s next launch starts it with every check.&lt;/p&gt;
&lt;h2 data-hextra-search-id="a-commands-output"&gt;A command&amp;rsquo;s output&lt;span class="hx:absolute hx:-mt-20" id="a-commands-output"&gt;&lt;/span&gt;
&lt;a href="#a-commands-output" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm closes the output of each command that it runs in a VM, apart from a shell and an image build&amp;rsquo;s steps, a second after the command ends or its time limit runs out, because the ssh that &lt;code&gt;limactl shell&lt;/code&gt; runs can leave a process behind that holds the output open. So a VM can&amp;rsquo;t keep devvm waiting past a command&amp;rsquo;s time limit, and a command whose output was cut short that way fails.&lt;/p&gt;
&lt;h2 data-hextra-search-id="confinement"&gt;Confinement&lt;span class="hx:absolute hx:-mt-20" id="confinement"&gt;&lt;/span&gt;
&lt;a href="#confinement" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A VM on a confined tier, internet, allowlist or none, reaches nothing but its proxy on the host, which applies its tier&amp;rsquo;s rules, and even root in the VM can&amp;rsquo;t get around that. Direct connections, DNS, UDP and connections to the host&amp;rsquo;s own services fail at once, while forwarded ports, mounts and ssh keep working. &lt;a href="https://next.devvm.dev/docs/internals/processes/"&gt;Processes&lt;/a&gt; has what the hostagent and the QEMU wrapper hold, write and wait for (&lt;a href="https://next.devvm.dev/docs/internals/processes/#limas-hostagent"&gt;Lima&amp;rsquo;s hostagent&lt;/a&gt;, &lt;a href="https://next.devvm.dev/docs/internals/processes/#the-qemu-wrapper-and-its-keeper"&gt;the QEMU wrapper&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;On each host, the VM&amp;rsquo;s traffic passes through one process that devvm confines:&lt;/p&gt;
&lt;div class="devvm-diagram" style="contain-intrinsic-block-size: auto 465px; --devvm-diagram-width: 562px"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" class="pele pele-flowchart" viewBox="0 0 562 465" width="562" height="465" style="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg);--_r:var(--pele-radius,4px);--_fm:var(--pele-font-mono,&amp;quot;Departure Mono&amp;quot;, monospace);font:14px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,&amp;quot;Departure Mono&amp;quot;, monospace)" fill="var(--_fg)" role="graphics-document document" aria-roledescription="flowchart" aria-labelledby="d67d260dfe3038c13--title" aria-describedby="d67d260dfe3038c13--desc"&gt;&lt;title id="d67d260dfe3038c13--title"&gt;The process that confines a VM's traffic&lt;/title&gt;&lt;desc id="d67d260dfe3038c13--desc"&gt;On Linux, the VM's traffic goes through QEMU, with restrict=on, which reaches only its proxy at 192.168.5.4:3128. On macOS, it goes through its Lima hostagent, which is sandboxed, so it reaches only its ssh port, its proxy, its Lima sockets and its SSH agent, and everything else is denied.&lt;/desc&gt;&lt;g class="pele-clusters"&gt;&lt;g class="pele-cluster" data-id="mac"&gt;&lt;rect x="310.32" y="8" width="165.09" height="245" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-cluster-label" fill="var(--_m)" x="346.59" y="31.4" text-anchor="middle"&gt;macOS&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-cluster" data-id="linux"&gt;&lt;rect x="8" y="26" width="174" height="227" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-cluster-label" fill="var(--_m)" x="44.27" y="49.4" text-anchor="middle"&gt;Linux&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round"&gt;&lt;g class="pele-edge" data-id="L_vm2_q_0"&gt;&lt;path d="M95,108L95,146"/&gt;&lt;path class="pele-marker" d="M95,153L91.64,145L98.36,145Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_q_proxy_0"&gt;&lt;path d="M95,213L95,354"/&gt;&lt;path class="pele-marker" d="M95,361L91.64,353L98.36,353Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_vm1_ha_0"&gt;&lt;path d="M392.86,90L392.86,128"/&gt;&lt;path class="pele-marker" d="M392.86,135L389.5,127L396.22,127Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_ha_ok_0"&gt;&lt;path d="M384.86,213L384.86,331Q384.86,343 372.86,343L302.7,343Q294.45,343 294.45,351.25L294.45,354"/&gt;&lt;path class="pele-marker" d="M294.45,361L291.09,353L297.81,353Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;g class="pele-edge" data-id="L_ha_no_0"&gt;&lt;path d="M400.86,213L400.86,259Q400.86,271 412.86,271L479.27,271Q491.27,271 491.27,283L491.27,354" stroke-dasharray="3 4"/&gt;&lt;path class="pele-marker" d="M491.27,361L487.91,353L494.63,353Z" fill="var(--_l)" stroke="none"/&gt;&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-edge-labels" font-size="14"&gt;&lt;g class="pele-edge-label" data-id="L_q_proxy_0"&gt;&lt;rect x="19.73" y="291" width="150.55" height="32" rx="3" fill="var(--_bg)"/&gt;&lt;text text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="95" y="303.2"&gt;only to&lt;/tspan&gt;&lt;tspan x="95" y="319.2"&gt;192.168.5.4:3128&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_ha_ok_0"&gt;&lt;rect x="349.68" y="298" width="70.36" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="384.86" y="311.2" text-anchor="middle"&gt;allowed&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-edge-label" data-id="L_ha_no_0"&gt;&lt;rect x="460.55" y="298" width="61.45" height="18" rx="3" fill="var(--_bg)"/&gt;&lt;text x="491.27" y="311.2" text-anchor="middle"&gt;denied&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;g class="pele-nodes"&gt;&lt;g class="pele-node pele-shape-rect" data-id="vm2" transform="translate(95,85.5)"&gt;&lt;rect x="-44.73" y="-22.5" width="89.45" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;the VM&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="q" transform="translate(95,183)"&gt;&lt;rect x="-67" y="-30" width="134" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;QEMU,&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;restrict=on&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="proxy" transform="translate(95,383.5)"&gt;&lt;rect x="-58.09" y="-22.5" width="116.18" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;its proxy&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="vm1" transform="translate(392.86,67.5)"&gt;&lt;rect x="-44.73" y="-22.5" width="89.45" height="45" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" x="0" y="4.9" text-anchor="middle"&gt;the VM&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="ha" transform="translate(392.86,174)"&gt;&lt;rect x="-62.55" y="-39" width="125.09" height="78" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-13.1"&gt;its Lima&lt;/tspan&gt;&lt;tspan x="0" y="4.9"&gt;hostagent,&lt;/tspan&gt;&lt;tspan x="0" y="22.9"&gt;sandboxed&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="ok" transform="translate(294.45,409)"&gt;&lt;rect x="-89.27" y="-48" width="178.55" height="96" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-22.1"&gt;its ssh port&lt;/tspan&gt;&lt;tspan x="0" y="-4.1"&gt;its proxy&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;its Lima sockets&lt;/tspan&gt;&lt;tspan x="0" y="31.9"&gt;its SSH agent&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;g class="pele-node pele-shape-rect" data-id="no" transform="translate(491.27,391)"&gt;&lt;rect x="-62.55" y="-30" width="125.09" height="60" fill="var(--_s)" stroke="var(--_b)" style="rx:var(--_r)"/&gt;&lt;text class="pele-label" text-anchor="middle" xml:space="preserve"&gt;&lt;tspan x="0" y="-4.1"&gt;everything&lt;/tspan&gt;&lt;tspan x="0" y="13.9"&gt;else&lt;/tspan&gt;&lt;/text&gt;
&lt;/g&gt;&lt;/g&gt;&lt;/svg&gt;&lt;/div&gt;&lt;p&gt;On macOS, devvm starts the VM&amp;rsquo;s Lima process, its hostagent, under a macOS sandbox. That&amp;rsquo;s &lt;code&gt;sandbox-exec&lt;/code&gt; with a Seatbelt profile, &lt;code&gt;sandbox.sb&lt;/code&gt; in the VM&amp;rsquo;s run folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The profile lets the process connect to the VM&amp;rsquo;s ssh port and its proxy on the host&amp;rsquo;s loopback, to the unix sockets in the VM&amp;rsquo;s Lima folder (ssh&amp;rsquo;s control socket and the VM&amp;rsquo;s network), and to the socket of the ssh agent the VM forwards, which is its proxy&amp;rsquo;s relay of your agent or devvm&amp;rsquo;s own (&lt;a href="https://next.devvm.dev/docs/internals/processes/#the-ssh-agents"&gt;the SSH agents&lt;/a&gt;). It connects nowhere else, so other sockets on the host, such as Docker&amp;rsquo;s, stay out of the hostagent&amp;rsquo;s reach. The profile limits only the network, so a compromised hostagent can still write your files, and through them run code as you.&lt;/li&gt;
&lt;li&gt;The profile lets the process listen only on the VM&amp;rsquo;s ssh port, over TCP, and on unix sockets in the VM&amp;rsquo;s Lima folder, so it can&amp;rsquo;t open a port of the VM&amp;rsquo;s on the host even if Lima ignored its rules (&lt;a href="#ports"&gt;ports&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Names resolve in the proxy, so Lima&amp;rsquo;s own DNS server for the VM is off, and the guest&amp;rsquo;s DNS points at &lt;code&gt;127.0.0.1&lt;/code&gt;, which only &lt;a href="https://next.devvm.dev/docs/internals/network/#tools-that-skip-the-proxy"&gt;transparent mode&lt;/a&gt; answers, inside the VM, with no upstream. Without it, nothing listens there, and a lookup through the system&amp;rsquo;s resolver, such as the ones &lt;code&gt;getent&lt;/code&gt; and curl make, asks &lt;code&gt;127.0.0.1&lt;/code&gt; itself (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-vms-resolver"&gt;the VM&amp;rsquo;s resolver&lt;/a&gt;) and fails at once on macOS and on a Linux host alike. The guest reaches the proxy at &lt;code&gt;192.168.5.2&lt;/code&gt;, which is the host as Lima&amp;rsquo;s network sees it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On Linux, Lima starts every VM&amp;rsquo;s QEMU through a wrapper that devvm writes (&lt;code&gt;~/.local/share/devvm/run/qemu/&lt;/code&gt;) and that runs devvm. It runs QEMU in a namespace that makes &lt;code&gt;.git&lt;/code&gt;&amp;rsquo;s hooks and config read-only, for a VM whose &lt;a href="https://next.devvm.dev/docs/internals/git-protection/#on-linux-hosts"&gt;.git protection&lt;/a&gt; is on. For a confined VM, the wrapper adds QEMU&amp;rsquo;s &lt;code&gt;restrict=on&lt;/code&gt; to Lima&amp;rsquo;s network, so no traffic goes in or out but Lima&amp;rsquo;s own forwards. It also adds one address, &lt;code&gt;192.168.5.4:3128&lt;/code&gt;, which QEMU connects to the VM&amp;rsquo;s proxy through a process for each connection, at most 256 at once (&lt;a href="https://next.devvm.dev/docs/internals/processes/#the-qemu-wrapper-and-its-keeper"&gt;the QEMU wrapper&lt;/a&gt;). If Lima&amp;rsquo;s QEMU arguments aren&amp;rsquo;t the shape devvm expects, with one &lt;code&gt;-netdev user,id=net0,…&lt;/code&gt; and no other network, the wrapper refuses to start QEMU (&lt;code&gt;qemu_refused&lt;/code&gt;), so QEMU never runs unrestricted. DNS points at &lt;code&gt;127.0.0.1&lt;/code&gt; in the guest, which only transparent mode answers, and without it lookups fail at once.&lt;/p&gt;
&lt;p&gt;An open VM isn&amp;rsquo;t confined: on macOS its hostagent runs without a profile, and on Linux the wrapper runs QEMU with Lima&amp;rsquo;s network as Lima gives it, without &lt;code&gt;restrict=on&lt;/code&gt; and without the &lt;code&gt;guestfwd&lt;/code&gt;, as it does for a build with the internet. Its guest reaches its proxy at &lt;code&gt;192.168.5.2&lt;/code&gt; and the proxy&amp;rsquo;s own port on both hosts, because Lima&amp;rsquo;s user-mode network, vz&amp;rsquo;s and QEMU&amp;rsquo;s alike, reaches the host&amp;rsquo;s loopback at that address. Its &lt;code&gt;NO_PROXY&lt;/code&gt; adds &lt;code&gt;host.lima.internal&lt;/code&gt; and &lt;code&gt;192.168.5.2&lt;/code&gt;, which the proxy on the host couldn&amp;rsquo;t resolve as the VM does, Lima&amp;rsquo;s DNS stays on, so names resolve in the VM, and &lt;code&gt;propagateProxyEnv&lt;/code&gt; is off, so the guest gets no proxy settings of the host&amp;rsquo;s.&lt;/p&gt;
&lt;p&gt;A process can&amp;rsquo;t leave its sandbox, so devvm records the hostagent it started (&lt;code&gt;started&lt;/code&gt; in the VM&amp;rsquo;s run folder) and checks that the VM still runs on it (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-self-check"&gt;the self-check&lt;/a&gt;). A VM started another way, such as with &lt;code&gt;limactl start&lt;/code&gt;, runs unconfined, and &lt;code&gt;devvm ls&lt;/code&gt; shows it as &lt;code&gt;unenforced&lt;/code&gt;. The VM&amp;rsquo;s proxy follows the hostagent&amp;rsquo;s pid file (&lt;code&gt;ha.pid&lt;/code&gt; in the VM&amp;rsquo;s Lima folder) and exits with it. devvm writes the record only once &lt;code&gt;limactl start&lt;/code&gt; returns, while the hostagent runs on its own from early in the start, so an interrupt during the start stops the VM (&lt;a href="https://next.devvm.dev/docs/internals/network/#how-long-a-proxy-runs"&gt;how long a proxy runs&lt;/a&gt;). Interrupted before the hostagent answers, the VM is one Lima reports as &lt;code&gt;Broken&lt;/code&gt;, which &lt;code&gt;limactl stop&lt;/code&gt; refuses, so devvm stops a broken VM with &lt;code&gt;limactl stop --force&lt;/code&gt;. A hostagent that runs without its driver yet is still starting QEMU, which writes its pid file only once it runs, and that can take seconds on a slow host, such as one with nested virtualization. Stopped with &lt;code&gt;--force&lt;/code&gt; then, the hostagent would go and the QEMU it started would run on without it, so devvm waits up to 30 seconds for the driver first and then stops the VM as Lima reports it. A VM whose QEMU still runs without its hostagent holds its disk, so no new QEMU can start on it, and a start stops such a VM with &lt;code&gt;--force&lt;/code&gt; first.&lt;/p&gt;
&lt;p&gt;Builds are also confined, because they run code devvm didn&amp;rsquo;t write. On macOS a build&amp;rsquo;s Lima process runs under a profile that reaches either the internet but not the host&amp;rsquo;s loopback, where other VMs&amp;rsquo; proxies and dev servers listen, or nothing at all. Behind a company proxy, a build with the internet also reaches one port of the host&amp;rsquo;s loopback, its own proxy&amp;rsquo;s (&lt;a href="https://next.devvm.dev/docs/contributing/design/#a-company-proxy"&gt;a company proxy&lt;/a&gt;). On Linux only a build with no network is confined. QEMU can&amp;rsquo;t keep the internet while dropping the host&amp;rsquo;s loopback, so other builds reach services on the host&amp;rsquo;s &lt;code&gt;localhost&lt;/code&gt;. Builds forward no ports. A build with the internet reaches your LAN on both hosts, this machine&amp;rsquo;s own address on it included, because the macOS profile keeps only the loopback from it.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sandbox-exec&lt;/code&gt; is deprecated. If macOS drops it, devvm needs another way to confine the hostagent, and until then the self-check catches a VM that runs unconfined.&lt;/p&gt;
&lt;h2 data-hextra-search-id="ports"&gt;Ports&lt;span class="hx:absolute hx:-mt-20" id="ports"&gt;&lt;/span&gt;
&lt;a href="#ports" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm&amp;rsquo;s forwarder forwards a Lima VM&amp;rsquo;s ports by the rules that &lt;a href="https://next.devvm.dev/docs/internals/ports/"&gt;Port forwarding&lt;/a&gt; sets out. On Lima this is an emulation, and it&amp;rsquo;s reviewed (&lt;a href="https://next.devvm.dev/docs/contributing/design/#ports-on-lima"&gt;design&lt;/a&gt;). devvm doesn&amp;rsquo;t use Lima&amp;rsquo;s own forwards because they listen with &lt;code&gt;SO_REUSEADDR&lt;/code&gt;, and on macOS such a forward takes &lt;code&gt;127.0.0.1:PORT&lt;/code&gt; while a program on the host has &lt;code&gt;*:PORT&lt;/code&gt;, along with that program&amp;rsquo;s &lt;code&gt;localhost&lt;/code&gt; connections.&lt;/p&gt;
&lt;p&gt;So Lima forwards nothing. Each VM&amp;rsquo;s &lt;code&gt;portForwards&lt;/code&gt; are rules that ignore every guest port, TCP and UDP, on &lt;code&gt;127.0.0.1&lt;/code&gt; (which also covers &lt;code&gt;::1&lt;/code&gt;), &lt;code&gt;0.0.0.0&lt;/code&gt; and &lt;code&gt;::&lt;/code&gt;. Lima&amp;rsquo;s own ssh is its VM driver&amp;rsquo;s forward, not a rule, so it keeps working. devvm sets the rules when it makes the VM, and a start sets them again only where they differ, because any change gives the VM new ssh host keys at its next boot. On macOS, a confined VM doesn&amp;rsquo;t rely on the rules alone, because its sandbox refuses the Lima process every port but its ssh port (&lt;a href="#confinement"&gt;confinement&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Which ports a VM forwards is in the VM&amp;rsquo;s state, which devvm&amp;rsquo;s forwarder reads, so &lt;code&gt;devvm ports&lt;/code&gt; changes the state and never the VM&amp;rsquo;s Lima config, and the backend never hears of them. &lt;a href="https://next.devvm.dev/docs/internals/ports/#its-process-and-files"&gt;Its process and files&lt;/a&gt; lists the forwarder&amp;rsquo;s files and its log.&lt;/p&gt;
&lt;p&gt;The forwarder isn&amp;rsquo;t Lima&amp;rsquo;s, and it runs only for project VMs. What Lima gives it is how to reach a running VM: Lima&amp;rsquo;s ssh port on this machine&amp;rsquo;s loopback, Lima&amp;rsquo;s user, and Lima&amp;rsquo;s key (&lt;code&gt;_config/user&lt;/code&gt; in devvm&amp;rsquo;s Lima home), which every VM there authorizes. The forwarder connects there with the host keys devvm pinned for the VM&amp;rsquo;s current start, which the VM&amp;rsquo;s ssh config checks too. Its lifeline is the VM&amp;rsquo;s hostagent&amp;rsquo;s pid file (&lt;code&gt;ha.pid&lt;/code&gt;), so it ends when the hostagent does, and &lt;code&gt;devvm rm&lt;/code&gt; deletes its files.&lt;/p&gt;</description></item><item><title>Processes</title><link>https://next.devvm.dev/docs/internals/processes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/processes/</guid><description>
&lt;p&gt;This page goes through every process that devvm runs on this machine for a VM, one section each: what it holds, such as secrets and keys, the input a VM controls that it reads, what it writes and how far that can grow, how it&amp;rsquo;s confined, and who starts it and waits for it. Then it lists every listener on this machine whose bytes a VM controls, and why devvm is written in Go. The pages each section links to have the details, and the &lt;a href="https://next.devvm.dev/docs/internals/security/"&gt;security model&lt;/a&gt; has what these processes protect.&lt;/p&gt;
&lt;p&gt;Every process here runs as you. devvm runs its own long-running processes as itself, &lt;code&gt;devvm&lt;/code&gt; with a hidden command, so their code is the binary you installed, and the other long-running programs it runs are OpenSSH&amp;rsquo;s &lt;code&gt;ssh&lt;/code&gt; and &lt;code&gt;ssh-agent&lt;/code&gt;, Lima and, on Linux, QEMU.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Process&lt;/th&gt;
&lt;th&gt;Started by&lt;/th&gt;
&lt;th&gt;Ends&lt;/th&gt;
&lt;th&gt;Confinement&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#devvm-itself"&gt;devvm itself&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;you&lt;/td&gt;
&lt;td&gt;when its command ends&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#a-vms-proxy"&gt;A VM&amp;rsquo;s proxy&lt;/a&gt;: its broker, &lt;code&gt;devvm _proxy&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;each start of the VM&lt;/td&gt;
&lt;td&gt;with the VM&amp;rsquo;s hostagent, its child, or &lt;code&gt;devvm stop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#a-vms-proxy"&gt;A VM&amp;rsquo;s proxy&lt;/a&gt;: its child, &lt;code&gt;devvm _proxy-child&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the broker&lt;/td&gt;
&lt;td&gt;with its broker&lt;/td&gt;
&lt;td&gt;a Seatbelt profile on macOS, and Landlock and a seccomp filter on Linux (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-childs-sandbox"&gt;the child&amp;rsquo;s sandbox&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#a-builds-proxy"&gt;A build&amp;rsquo;s proxy&lt;/a&gt;, &lt;code&gt;devvm _proxy&lt;/code&gt; and its child&lt;/td&gt;
&lt;td&gt;a build behind a company proxy&lt;/td&gt;
&lt;td&gt;with the build&lt;/td&gt;
&lt;td&gt;its child&amp;rsquo;s, as a VM&amp;rsquo;s proxy&amp;rsquo;s child&amp;rsquo;s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#the-port-forwarder"&gt;The port forwarder&lt;/a&gt;, &lt;code&gt;devvm _ports&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;each start of a project VM, and each change of its ports&lt;/td&gt;
&lt;td&gt;with the VM&amp;rsquo;s hostagent, or &lt;code&gt;devvm stop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#the-link-session"&gt;The link session&lt;/a&gt;, &lt;code&gt;devvm _links&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a start or a change of links, for a client with links&lt;/td&gt;
&lt;td&gt;when the client stops or has no links, or &lt;code&gt;devvm stop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#ssh-masters-and-relays"&gt;ssh masters and relays&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;the forwarder, the link session and devvm&lt;/td&gt;
&lt;td&gt;with the process that started them&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#the-qemu-wrapper-and-its-keeper"&gt;The QEMU wrapper&lt;/a&gt;, &lt;code&gt;devvm _qemu&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Lima, on Linux hosts&lt;/td&gt;
&lt;td&gt;with QEMU&lt;/td&gt;
&lt;td&gt;QEMU&amp;rsquo;s restricted network, and a user namespace for a VM with &lt;code&gt;.git&lt;/code&gt; pins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#the-daily-tools-check"&gt;The daily tools check&lt;/a&gt;, &lt;code&gt;devvm _refresh-tools&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a launch of an existing VM, once a day&lt;/td&gt;
&lt;td&gt;when the check is done&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#the-desktop-relay"&gt;The desktop relay&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;devvm desktop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;with &lt;code&gt;devvm desktop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#the-ssh-agents"&gt;The SSH agents&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;you, or &lt;code&gt;devvm&lt;/code&gt; for devvm&amp;rsquo;s own&lt;/td&gt;
&lt;td&gt;devvm&amp;rsquo;s own: at logout or a reboot&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#limas-hostagent"&gt;Lima&amp;rsquo;s hostagent&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;limactl start&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;when the VM stops&lt;/td&gt;
&lt;td&gt;a Seatbelt profile on macOS, for a confined VM or a build&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 data-hextra-search-id="how-devvm-starts-them"&gt;How devvm starts them&lt;span class="hx:absolute hx:-mt-20" id="how-devvm-starts-them"&gt;&lt;/span&gt;
&lt;a href="#how-devvm-starts-them" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm starts the proxy, the port forwarder, the link session and the daily tools check detached, in a session of their own, so they outlive the run that started them and the terminal it ran in (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt;). Each gets no input and devvm&amp;rsquo;s environment without &lt;code&gt;SSH_AUTH_SOCK&lt;/code&gt;, so none of them uses your SSH agent of its own accord, and its output goes to its own log or nowhere. The one exception is a VM&amp;rsquo;s proxy, which relays the agent that the VM&amp;rsquo;s start forwards, named in its config (&lt;a href="#the-ssh-agents"&gt;the SSH agents&lt;/a&gt;). devvm marks every file it was given past standard input, output and error close-on-exec as it starts, so a terminal or a pipe that devvm inherited never stays open in them (&lt;a href="https://next.devvm.dev/docs/contributing/design/#things-learned"&gt;things learned&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;devvm finds such a process again by its pid file and its arguments, and it signals a process only while both still say it&amp;rsquo;s that process, so a pid that the system gave another program since is never signalled. A stop sends &lt;code&gt;SIGTERM&lt;/code&gt;, waits two seconds, and sends &lt;code&gt;SIGKILL&lt;/code&gt; only to a process whose arguments are still the ones devvm started. Each signal goes to the process&amp;rsquo;s group, which its own session makes it the leader of, so what it started ends with it, such as the forwarder&amp;rsquo;s and the link session&amp;rsquo;s ssh masters and relays, even when it&amp;rsquo;s killed and can&amp;rsquo;t stop them itself. A forwarder or a link session that gets &lt;code&gt;SIGTERM&lt;/code&gt; from anything else, such as &lt;code&gt;kill&lt;/code&gt;, stops its ssh before it exits, waiting up to two seconds for that, as devvm does for its cleanups. A process that devvm waits for, such as the proxy, says it&amp;rsquo;s ready in a status file of its own, which holds its pid and its address, so a file that another process left never counts (&lt;a href="https://next.devvm.dev/docs/internals/network/#how-long-a-proxy-runs"&gt;how long a proxy runs&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The run that starts a process reaps it if it ends first, and once that run ends, nothing on this machine waits for it. Instead, each one ends on its own. The proxy and the forwarder follow the VM&amp;rsquo;s hostagent through its pid file, &lt;code&gt;ha.pid&lt;/code&gt;, which is the VM&amp;rsquo;s lifeline, and the link session asks the VM&amp;rsquo;s backend every 5 seconds whether the VM still runs the start it was made for. &lt;code&gt;devvm stop&lt;/code&gt;, &lt;code&gt;devvm rm&lt;/code&gt; and &lt;code&gt;devvm gc --orphans&lt;/code&gt; stop a VM&amp;rsquo;s proxy, forwarder and link session while they still run.&lt;/p&gt;
&lt;h2 data-hextra-search-id="devvm-itself"&gt;devvm itself&lt;span class="hx:absolute hx:-mt-20" id="devvm-itself"&gt;&lt;/span&gt;
&lt;a href="#devvm-itself" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Holds:&lt;/strong&gt; everything you keep with devvm. It reads secrets from the macOS Keychain with the &lt;code&gt;security&lt;/code&gt; command or from files only you can read, and it writes each VM&amp;rsquo;s proxy password and the company proxy&amp;rsquo;s credentials into files only you can read, never into a process&amp;rsquo;s arguments (&lt;a href="https://next.devvm.dev/docs/internals/network/#where-secrets-are-saved"&gt;where secrets are saved&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads from a VM:&lt;/strong&gt; the output of the commands it runs there, such as a VM&amp;rsquo;s host keys, its settings to save and a history export, and the files a VM can write or swap, such as the project folder&amp;rsquo;s &lt;code&gt;devcontainer.json&lt;/code&gt;. It reads such a file without following a link out of the folder, and with a cap on its size, and each kind of output has a cap of its own, such as 128 MiB for a VM&amp;rsquo;s settings and 2 GiB for a history export (&lt;a href="https://next.devvm.dev/docs/internals/agents/#saving-a-vms-settings"&gt;coding agents&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes:&lt;/strong&gt; its run log, &lt;code&gt;~/.local/share/devvm/logs/runs/&amp;lt;date&amp;gt;-&amp;lt;time&amp;gt;-&amp;lt;pid&amp;gt;.log&lt;/code&gt;, with at most 4 MiB of output for each command it runs in a VM and at most 128 MiB in all, after which one line says the rest was left out. It keeps the newest 20 logs, or as many as &lt;code&gt;logs.runs&lt;/code&gt; sets, and deletes older ones once the logs take more than 256 MiB together. It never deletes the newest log, or one whose run still runs, which it tells from the pid in the log&amp;rsquo;s name. It writes state files whole, renamed into place (&lt;a href="https://next.devvm.dev/docs/internals/overview/#state-files"&gt;state files&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Listens:&lt;/strong&gt; only in &lt;code&gt;devvm desktop&lt;/code&gt; (&lt;a href="#the-desktop-relay"&gt;the desktop relay&lt;/a&gt;) and while &lt;code&gt;devvm agent login&lt;/code&gt; waits for a browser&amp;rsquo;s login (&lt;a href="#listeners-a-vm-reaches"&gt;listeners&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Confinement:&lt;/strong&gt; none. devvm needs your Keychain and your files, and it&amp;rsquo;s the program you chose to run.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="a-vms-proxy"&gt;A VM&amp;rsquo;s proxy&lt;span class="hx:absolute hx:-mt-20" id="a-vms-proxy"&gt;&lt;/span&gt;
&lt;a href="#a-vms-proxy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Each running VM&amp;rsquo;s proxy is two processes, so the code that reads every byte the VM sends never holds what only the host should. The two are a broker, &lt;code&gt;devvm _proxy -config FILE&lt;/code&gt;, with the VM&amp;rsquo;s &lt;code&gt;proxy.json&lt;/code&gt; in its run folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/run/&lt;/code&gt;, and its child, &lt;code&gt;devvm _proxy-child -for FILE&lt;/code&gt;, which the broker starts and which reads the VM&amp;rsquo;s network (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-proxy"&gt;the proxy&lt;/a&gt;). The child asks the broker over a socketpair between them for a bound value, a changed file, a connection to a link, a login&amp;rsquo;s token exchange, a name&amp;rsquo;s addresses and a connection to an address or the company proxy, each by something the broker finds in its own config, which is one VM&amp;rsquo;s (&lt;a href="https://next.devvm.dev/docs/contributing/design/#the-proxys-broker"&gt;the proxy&amp;rsquo;s broker&lt;/a&gt; has the design and its threat check).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The broker:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Holds:&lt;/strong&gt; the VM&amp;rsquo;s password and the company proxy&amp;rsquo;s credentials, which it reads from the config and hands the child as it starts. It looks up each bound secret&amp;rsquo;s value itself, through the Keychain or the secret&amp;rsquo;s file, keeps a value for 5 minutes, an agent&amp;rsquo;s login for 30 seconds and a failed lookup for 5 seconds, and drops them all when the VM&amp;rsquo;s bindings change. It reads the agents&amp;rsquo; login files in devvm&amp;rsquo;s store and refreshes their OAuth logins there, and it sends each login that the VM makes to the agent&amp;rsquo;s token endpoint itself, saves it into the store and rewrites the VM&amp;rsquo;s bindings, so a login&amp;rsquo;s real tokens never reach the child (&lt;a href="https://next.devvm.dev/docs/internals/network/#logins-made-in-a-vm"&gt;logins made in a VM&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads from the VM:&lt;/strong&gt; the child&amp;rsquo;s frames, each at most 2 MiB, and through them a login&amp;rsquo;s token request, at most 64 KiB of headers and 64 KiB of body, and its endpoint&amp;rsquo;s reply, at most 1 MiB. It also reads your policy files and the VM&amp;rsquo;s bindings, each at most 1 MiB, and the links&amp;rsquo; list, &lt;code&gt;links.json&lt;/code&gt;, at most 1 MiB, which &lt;code&gt;devvm _links&lt;/code&gt; writes. It reads them for the child once they change, reads the bindings and the links&amp;rsquo; list again at each request that uses them, and reads the policy files again at each connection it opens for the child. For a VM that forwards an SSH agent, it reads the agent&amp;rsquo;s requests that the VM sends, each at most 256 KiB (&lt;a href="#the-ssh-agents"&gt;the SSH agents&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes:&lt;/strong&gt; its own lines in &lt;code&gt;proxy.log&lt;/code&gt;, its child&amp;rsquo;s pid file, &lt;code&gt;run/proxy-child.pid&lt;/code&gt;, and how the child is confined, &lt;code&gt;run/proxy.confined&lt;/code&gt;, and the login files and bindings above. It also holds the logs that the VM&amp;rsquo;s backend writes as the VM runs to 10 MiB each, with a &lt;code&gt;.1&lt;/code&gt; file of as much, the VM&amp;rsquo;s serial console&amp;rsquo;s among them, looking at each every second in a goroutine of its own (&lt;a href="#limas-hostagent"&gt;Lima&amp;rsquo;s hostagent&lt;/a&gt;), because they&amp;rsquo;re in the backend&amp;rsquo;s folder for the VM, beside its disk, which the child must never write. A proxy that an older devvm started doesn&amp;rsquo;t hold them, so a VM that&amp;rsquo;s running when you upgrade gets this once its next devvm command starts its proxy again.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bounds:&lt;/strong&gt; one value, 8 token exchanges, 4 files, 256 links, 256 lookups and 1024 connections at once from its child, and an error for a request past them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connects:&lt;/strong&gt; for the child, to an address only once its own read of the VM&amp;rsquo;s policy files and of this machine&amp;rsquo;s addresses allows it, as the floor does, and to the company proxy of its config, each within 15 seconds. It also looks up names through this machine&amp;rsquo;s resolver for the child, each within 20 seconds.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Listens:&lt;/strong&gt; on the VM&amp;rsquo;s agent socket, &lt;code&gt;~/.local/share/devvm/run/agent-&amp;lt;hash&amp;gt;.sock&lt;/code&gt;, for a VM that forwards an SSH agent. It also opens the VM&amp;rsquo;s proxy port and hands the listener to its child (&lt;a href="#listeners-a-vm-reaches"&gt;listeners&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Confinement:&lt;/strong&gt; none. It runs as you, with your Keychain and your files.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Starts and ends:&lt;/strong&gt; devvm starts it before each start of the VM, on every tier, and waits up to 5 seconds for it to say it&amp;rsquo;s listening. The broker says so once its child has said it&amp;rsquo;s ready, within 4 seconds of the broker&amp;rsquo;s start. It exits when the hostagent it follows ends, 15 minutes after it starts if the hostagent never appears, or when its child ends, and &lt;code&gt;devvm stop&lt;/code&gt; also stops it (&lt;a href="https://next.devvm.dev/docs/internals/network/#how-long-a-proxy-runs"&gt;how long a proxy runs&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;The child:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Holds:&lt;/strong&gt; the VM&amp;rsquo;s password, the VM&amp;rsquo;s CA and the next one, with their keys, the company proxy&amp;rsquo;s credentials, and each value that the broker gave it, until the broker&amp;rsquo;s lookup of that value is as old as the broker keeps one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads from the VM:&lt;/strong&gt; every request the VM sends. It takes at most 64 KiB of a request&amp;rsquo;s headers within 30 seconds, also in an intercepted or transparent connection, and it requires the VM&amp;rsquo;s password before anything else. It reads a ClientHello of at most 16 KiB and 256 bytes within 10 seconds of its first byte. It looks at the changing files with &lt;code&gt;stat&lt;/code&gt; alone and asks the broker for one once it changed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes:&lt;/strong&gt; its event log, &lt;code&gt;network.jsonl&lt;/code&gt;, and its own lines in &lt;code&gt;proxy.log&lt;/code&gt;, in the VM&amp;rsquo;s logs folder, &lt;code&gt;~/.local/share/devvm/vms/&amp;lt;hash&amp;gt;/logs/&lt;/code&gt;, each rotated before it passes 10 MiB, with one &lt;code&gt;.1&lt;/code&gt; file kept (&lt;a href="https://next.devvm.dev/docs/internals/network/#log-files"&gt;log files&lt;/a&gt;). Its HTTP server&amp;rsquo;s errors go to &lt;code&gt;proxy.log&lt;/code&gt; too, and so does what reaches either process&amp;rsquo;s error output, which counts toward the 10 MiB. For a VM with the nix layer, it fills the &lt;a href="https://next.devvm.dev/docs/internals/network/#the-shared-nix-cache"&gt;shared Nix cache&lt;/a&gt;, at most 10 GiB unless its config sets another cap. It reads and writes nothing else of yours or devvm&amp;rsquo;s.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bounds:&lt;/strong&gt; at most 8448 open files, a limit it sets on itself before it&amp;rsquo;s confined, at most 1024 &lt;code&gt;CONNECT&lt;/code&gt; tunnels at once, at most 2048 connections of every kind with the VM&amp;rsquo;s password, plain HTTP and idle ones included, at most 128 more that haven&amp;rsquo;t sent the password yet, and at most 2048 requests to hosts under way, its tunnels&amp;rsquo; included. It keeps at most 1024 of the certificates it made for intercepted hosts for each CA, dropping the one used longest ago. A connection to the proxy, and the HTTP inside an intercepted or transparent connection, waits at most 10 minutes between requests, and HTTP/2 inside one carries at most 100 requests at once. A request without the VM&amp;rsquo;s password gets its &lt;code&gt;407&lt;/code&gt; and its connection closed. A plain HTTP request whose client has stopped sending goes on while its answer keeps coming, and ends after a minute with nothing to pass on, so a client that went away frees what its request holds (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-proxy"&gt;the proxy&lt;/a&gt;). Nothing bounds how long a request or a tunnel lasts, so long downloads, WebSockets and slow streams go on.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Listens:&lt;/strong&gt; on &lt;code&gt;127.0.0.1&lt;/code&gt;, on the VM&amp;rsquo;s proxy port, through the listener the broker opened (&lt;a href="#listeners-a-vm-reaches"&gt;listeners&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connects:&lt;/strong&gt; nowhere itself. It asks the broker to look up each name and to open each connection to a host or to the company proxy, and the broker hands it the connection, so it reaches this machine&amp;rsquo;s loopback, its own addresses and the private and link-local ranges only where a rule names the address, or through a company proxy (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-childs-sandbox"&gt;the child&amp;rsquo;s sandbox&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inherits:&lt;/strong&gt; standard input from the null device, &lt;code&gt;proxy.log&lt;/code&gt; as its output and its error output, the socket to the broker as descriptor 3 and the listener as descriptor 4, and from the environment only &lt;code&gt;TZ&lt;/code&gt;, &lt;code&gt;SSL_CERT_FILE&lt;/code&gt;, &lt;code&gt;SSL_CERT_DIR&lt;/code&gt; and &lt;code&gt;GODEBUG&lt;/code&gt;. Run by hand without those two sockets, it refuses to start.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Confinement:&lt;/strong&gt; on macOS, a Seatbelt profile that denies everything but what the child needs, from its first instruction, because the broker starts it through &lt;code&gt;/usr/bin/sandbox-exec&lt;/code&gt; with the profile as an argument, never as a file (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-childs-sandbox"&gt;the child&amp;rsquo;s sandbox&lt;/a&gt;). The profile lets it run and read devvm&amp;rsquo;s binary, write regular files in its logs folder and the shared Nix cache, look at the changing files with &lt;code&gt;stat&lt;/code&gt;, and ask &lt;code&gt;trustd&lt;/code&gt; to check certificates. It denies the child your home folder, devvm&amp;rsquo;s other folders, the Keychain, every connection of its own, over TCP, UDP or a unix socket, a bind, a fork, a signal to another process, and a look at another process, its arguments included. The child checks that the sandbox holds before it says it&amp;rsquo;s ready, and it says how it&amp;rsquo;s confined in &lt;code&gt;run/proxy.confined&lt;/code&gt;, which is &lt;code&gt;full seatbelt&lt;/code&gt; when it is. The broker adds a second line with its pid and when the system says it started, and devvm doctor reads the file only when that line names the broker that runs now. So doctor ignores a file that a newer devvm&amp;rsquo;s broker left behind when, after a downgrade, an older devvm started the VM&amp;rsquo;s proxy, and it names that proxy as one an older devvm started. When doctor can&amp;rsquo;t read when the running broker started, it says it can&amp;rsquo;t tell whether the proxy runs in its sandbox. Where &lt;code&gt;sandbox-exec&lt;/code&gt; is missing or fails to start it, the broker starts it unconfined, writes a warning in &lt;code&gt;proxy.log&lt;/code&gt;, and devvm doctor warns while the VM runs (&lt;a href="https://next.devvm.dev/docs/using/troubleshooting/#the-proxy-runs-without-a-sandbox"&gt;the proxy runs without a sandbox&lt;/a&gt;). On Linux it confines itself before it reads a byte of the VM&amp;rsquo;s. It sets &lt;code&gt;no_new_privs&lt;/code&gt;, limits itself to the same folders with Landlock, and installs a seccomp filter that refuses it every socket but a netlink route socket, &lt;code&gt;connect&lt;/code&gt;, TCP Fast Open, a listen, &lt;code&gt;io_uring&lt;/code&gt;, the calls that reach another process, a change to a file&amp;rsquo;s metadata by its path, the kernel&amp;rsquo;s keyrings, a program, a process or a namespace of its own. It says &lt;code&gt;full landlock&lt;/code&gt; when the kernel has Landlock&amp;rsquo;s ABI 6 and its fix for signals between threads. An older kernel confines it in part, which it says, and the broker and devvm doctor warn of it the same way.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Starts and ends:&lt;/strong&gt; the broker starts it, devvm&amp;rsquo;s own binary, by its real path on macOS and as &lt;code&gt;/proc/self/exe&lt;/code&gt; on Linux, and on Linux the system kills it when the broker&amp;rsquo;s thread that started it ends. It ends when it reads the end of its socket to the broker. It then stops listening, closes every connection it accepted, including the tunnels it carries and the WebSocket upgrades it passes on, and refuses one that arrives after that. It then waits for the handlers to return, 5 seconds at most, because Go&amp;rsquo;s HTTP server neither closes a connection that a handler took from it nor waits for a handler. When the hostagent ends, the broker closes the socket and kills the child a second past those 5 seconds. &lt;code&gt;devvm stop&lt;/code&gt;&amp;rsquo;s &lt;code&gt;SIGTERM&lt;/code&gt; reaches the broker, which sends the child &lt;code&gt;SIGTERM&lt;/code&gt;, which ends it at once, and kills it if it hasn&amp;rsquo;t ended within a second. A child that ends, however it ends, ends its broker, and neither starts the other again.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="a-builds-proxy"&gt;A build&amp;rsquo;s proxy&lt;span class="hx:absolute hx:-mt-20" id="a-builds-proxy"&gt;&lt;/span&gt;
&lt;a href="#a-builds-proxy" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A build gets a proxy of its own only behind a company proxy, because a build VM otherwise reaches the internet directly (&lt;a href="https://next.devvm.dev/docs/contributing/design/#a-company-proxy"&gt;a company proxy&lt;/a&gt;). It&amp;rsquo;s the same &lt;code&gt;devvm _proxy&lt;/code&gt; broker and its child, with a config in the build VM&amp;rsquo;s &lt;code&gt;run/build-proxy&lt;/code&gt; folder, which devvm makes again for each build.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Holds:&lt;/strong&gt; a password made for the build, and the company proxy&amp;rsquo;s credentials. It has no CA, no secrets, no links and no Nix cache, so its broker looks up only the &lt;code&gt;proxy&lt;/code&gt; secret, when &lt;code&gt;config.toml&lt;/code&gt;&amp;rsquo;s company proxy names one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads from the build:&lt;/strong&gt; its requests, in the child, with the same checks as a VM&amp;rsquo;s proxy, under a policy that allows any host on ports 80 and 443, but not this machine&amp;rsquo;s own or internal addresses.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes:&lt;/strong&gt; &lt;code&gt;events.jsonl&lt;/code&gt; and &lt;code&gt;proxy.log&lt;/code&gt;, in the build proxy&amp;rsquo;s &lt;code&gt;logs/&lt;/code&gt; folder, which its child writes and which holds nothing else of the build proxy&amp;rsquo;s, each rotated as a VM&amp;rsquo;s proxy rotates its own. devvm deletes the build proxy&amp;rsquo;s folder after a build that succeeds and keeps it after one that fails. The build&amp;rsquo;s devvm process holds the build VM&amp;rsquo;s own logs to their caps, with a company proxy or without one, as a VM&amp;rsquo;s proxy holds a VM&amp;rsquo;s.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Confinement:&lt;/strong&gt; none for the broker. Its child is confined as a VM&amp;rsquo;s proxy&amp;rsquo;s child is, under the same Seatbelt profile on macOS and with Landlock and the seccomp filter on Linux, and its only folder is the build proxy&amp;rsquo;s &lt;code&gt;logs/&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Starts and ends:&lt;/strong&gt; the build starts its broker, keeps its process and stops it when the build ends, which ends the child as &lt;code&gt;devvm stop&lt;/code&gt; does, and a cleanup stops it when the build fails or is interrupted. It also follows the build VM&amp;rsquo;s hostagent, as a VM&amp;rsquo;s proxy does.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="the-port-forwarder"&gt;The port forwarder&lt;span class="hx:absolute hx:-mt-20" id="the-port-forwarder"&gt;&lt;/span&gt;
&lt;a href="#the-port-forwarder" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;One forwarder runs for each running project VM that forwards ports, as &lt;code&gt;devvm _ports&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/ports/#its-process-and-files"&gt;its process and files&lt;/a&gt;).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Holds:&lt;/strong&gt; the key that the backend logs in to the VM with, which on Lima is Lima&amp;rsquo;s &lt;code&gt;_config/user&lt;/code&gt;, and the VM&amp;rsquo;s host keys for its current start. Its ssh uses no agent.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads from the VM:&lt;/strong&gt; the VM&amp;rsquo;s report of the ports it listens on, which comes over one ssh session about every 10 seconds, as the VM paces it. A line of the report has at most 127 bytes and its newline, and a longer line, or a report of more than 4096 lines, ends the session, which the forwarder opens again, so nothing is cut. The forwarder applies at most one report every 500 ms. It also reads the bytes of each forwarded connection, which it carries as they are, and the other VMs&amp;rsquo; records of their ports.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes:&lt;/strong&gt; &lt;code&gt;ports.forwarded&lt;/code&gt; in the VM&amp;rsquo;s run folder, and its log, &lt;code&gt;ports.log&lt;/code&gt;, in the VM&amp;rsquo;s logs folder. The VM chooses some of what goes in the log, so the forwarder makes at most 200 writes at once and then one every 10 seconds, each cut at 512 bytes and without control characters other than newlines and tabs. The log is also its process&amp;rsquo;s output, and before each line the forwarder checks its size on disk, so a line that would take it past 1 MiB rotates it first. The log&amp;rsquo;s end goes to &lt;code&gt;ports.log.1&lt;/code&gt;, replacing the one there, and the log starts empty. devvm rotates a log that an earlier forwarder left past 1 MiB as it starts the next one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bounds:&lt;/strong&gt; at most 256 forwards, and at most 256 connections at once. When accepting a connection fails while the port still listens, such as when the forwarder runs out of open files, it tries again after a wait that starts at 5 ms and doubles with each failure in a row, up to a second, and logs only the first failure of a run, as the link session and a login&amp;rsquo;s forward do.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Listens:&lt;/strong&gt; on &lt;code&gt;127.0.0.1&lt;/code&gt; and &lt;code&gt;::1&lt;/code&gt; for each forwarded port (&lt;a href="#listeners-a-vm-reaches"&gt;listeners&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Confinement:&lt;/strong&gt; none. Its ssh processes get the higher limit of open files that devvm runs with.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Starts and ends:&lt;/strong&gt; devvm starts it once the backend says the VM runs, and again when the VM&amp;rsquo;s ports change. It exits once the VM&amp;rsquo;s hostagent is gone, which it checks every 2 seconds, and &lt;code&gt;devvm stop&lt;/code&gt;, &lt;code&gt;devvm rm&lt;/code&gt; and &lt;code&gt;devvm gc --orphans&lt;/code&gt; stop it.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="the-link-session"&gt;The link session&lt;span class="hx:absolute hx:-mt-20" id="the-link-session"&gt;&lt;/span&gt;
&lt;a href="#the-link-session" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;One link session runs for each running client VM with &lt;a href="https://next.devvm.dev/docs/internals/ports/#links-between-vms"&gt;links&lt;/a&gt;, as &lt;code&gt;devvm _links VM&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/ports/#the-link-session"&gt;the link session&lt;/a&gt;).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Holds:&lt;/strong&gt; the login key and the pinned host keys of the client and of each target it connects to.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads from the VMs:&lt;/strong&gt; the bytes of each link&amp;rsquo;s connection, both ways, and the messages of the client&amp;rsquo;s sshd, such as its refusal of a forward, each cut at 512 bytes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes:&lt;/strong&gt; &lt;code&gt;links.json&lt;/code&gt; in the client&amp;rsquo;s run folder, the client&amp;rsquo;s event log, &lt;code&gt;network.jsonl&lt;/code&gt;, with the proxy&amp;rsquo;s own writer, so it rotates by the same rule, and its log, &lt;code&gt;links.log&lt;/code&gt;, in the client&amp;rsquo;s logs folder, which it writes, limits and rotates past 1 MiB as the forwarder does its own. Its warning that the client refused to listen for a link carries the client&amp;rsquo;s sshd&amp;rsquo;s words, and the client chooses how often it comes, so each warning takes its turn from the same limit as the log&amp;rsquo;s lines.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bounds:&lt;/strong&gt; at most 256 of the client&amp;rsquo;s connections at once.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Listens:&lt;/strong&gt; on a unix socket for each link, mode 600, in &lt;code&gt;~/.local/share/devvm/run&lt;/code&gt; (mode 700).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Confinement:&lt;/strong&gt; none.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Starts and ends:&lt;/strong&gt; a start of the client and a change of its links start it. It ends once the client no longer runs the start it was made for, which it checks every 5 seconds, or has no links left, and &lt;code&gt;devvm stop&lt;/code&gt; stops it with the client.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="ssh-masters-and-relays"&gt;ssh masters and relays&lt;span class="hx:absolute hx:-mt-20" id="ssh-masters-and-relays"&gt;&lt;/span&gt;
&lt;a href="#ssh-masters-and-relays" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The forwarder and the link session each reach a VM over one ssh connection of their own, its master. The forwarder&amp;rsquo;s master runs the VM&amp;rsquo;s report of its ports, and the link session keeps one master to the client, which asks for the links&amp;rsquo; remote forwards, and one to each target. Every master checks the VM&amp;rsquo;s pinned host key, sets &lt;code&gt;ControlPersist=no&lt;/code&gt;, and sends a keepalive every 10 seconds, giving up after 3 that get no answer.&lt;/p&gt;
&lt;p&gt;Each connection that the forwarder or the link session carries gets an ssh process of its own, a relay, which runs &lt;code&gt;ssh -W&lt;/code&gt;. A link&amp;rsquo;s relay can only ride on its target&amp;rsquo;s master. A forwarder&amp;rsquo;s relay rides on the VM&amp;rsquo;s master when it can, and it checks the same pinned host key either way, so it reaches only that VM.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Holds:&lt;/strong&gt; the login key, and no agent (&lt;code&gt;IdentityAgent=none&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads from the VM:&lt;/strong&gt; the bytes of the connection it carries.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes:&lt;/strong&gt; nothing of its own. A master&amp;rsquo;s messages go to its process&amp;rsquo;s log.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ends:&lt;/strong&gt; a relay ends when either side ends, when its forward or its link goes, and 30 seconds after the program on this machine closes its side if the VM sends nothing in that time (&lt;a href="https://next.devvm.dev/docs/internals/ports/#how-it-reaches-the-vm"&gt;how it reaches the VM&lt;/a&gt;). Each process that starts a master or a relay waits for it, and kills it when it ends that connection.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;devvm desktop&lt;/code&gt; and &lt;code&gt;devvm agent login&lt;/code&gt; start relays of their own, one ssh process for each connection, which rides on no master (&lt;code&gt;ControlMaster=no&lt;/code&gt;, &lt;code&gt;ControlPath=none&lt;/code&gt;). A login&amp;rsquo;s relay ends as the forwarder&amp;rsquo;s do, and a login carries at most 16 connections at once, closing any past that, so whatever else on this machine connects to its port can&amp;rsquo;t start ssh processes without end. A viewer&amp;rsquo;s ssh process gets 2 seconds to end once its viewer leaves, and is then killed.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-qemu-wrapper-and-its-keeper"&gt;The QEMU wrapper and its keeper&lt;span class="hx:absolute hx:-mt-20" id="the-qemu-wrapper-and-its-keeper"&gt;&lt;/span&gt;
&lt;a href="#the-qemu-wrapper-and-its-keeper" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;On Linux hosts, Lima starts each VM&amp;rsquo;s QEMU through a wrapper that devvm writes into &lt;code&gt;~/.local/share/devvm/run/qemu/&lt;/code&gt;, which runs &lt;code&gt;devvm _qemu exec&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;confinement&lt;/a&gt;).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;devvm _qemu exec&lt;/code&gt;&lt;/strong&gt; reads Lima&amp;rsquo;s arguments for QEMU and adds &lt;code&gt;restrict=on&lt;/code&gt; to Lima&amp;rsquo;s one network, except for an open VM and a build with the internet, and for a VM confined to its proxy it adds a &lt;code&gt;guestfwd&lt;/code&gt; to that proxy. It refuses arguments of any other shape (&lt;code&gt;qemu_refused&lt;/code&gt;). It then runs QEMU in its place, or, for a VM with &lt;code&gt;.git&lt;/code&gt; pins, which a VM whose &lt;a href="https://next.devvm.dev/docs/internals/git-protection/#on-linux-hosts"&gt;.git protection&lt;/a&gt; is on has, starts the keeper and waits for it. Only such a VM gets a user namespace.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The keeper, &lt;code&gt;devvm _qemu pinned&lt;/code&gt;,&lt;/strong&gt; runs in a user namespace and a mount namespace of its own, as you, with the capability to mount in that namespace alone. It makes &lt;code&gt;.git&lt;/code&gt;&amp;rsquo;s hooks and config read-only there, and it pins a path again after any change in a folder it watches, and every 2 seconds. It records each pin it makes again in &lt;code&gt;git-pins.jsonl&lt;/code&gt; in the VM&amp;rsquo;s run folder, and on QEMU&amp;rsquo;s error output, which Lima logs. Past 1 MiB, the file takes no more events, only a line for each that says it went unrecorded, up to 64 KiB more, and the next check names those. It starts QEMU through &lt;code&gt;devvm _qemu drop&lt;/code&gt;, which clears its ambient, permitted, effective and inheritable capabilities, keeping the bounding set, sets &lt;code&gt;no_new_privs&lt;/code&gt;, and runs QEMU.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;devvm _qemu probe DIR&lt;/code&gt;&lt;/strong&gt; checks, in a namespace of its own, that a file in DIR can be pinned.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;devvm _qemu connect&lt;/code&gt;&lt;/strong&gt; is what QEMU&amp;rsquo;s &lt;code&gt;guestfwd&lt;/code&gt; runs for each connection that the VM makes to &lt;code&gt;192.168.5.4:3128&lt;/code&gt;. It connects to the VM&amp;rsquo;s proxy and carries the bytes both ways, so it reads only what the VM sends to its proxy, which the proxy checks. Each one is a process of its own, about 7.7 MB of memory, so it carries at most 256 of the VM&amp;rsquo;s connections at once, about 2 GB for a VM that holds them all, each holding a slot, which is a lock file in the &lt;code&gt;proxy.slots&lt;/code&gt; folder of the VM&amp;rsquo;s run folder. A connection past that gets a &lt;code&gt;503&lt;/code&gt; and is closed before it reaches the proxy, and QEMU&amp;rsquo;s error output, which Lima logs, says so at most once a minute (&lt;code&gt;qemu_connects_full&lt;/code&gt;). A VM that was running when devvm was upgraded has no slots, and so no limit, until its next start. It has no idle timeout and no limit on the bytes it carries, because the proxy bounds what each connection carries, and a long download or a quiet stream must go on.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The keeper dies with &lt;code&gt;devvm _qemu exec&lt;/code&gt;, and QEMU with the keeper. &lt;code&gt;devvm _qemu connect&lt;/code&gt; ends when its connection ends, and its slot is free again.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-daily-tools-check"&gt;The daily tools check&lt;span class="hx:absolute hx:-mt-20" id="the-daily-tools-check"&gt;&lt;/span&gt;
&lt;a href="#the-daily-tools-check" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm _refresh-tools&lt;/code&gt; asks for the shared tools&amp;rsquo; newest versions once a day, so a later launch can offer them (&lt;a href="https://next.devvm.dev/docs/using/toolchains/"&gt;shared tools&lt;/a&gt;).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Holds:&lt;/strong&gt; the company proxy&amp;rsquo;s password, when &lt;code&gt;config.toml&lt;/code&gt; sets the proxy, in the environment of the mise it runs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads:&lt;/strong&gt; nothing from a VM. It downloads devvm&amp;rsquo;s pinned mise, checked by its SHA-256, mise reads the tools&amp;rsquo; versions from the internet, and the check fetches .NET&amp;rsquo;s release data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes:&lt;/strong&gt; the shared tools&amp;rsquo; lock, under its lock, the time of the check, and its output to &lt;code&gt;~/.local/share/devvm/logs/tools-check.log&lt;/code&gt;, which each check starts empty.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Starts and ends:&lt;/strong&gt; a launch of an existing VM starts it when the shared tools have a lock file and a day has passed since the last check, and doesn&amp;rsquo;t wait for it. &lt;code&gt;DEVVM_NO_TOOL_CHECK&lt;/code&gt; turns it off.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="the-desktop-relay"&gt;The desktop relay&lt;span class="hx:absolute hx:-mt-20" id="the-desktop-relay"&gt;&lt;/span&gt;
&lt;a href="#the-desktop-relay" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm desktop&lt;/code&gt; runs the relay in its own process, for as long as it runs (&lt;a href="https://next.devvm.dev/docs/internals/desktop/#on-this-machine"&gt;on this machine&lt;/a&gt;).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Holds:&lt;/strong&gt; the VM&amp;rsquo;s desktop password, which never goes into the VM.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads from the VM:&lt;/strong&gt; the VM&amp;rsquo;s side of VNC&amp;rsquo;s handshake, which is a version, at most 255 security types and a result, within 15 seconds, and then the VM&amp;rsquo;s screen, which it passes to the viewer as it is.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes:&lt;/strong&gt; lines to the run log when each viewer connects and disconnects, and for each connection it refuses, and each ssh process&amp;rsquo;s messages.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bounds:&lt;/strong&gt; at most 8 connections at once, counting those still in their handshake, one check of a password at a time, and a second&amp;rsquo;s wait after a wrong one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Listens:&lt;/strong&gt; on &lt;code&gt;127.0.0.1&lt;/code&gt; alone, on the VM&amp;rsquo;s desktop port (&lt;a href="#listeners-a-vm-reaches"&gt;listeners&lt;/a&gt;). When accepting a connection fails but the port stays open, as when it runs out of open files, it tries again after 5 ms and then twice as long each time, up to a second, and logs only the first failure of a run.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Starts and ends:&lt;/strong&gt; it ends when you press Ctrl+C, or when the VM no longer runs, which it checks every 5 seconds, and it waits for each viewer&amp;rsquo;s connection.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="the-ssh-agents"&gt;The SSH agents&lt;span class="hx:absolute hx:-mt-20" id="the-ssh-agents"&gt;&lt;/span&gt;
&lt;a href="#the-ssh-agents" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A VM whose &lt;a href="https://next.devvm.dev/docs/using/ssh/#agent-forwarding"&gt;SSH agent&lt;/a&gt; choice is &lt;code&gt;on&lt;/code&gt; gets your own agent, which devvm doesn&amp;rsquo;t start, stop or confine. A VM whose choice is &lt;code&gt;devvm&lt;/code&gt; gets devvm&amp;rsquo;s own agent, which is OpenSSH&amp;rsquo;s &lt;code&gt;ssh-agent&lt;/code&gt;, run as &lt;code&gt;ssh-agent -a ~/.local/share/devvm/agent.sock&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Holds:&lt;/strong&gt; only the keys you add with &lt;code&gt;devvm ssh-agent add&lt;/code&gt;, each for 12 hours unless you chose another lifetime. devvm refuses a key in a folder that a VM mounts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads from the VM:&lt;/strong&gt; only the requests that the VM&amp;rsquo;s proxy passes on. A VM can use the keys while it&amp;rsquo;s connected, and it can&amp;rsquo;t copy them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Starts and ends:&lt;/strong&gt; devvm starts it when a VM that uses it starts, or when you add a key, and doesn&amp;rsquo;t stop it, so it runs until you log out or restart this machine. devvm keeps no pid file for it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Apart from the exceptions below, a VM that devvm starts never reaches either agent&amp;rsquo;s socket itself. &lt;code&gt;ssh-agent&lt;/code&gt; answers every request that reaches it by its own rules, and a forwarded connection may send any of them, so a VM with the agent&amp;rsquo;s own socket could remove every key with &lt;code&gt;ssh-add -D&lt;/code&gt;, lock the agent with a password of its own with &lt;code&gt;ssh-add -x&lt;/code&gt;, or add keys to it without bound. Every VM that uses the agent would lose it then, and with your own agent, so would you. Instead, the VM&amp;rsquo;s proxy&amp;rsquo;s broker, never its child, listens on a socket of the VM&amp;rsquo;s own, &lt;code&gt;~/.local/share/devvm/run/agent-&amp;lt;hash&amp;gt;.sock&lt;/code&gt;, mode 600, and the VM&amp;rsquo;s start forwards that socket, as devvm&amp;rsquo;s own connections to the VM and its &lt;a href="https://next.devvm.dev/docs/using/ssh/#ssh-access-by-name"&gt;ssh entry&lt;/a&gt; do, so an editor forwards it too. The proxy passes on only three requests to the agent: listing its keys, signing with one, and &lt;code&gt;[email protected]&lt;/code&gt;, which ssh sends as it forwards an agent and as it logs in with one, so a key you added with destination constraints (&lt;code&gt;ssh-add -h&lt;/code&gt;) keeps them. It answers any other request with &lt;code&gt;SSH_AGENT_FAILURE&lt;/code&gt; itself, and logs the first one on each connection in its own log, so removing a key, locking the agent, adding a key and loading a smartcard&amp;rsquo;s keys never reach the agent. It reads each message whole, at most 256 KiB, as &lt;code&gt;ssh-agent&lt;/code&gt; does, and ends a connection that sends a longer one. Each VM&amp;rsquo;s proxy carries at most 16 connections at once, each with a connection of its own to the agent, and it closes a connection that sends no whole request for 2 minutes. The cap is each VM&amp;rsquo;s own, not the agent&amp;rsquo;s, so VMs that share an agent can hold 16 connections each, and enough of them could still use up the agent&amp;rsquo;s open files, 256 by default on macOS. A request that the agent asks you about, for a key added with &lt;code&gt;--confirm&lt;/code&gt;, waits as long as the agent does, and &lt;code&gt;ssh-agent&lt;/code&gt; answers one request at a time, so while it waits for your answer, every other VM that shares the agent, and you, wait too.&lt;/p&gt;
&lt;p&gt;devvm records in the VM&amp;rsquo;s state each start it made. For a start whose choice forwards an agent, it also records that the start forwarded the relay, even when devvm ran the start without &lt;code&gt;SSH_AUTH_SOCK&lt;/code&gt; and so had no agent to relay. For such a start, devvm&amp;rsquo;s own connections and the ssh entry name the relay even while the proxy starts again or is gone, or relays nothing, so the VM then has no agent, never the agent&amp;rsquo;s own socket, even when a later command runs from a shell that has one. A VM running a start that devvm didn&amp;rsquo;t record, such as one started with &lt;code&gt;devvm limactl start&lt;/code&gt;, gets no agent in its ssh entry, and devvm&amp;rsquo;s own connections get its proxy&amp;rsquo;s relay of the agent that devvm last started it with, or none, never the agent&amp;rsquo;s own socket. Only a VM that an earlier devvm started without the relay keeps the agent&amp;rsquo;s own socket, in devvm&amp;rsquo;s connections and its ssh entry, until its next start.&lt;/p&gt;
&lt;p&gt;The proxy relays the agent that the VM&amp;rsquo;s start chose, and it keeps relaying that agent until the VM&amp;rsquo;s next start, even when it starts again for a running VM, so a change of choice waits for the next start, as it does for the VM&amp;rsquo;s backend. The proxy deletes the socket when it ends with the VM&amp;rsquo;s hostagent, devvm deletes it when it stops the proxy, and &lt;code&gt;devvm gc --orphans&lt;/code&gt; deletes one that a killed proxy left, which nothing listens on.&lt;/p&gt;
&lt;h2 data-hextra-search-id="limas-hostagent"&gt;Lima&amp;rsquo;s hostagent&lt;span class="hx:absolute hx:-mt-20" id="limas-hostagent"&gt;&lt;/span&gt;
&lt;a href="#limas-hostagent" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Each running VM has a hostagent, &lt;code&gt;limactl hostagent&lt;/code&gt;, which &lt;code&gt;limactl start&lt;/code&gt; runs and which runs the VM: on macOS it runs Apple&amp;rsquo;s Virtualization framework in its own process, and on Linux it starts QEMU.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Holds:&lt;/strong&gt; Lima&amp;rsquo;s login key, &lt;code&gt;_config/user&lt;/code&gt; in devvm&amp;rsquo;s Lima home, which every VM there authorizes, and the VM&amp;rsquo;s disk.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reads from the VM:&lt;/strong&gt; everything the VM&amp;rsquo;s network sends, on macOS. On Linux, QEMU carries it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Writes:&lt;/strong&gt; its logs, &lt;code&gt;ha.stdout.log&lt;/code&gt; and &lt;code&gt;ha.stderr.log&lt;/code&gt;, in the VM&amp;rsquo;s Lima folder, which also get QEMU&amp;rsquo;s errors on Linux, and the VM&amp;rsquo;s serial console logs there, &lt;code&gt;serial.log&lt;/code&gt;, &lt;code&gt;serialv.log&lt;/code&gt; and &lt;code&gt;serialp.log&lt;/code&gt;, which QEMU or Apple&amp;rsquo;s Virtualization framework writes for it and which the VM&amp;rsquo;s root writes to through &lt;code&gt;/dev/hvc0&lt;/code&gt; and the other consoles. Each start writes them anew. devvm replaces each proxy password in &lt;code&gt;ha.stderr.log&lt;/code&gt; and the serial consoles&amp;rsquo; logs with as many &lt;code&gt;*&lt;/code&gt; once the start ends, in the first 64 MiB of each log. While the VM runs, its proxy looks at each of these logs every second, skipping one that hasn&amp;rsquo;t grown. It replaces each password in what the log gained since, because a reboot inside the VM, which QEMU on Linux carries out in place, runs Lima&amp;rsquo;s boot scripts again and writes the password to the console again, and it rotates a log once it holds more than 10 MiB. When a line hasn&amp;rsquo;t ended yet, the next look reads it again from its start if that&amp;rsquo;s within 64 KiB of where the last look stopped, and otherwise from 64 KiB before that point, where it stars everything up to an &lt;code&gt;@&lt;/code&gt; as the rest of a secret. So a line that never ends costs at most 64 KiB more than what&amp;rsquo;s new in it, and a secret of any length is found. A rotation copies the log&amp;rsquo;s last 10 MiB, from a line&amp;rsquo;s start, to the log&amp;rsquo;s &lt;code&gt;.1&lt;/code&gt; file, replacing the one there, and then empties the log. The copy has each password and proxy key replaced, and the start of one that the copy cuts before its &lt;code&gt;@&lt;/code&gt; masked. The next look stars the rest of that one, which the writer goes on with, up to its &lt;code&gt;@&lt;/code&gt;. So each of these logs takes at most 10 MiB and 10 MiB more in its &lt;code&gt;.1&lt;/code&gt; file, plus what a VM writes in a second. The log&amp;rsquo;s writer goes on at its own offset, past a hole that takes no disk, so the cap is on the space the log takes on disk rather than on its length, which keeps growing. The cap holds only on a file system with holes, such as APFS, ext4, XFS and btrfs, because one without them would write the emptied part out as zeros. What the writer adds between the copy and the emptying is lost. On macOS, a reboot inside the VM stops it, as Apple&amp;rsquo;s Virtualization framework ends a VM that restarts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Listens:&lt;/strong&gt; on macOS, on the VM&amp;rsquo;s ssh port on this machine&amp;rsquo;s loopback, which QEMU listens on instead on Linux. It also listens on unix sockets in the VM&amp;rsquo;s Lima folder and, for an open VM or a build, on loopback ports for Lima&amp;rsquo;s DNS resolver (&lt;a href="#listeners-a-vm-reaches"&gt;listeners&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Confinement:&lt;/strong&gt; on macOS, a confined VM&amp;rsquo;s hostagent and a build&amp;rsquo;s run under a Seatbelt profile, &lt;code&gt;sandbox.sb&lt;/code&gt; in the VM&amp;rsquo;s run folder, which denies &lt;code&gt;com.apple.dnssd.service&lt;/code&gt;. A confined VM&amp;rsquo;s profile lets it connect only to the VM&amp;rsquo;s ssh port and its proxy on the host&amp;rsquo;s loopback, to the unix sockets in the VM&amp;rsquo;s Lima folder and, when the VM forwards an agent, to that SSH agent, and it lets the hostagent listen only on the VM&amp;rsquo;s ssh port and those unix sockets. A build&amp;rsquo;s profile lets it reach either the internet, but not the host&amp;rsquo;s loopback apart from its ssh port and its build proxy&amp;rsquo;s port, or nothing, and it doesn&amp;rsquo;t limit what the hostagent listens on. Every profile limits only the network, so the hostagent can still read and write your files. An open VM&amp;rsquo;s hostagent and every hostagent on Linux run unconfined, and on Linux, QEMU&amp;rsquo;s restricted network confines a confined VM instead (&lt;a href="https://next.devvm.dev/docs/internals/lima/#confinement"&gt;confinement&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Starts and ends:&lt;/strong&gt; devvm records the hostagent it started in &lt;code&gt;started&lt;/code&gt; in the VM&amp;rsquo;s run folder and checks that the VM still runs on it (&lt;a href="https://next.devvm.dev/docs/internals/network/#the-self-check"&gt;the self-check&lt;/a&gt;), and the proxy and the forwarder follow its &lt;code&gt;ha.pid&lt;/code&gt;. Nothing waits for it, and &lt;code&gt;limactl stop&lt;/code&gt;, which &lt;code&gt;devvm stop&lt;/code&gt; runs, ends it.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="listeners-a-vm-reaches"&gt;Listeners a VM reaches&lt;span class="hx:absolute hx:-mt-20" id="listeners-a-vm-reaches"&gt;&lt;/span&gt;
&lt;a href="#listeners-a-vm-reaches" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;These are the listeners on this machine that carry bytes a VM controls. Every one listens on this machine&amp;rsquo;s loopback or on a unix socket, so other machines never reach them, but every program and every user on this machine can connect to a TCP port on its loopback.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Listener&lt;/th&gt;
&lt;th&gt;Process&lt;/th&gt;
&lt;th&gt;Gate&lt;/th&gt;
&lt;th&gt;What the VM controls&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;each forwarded port, on &lt;code&gt;127.0.0.1&lt;/code&gt; and &lt;code&gt;::1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the port forwarder&lt;/td&gt;
&lt;td&gt;none: whatever connects reaches the VM&amp;rsquo;s server, 256 connections at once&lt;/td&gt;
&lt;td&gt;everything its server sends back&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;the VM&amp;rsquo;s ssh port, on the loopback, one of the 17 ports every browser refuses (&lt;a href="https://next.devvm.dev/docs/internals/lima/#what-devvm-sets-on-a-vm"&gt;why&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;the hostagent on macOS, QEMU on Linux&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s sshd, which each of devvm&amp;rsquo;s connections checks against the VM&amp;rsquo;s pinned host key, and browsers&amp;rsquo; own refusal of the port&lt;/td&gt;
&lt;td&gt;everything the VM&amp;rsquo;s sshd sends, which root in the VM can make speak HTTP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lima&amp;rsquo;s DNS resolver, on loopback ports the system picks&lt;/td&gt;
&lt;td&gt;the hostagent, for an open VM and every build, never for a VM confined to its proxy&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;td&gt;its lookups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;the unix sockets in the VM&amp;rsquo;s Lima folder: the network socket on macOS, which carries the VM&amp;rsquo;s network frames, and Lima&amp;rsquo;s ssh control socket, &lt;code&gt;ssh.sock&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the hostagent, and Lima&amp;rsquo;s ssh&lt;/td&gt;
&lt;td&gt;the folder&amp;rsquo;s mode&lt;/td&gt;
&lt;td&gt;its network frames, and everything its sshd sends&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;the VM&amp;rsquo;s proxy port, on &lt;code&gt;127.0.0.1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s proxy&amp;rsquo;s child&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s password, before anything else&lt;/td&gt;
&lt;td&gt;its requests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;a build&amp;rsquo;s proxy port, on &lt;code&gt;127.0.0.1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the build&amp;rsquo;s proxy&amp;rsquo;s child&lt;/td&gt;
&lt;td&gt;the build&amp;rsquo;s password&lt;/td&gt;
&lt;td&gt;its requests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;the desktop port, on &lt;code&gt;127.0.0.1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;devvm desktop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s desktop password, checked on this machine&lt;/td&gt;
&lt;td&gt;its screen, once a viewer is in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;127.0.0.1:1455&lt;/code&gt;, with &lt;code&gt;::1:1455&lt;/code&gt; and port 1457 on both when they&amp;rsquo;re free&lt;/td&gt;
&lt;td&gt;&lt;code&gt;devvm agent login&lt;/code&gt;, while Codex&amp;rsquo;s or opencode&amp;rsquo;s browser login to ChatGPT waits, but not with &lt;code&gt;--device-code&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;none: whatever connects reaches the agent&amp;rsquo;s login server in the VM, 16 connections at once&lt;/td&gt;
&lt;td&gt;the login server&amp;rsquo;s answers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;each link&amp;rsquo;s unix socket&lt;/td&gt;
&lt;td&gt;the link session&lt;/td&gt;
&lt;td&gt;the socket&amp;rsquo;s mode, 600 in a folder of mode 700&lt;/td&gt;
&lt;td&gt;the client&amp;rsquo;s bytes, through its sshd&amp;rsquo;s remote forward or its proxy, and the target&amp;rsquo;s answers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;the ssh masters&amp;rsquo; control sockets, &lt;code&gt;run/port-&amp;lt;hash&amp;gt;.ctl&lt;/code&gt; and &lt;code&gt;run/link-&amp;lt;hash&amp;gt;.ctl&lt;/code&gt; in &lt;code&gt;~/.local/share/devvm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the forwarder&amp;rsquo;s and the link session&amp;rsquo;s ssh masters&lt;/td&gt;
&lt;td&gt;the folder&amp;rsquo;s mode: any process of yours that connects gets a channel into the VM&lt;/td&gt;
&lt;td&gt;everything the VM sends on that channel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;the VM&amp;rsquo;s agent socket, &lt;code&gt;run/agent-&amp;lt;hash&amp;gt;.sock&lt;/code&gt; in &lt;code&gt;~/.local/share/devvm&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;the VM&amp;rsquo;s proxy&amp;rsquo;s broker, for a VM that forwards an SSH agent&lt;/td&gt;
&lt;td&gt;the socket&amp;rsquo;s mode, 600 in a folder of mode 700&lt;/td&gt;
&lt;td&gt;the agent&amp;rsquo;s requests, of which the proxy passes on only listing keys, signing and binding a session to a host&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;A forwarded port and the login&amp;rsquo;s port carry whatever connects to them into the VM, a browser&amp;rsquo;s pages included, and that&amp;rsquo;s what &lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#network"&gt;attack vectors&lt;/a&gt; lists as left open.&lt;/p&gt;
&lt;h2 data-hextra-search-id="why-go"&gt;Why Go&lt;span class="hx:absolute hx:-mt-20" id="why-go"&gt;&lt;/span&gt;
&lt;a href="#why-go" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm stays in Go, and its own history shows why. None of its first 712 commits fixes a memory-safety bug, and none fixes a data race that got past Go&amp;rsquo;s race detector, which every test run uses. devvm&amp;rsquo;s own code imports &lt;code&gt;unsafe&lt;/code&gt; only for a few raw system calls on Linux, which confine the proxy&amp;rsquo;s child and set a file&amp;rsquo;s times through its descriptor, and it builds without cgo. Its security and reliability fixes fall mostly into five classes, which a language&amp;rsquo;s types don&amp;rsquo;t prevent:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Lifecycles and resources,&lt;/strong&gt; such as a relay that outlived its link, a VM&amp;rsquo;s QEMU left running without its hostagent, and a VM that could make devvm read more than it should.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Policy semantics,&lt;/strong&gt; such as a 6to4 address judged by its IPv4 address, and a placeholder swapped only when it&amp;rsquo;s the whole value.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Secret leaks,&lt;/strong&gt; such as a proxy password in Lima&amp;rsquo;s log, and a resolver&amp;rsquo;s error in a VM&amp;rsquo;s refusal reason.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Races between processes,&lt;/strong&gt; such as a proxy that had just started looking gone, and two runs choosing ports or making a folder&amp;rsquo;s VM at once.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;File-system trust,&lt;/strong&gt; such as a project folder replaced after devvm found it, a folder that a VM names as a git folder, a link under a folder&amp;rsquo;s path, and a project folder mounted by its path rather than as the folder itself.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A port to Rust would cost what keeps devvm easy to keep:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;One static binary,&lt;/strong&gt; built with &lt;code&gt;CGO_ENABLED=0&lt;/code&gt; for every platform from one machine. Go&amp;rsquo;s &lt;code&gt;crypto/tls&lt;/code&gt; needs no C toolchain, while rustls&amp;rsquo;s usual providers, aws-lc-rs and ring, have C in them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A small dependency tree:&lt;/strong&gt; Go&amp;rsquo;s standard library, Go&amp;rsquo;s own &lt;code&gt;x&lt;/code&gt; modules, Cobra and pflag, a TOML parser and go-i18n, with the few modules that cobra/doc brings in, where a Rust proxy on the usual async, HTTP and TLS crates brings in about a hundred.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;One owner for each concern,&lt;/strong&gt; which depguard, forbidigo and the &lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-structure-test"&gt;structure test&lt;/a&gt; enforce, and which none of them could see across a language boundary.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The proxy is the only part that could be split off, and it&amp;rsquo;s bound to the rest: its broker looks up secrets and refreshes agents&amp;rsquo; logins with devvm&amp;rsquo;s own code, its config is a schema that every release&amp;rsquo;s state keeps, and its child reads its built-in policies from devvm&amp;rsquo;s binary.&lt;/p&gt;
&lt;p&gt;The answer changes only for a requirement Go can&amp;rsquo;t meet, such as intercepting QUIC. Even then, only that piece would move, as a process of its own.&lt;/p&gt;</description></item><item><title>Coding agents</title><link>https://next.devvm.dev/docs/internals/agents/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://next.devvm.dev/docs/internals/agents/</guid><description>
&lt;p&gt;This page explains how devvm gives the coding agents in a VM their settings, logins and history, and what it checks on the way, for the tasks that &lt;a href="https://next.devvm.dev/docs/using/coding-agents/"&gt;Coding agents&lt;/a&gt; shows. How the proxy holds the agents&amp;rsquo; secrets is in &lt;a href="https://next.devvm.dev/docs/internals/network/#agents-logins-and-settings"&gt;agents&amp;rsquo; logins and settings&lt;/a&gt;.&lt;/p&gt;
&lt;h2 data-hextra-search-id="the-guide-in-every-vm"&gt;The guide in every VM&lt;span class="hx:absolute hx:-mt-20" id="the-guide-in-every-vm"&gt;&lt;/span&gt;
&lt;a href="#the-guide-in-every-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Each launch installs the guide again whenever it differs from devvm&amp;rsquo;s, and it belongs to root and is read-only, so nothing that the VM&amp;rsquo;s user runs without &lt;code&gt;sudo&lt;/code&gt; can change what the agents read, and a change made with &lt;code&gt;sudo&lt;/code&gt; lasts only until the next launch.&lt;/p&gt;
&lt;h2 data-hextra-search-id="pasting"&gt;Pasting&lt;span class="hx:absolute hx:-mt-20" id="pasting"&gt;&lt;/span&gt;
&lt;a href="#pasting" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;How devvm paste reads the clipboard, names a copied file, refuses links and finds Linux&amp;rsquo;s clipboard programs is in the design note on &lt;a href="https://next.devvm.dev/docs/contributing/design/#pasting-images"&gt;pasting images&lt;/a&gt;.&lt;/p&gt;
&lt;h2 data-hextra-search-id="each-agents-variables"&gt;Each agent&amp;rsquo;s variables&lt;span class="hx:absolute hx:-mt-20" id="each-agents-variables"&gt;&lt;/span&gt;
&lt;a href="#each-agents-variables" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Every VM sets &lt;code&gt;OPENCODE_DISABLE_AUTOUPDATE=1&lt;/code&gt;, as it sets &lt;code&gt;DISABLE_AUTOUPDATER=1&lt;/code&gt; for Claude Code, because the agents are read-only shared tools that can&amp;rsquo;t update themselves, and devvm keeps their versions. For the same reason every VM sets &lt;code&gt;PI_SKIP_VERSION_CHECK=1&lt;/code&gt;, so pi doesn&amp;rsquo;t ask you to run &lt;code&gt;pi update&lt;/code&gt;, and &lt;code&gt;PI_TELEMETRY=0&lt;/code&gt;, which turns off pi&amp;rsquo;s report of its install and the attribution headers it adds to some providers&amp;rsquo; requests. Claude Code&amp;rsquo;s telemetry and error reports are off with &lt;code&gt;DISABLE_TELEMETRY=1&lt;/code&gt; and &lt;code&gt;DISABLE_ERROR_REPORTING=1&lt;/code&gt;, and &lt;code&gt;CLAUDE_CODE_PLUGIN_CACHE_DIR&lt;/code&gt; and &lt;code&gt;CLAUDE_CODE_PLUGIN_SEED_DIR&lt;/code&gt; name its plugins folder and its seed (&lt;a href="#claude-codes-plugins"&gt;Claude Code&amp;rsquo;s plugins&lt;/a&gt;). devvm writes every agent&amp;rsquo;s variables into each VM at every launch, whichever agents the VM has, and every shell in the VM gets them, login or not, so an agent that an editor&amp;rsquo;s terminal or &lt;code&gt;ssh&lt;/code&gt; runs gets them too. pi would download &lt;code&gt;fd&lt;/code&gt; and &lt;code&gt;rg&lt;/code&gt; into &lt;code&gt;~/.pi/agent/bin&lt;/code&gt; whenever they&amp;rsquo;re missing, so base has both, from Ubuntu&amp;rsquo;s or the container image&amp;rsquo;s own packages, and pi finds Ubuntu&amp;rsquo;s and Debian&amp;rsquo;s &lt;code&gt;fd&lt;/code&gt; by its name there, &lt;code&gt;fdfind&lt;/code&gt;.&lt;/p&gt;
&lt;h2 data-hextra-search-id="importing"&gt;Importing&lt;span class="hx:absolute hx:-mt-20" id="importing"&gt;&lt;/span&gt;
&lt;a href="#importing" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The import copies only the paths in &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#devvms-agent-store"&gt;the store&amp;rsquo;s table&lt;/a&gt;, from &lt;code&gt;~/.claude&lt;/code&gt;, &lt;code&gt;~/.claude.json&lt;/code&gt;, &lt;code&gt;~/.codex&lt;/code&gt;, &lt;code&gt;~/.config/opencode&lt;/code&gt;, &lt;code&gt;~/.local/share/opencode&lt;/code&gt; and &lt;code&gt;~/.pi/agent&lt;/code&gt;, so it never copies your history, such as &lt;code&gt;~/.claude/projects&lt;/code&gt;, &lt;code&gt;~/.codex&lt;/code&gt;&amp;rsquo;s sessions or &lt;code&gt;~/.pi/agent/sessions&lt;/code&gt;, and never &lt;code&gt;~/.claude/.credentials.json&lt;/code&gt;. Of &lt;code&gt;~/.claude/plugins&lt;/code&gt; it copies only what a seed has, &lt;code&gt;known_marketplaces.json&lt;/code&gt;, &lt;code&gt;marketplaces&lt;/code&gt; and &lt;code&gt;cache&lt;/code&gt;, whether the folder is in &lt;code&gt;~/.claude&lt;/code&gt; or a link you allowed leads to it, so this machine&amp;rsquo;s own entries, such as each plugin&amp;rsquo;s data in &lt;code&gt;data&lt;/code&gt;, its MCP bundles in &lt;code&gt;mcpb&lt;/code&gt;, the plugins that claude.ai synced, its trash and its record of the plugins it installed, never reach the store (&lt;a href="#claude-codes-plugins"&gt;Claude Code&amp;rsquo;s plugins&lt;/a&gt;). Claude Code&amp;rsquo;s plugin records name the plugins&amp;rsquo; folders by their paths, so the store&amp;rsquo;s copies of the JSON files in &lt;code&gt;~/.claude/plugins&lt;/code&gt; name the plugins&amp;rsquo; folders in the store, where the VMs mount them.&lt;/p&gt;
&lt;p&gt;A link inside an agent&amp;rsquo;s folder that leads to a file inside it is copied as that file only when the file is one of the settings that the import copies of the folder itself, by the name that the link resolves to, one link at a time. So a link never copies what the import leaves out, such as &lt;code&gt;~/.claude/projects&lt;/code&gt;, &lt;code&gt;~/.claude/.credentials.json&lt;/code&gt; or a plugin&amp;rsquo;s data in &lt;code&gt;~/.claude/plugins/data&lt;/code&gt;, and the import also leaves out a name that differs from a setting&amp;rsquo;s only in case, which a Mac&amp;rsquo;s file system would still find. The import reads each file it listed, and a link&amp;rsquo;s file by the path that the link resolved to. It reads through the agent&amp;rsquo;s folder opened one folder at a time, each from its parent, without following a link in any part of the path, and it fails unless the file it opened is the one it listed. A VM whose project folder is inside an agent&amp;rsquo;s folder, such as a skill you work on in &lt;code&gt;~/.claude/skills&lt;/code&gt;, can change a link or a folder there between the listing and the read, so such a change fails the import rather than copy what the new link leads to, and devvm warns, before it reads anything, of each VM whose project folder is inside an agent&amp;rsquo;s folder or holds it. A VM whose state devvm can&amp;rsquo;t read gets a warning of its own, naming its state file, because devvm can&amp;rsquo;t tell where its project folder is, and while any state can&amp;rsquo;t be read, devvm leaves out, with a warning naming the state, every path it would read through a link: an agent&amp;rsquo;s folder or login whose path passes through one, and every link out of an agent&amp;rsquo;s folder. That also counts the links on the way to your home folder, because a VM made with &lt;code&gt;--unsafe-folder&lt;/code&gt; on a folder that holds your home folder holds them. It doesn&amp;rsquo;t count a link that only root can change, such as macOS&amp;rsquo;s &lt;code&gt;/var&lt;/code&gt; or the &lt;code&gt;/home&lt;/code&gt; of Fedora Silverblue, whose folders up to &lt;code&gt;/&lt;/code&gt; are root&amp;rsquo;s alone, by their modes and by what the system says you may write, an ACL included. A VM changes this machine&amp;rsquo;s files only as you, so no VM can change where such a link leads. devvm opens an agent&amp;rsquo;s folder twice, as a root to list it and one folder at a time to read it, and fails the import, naming the folder, unless both are the same folder, so a VM can&amp;rsquo;t swap the folder between the two. A project folder that holds an agent&amp;rsquo;s folder, such as &lt;code&gt;~/.pi&lt;/code&gt; for pi&amp;rsquo;s &lt;code&gt;~/.pi/agent&lt;/code&gt;, lets its VM put a link in the agent folder&amp;rsquo;s place, so devvm resolves the folder&amp;rsquo;s path one link at a time and leaves the folder out, with a warning, when a link in a VM&amp;rsquo;s project folder leads it out of that folder, which would let the VM choose any folder of this machine&amp;rsquo;s, such as your home folder. A login file in a folder left out so, such as pi&amp;rsquo;s &lt;code&gt;auth.json&lt;/code&gt;, is left out with it. Otherwise devvm reads the folder where the path led when it resolved it. It reads an agent&amp;rsquo;s login file, other than Claude Code&amp;rsquo;s &lt;code&gt;~/.claude.json&lt;/code&gt;, in the same way: devvm resolves its path one link at a time, leaves it out in the same way, and reads it where the path led, through its folder opened one folder at a time without following a link and never resolved again. It opens the file itself without following a link and reads it only as a regular file of at most 128 MiB, so a link, a FIFO or an endless file that a VM put in its place fails the import. It copies at most 20,000 files, folders and links, 128 MiB, and 16 MiB in one file, of each agent&amp;rsquo;s folder, the bounds of &lt;a href="#saving-a-vms-settings"&gt;saving a VM&amp;rsquo;s settings&lt;/a&gt;, so such a VM can&amp;rsquo;t fill the store that every VM with the agent mounts. It reads each folder 256 entries at a time and counts every entry as it reads it, a link, a socket or a FIFO as much as a file, stopping at 20,000, so a folder of millions of entries never costs it more than that and one batch, and a folder that holds more fails the import before anything is written, naming the folder. It goes at most 128 folders deep, in paths of at most 4,096 bytes, because it opens each folder from the agent&amp;rsquo;s folder down, one name at a time, through the folder above it, which it opened in the same way. So a chain of folders nested deeper fails the import in the same way, and a link or a FIFO that a VM swaps in for a folder during the walk fails the import instead of leading it elsewhere or holding it. A file that grows past 16 MiB, or past what&amp;rsquo;s left of the 128 MiB, between the listing and the read fails the import too, naming the file. The copy of a Claude Code plugin record names the store&amp;rsquo;s longer paths, so it can be larger than the file, and what it grows counts against the same bounds, so a copy that would pass them fails the import, naming the folder.&lt;/p&gt;
&lt;p&gt;The import reads and writes every agent&amp;rsquo;s settings into a staging folder of the agent&amp;rsquo;s store first, &lt;code&gt;.devvm-import-&lt;/code&gt; and a random name, beside the agent&amp;rsquo;s folder there, so no VM mounts it. When a file fails to read, has changed since it was listed or passes the bounds, the import fails, leaving the store as it was and taking out the staging folder. An interrupt before every agent&amp;rsquo;s settings are staged does the same, and the run&amp;rsquo;s cleanups take out its staging folders. Once every agent&amp;rsquo;s settings are staged, the import moves each file into place and moves what your home folder no longer has aside, into a folder of the staging folder, where a file it replaces is kept too, as a second hard link, so each file is still replaced in one rename. Then it saves the logins, all or none, reading each login file it replaces first. A failure from then on, such as a rename that fails or a login that can&amp;rsquo;t be saved, puts back every agent&amp;rsquo;s store and every login as they were, the last change first, and an interrupt waits for that, or for the import to finish, before the run&amp;rsquo;s cleanups take the staging folder out. It puts back every agent&amp;rsquo;s store that it changed, even after putting one back fails. Only then, if one did fail, does it say so, naming each store it couldn&amp;rsquo;t put back and its staging folder. It keeps that staging folder, which holds what devvm couldn&amp;rsquo;t put back, until the next import or save. A run that&amp;rsquo;s killed while it puts the settings in place can leave the store partly replaced, so run the import again. The staging folders go once the import is done. The import holds the store&amp;rsquo;s lock, &lt;code&gt;agents.lock&lt;/code&gt; in devvm&amp;rsquo;s data folder, from its staging to its logins, as &lt;a href="#saving-a-vms-settings"&gt;the save&lt;/a&gt; does while it writes, and a start does while it cleans &lt;a href="#claude-codes-plugins"&gt;Claude Code&amp;rsquo;s plugins&lt;/a&gt; or &lt;a href="#opencodes-service"&gt;opencode&amp;rsquo;s service settings&lt;/a&gt;, once it finds something to take out, so no two of them change the store at once, and the second waits under a status line until the first is done. A staging folder that a killed import or save left counts as nothing of the agent&amp;rsquo;s, so the import doesn&amp;rsquo;t ask before it replaces a store that holds only that, and the next import or save of that agent takes it out first. A replacement keeps the store&amp;rsquo;s folders, so a running VM&amp;rsquo;s mounts still show them. The import and &lt;a href="#saving-a-vms-settings"&gt;the save&lt;/a&gt; read names as the volume that holds the store reads them, so on a volume that ignores case, as a Mac&amp;rsquo;s does by default, a file named &lt;code&gt;foo.md&lt;/code&gt; replaces the store&amp;rsquo;s &lt;code&gt;Foo.md&lt;/code&gt; in place, under the store&amp;rsquo;s name. What they keep when they move aside what a folder no longer has is each file and folder they wrote or keep, found by what it is on the volume rather than by how its name is spelled, so the store&amp;rsquo;s &lt;code&gt;Foo.md&lt;/code&gt; stays. Their staging folder is on the same volume and holds only what they wrote, so a name that&amp;rsquo;s already there before they write it, under no name they wrote, is one the volume reads as another of theirs, such as &lt;code&gt;a.md&lt;/code&gt; after &lt;code&gt;A.md&lt;/code&gt;, and then they fail before the store changes and name both. The save also counts the names that it leaves out in this check. The staging folder reads names by its own folder&amp;rsquo;s rules, which are the store&amp;rsquo;s wherever a volume&amp;rsquo;s rules hold for every folder, as on macOS, but Linux&amp;rsquo;s ext4 can ignore case in some folders alone, so a store whose agent folder alone ignores case gets no such check. A file with a second name, a hard link, which only a hand-made store has, is kept only by the name it&amp;rsquo;s written or kept under, and the save&amp;rsquo;s diff shows its other names as removed. Where the store has a folder and the home folder now has a file, or the other way round, as when a link that led to a folder now leads to a file, the import replaces it. Before they write anything, both the import and &lt;a href="#saving-a-vms-settings"&gt;the save&lt;/a&gt; check the path of every folder and file they&amp;rsquo;ll write, and each part of the path below devvm&amp;rsquo;s config folder must be a folder, never a link. A link there, which only a hand-made store has and which could lead to your home folder, fails the command before the store changes, for any of the agents that the command handles, and the command names it. A link in the store in place of a settings file is replaced, never followed. They then write only through the agent&amp;rsquo;s store, or its folder there, opened from devvm&amp;rsquo;s config folder as a root, every part of its path a folder, so a link put in the store after the check can&amp;rsquo;t lead a write out of it. They also reach a folder of the store that they empty from devvm&amp;rsquo;s config folder in the same way, as the start does for &lt;a href="#claude-codes-plugins"&gt;Claude Code&amp;rsquo;s plugins&lt;/a&gt;, and devvm&amp;rsquo;s config folder itself may be a link, as a dotfiles repo&amp;rsquo;s is.&lt;/p&gt;
&lt;p&gt;opencode 2 keeps its logins in its own database rather than in &lt;code&gt;~/.local/share/opencode/auth.json&lt;/code&gt;, so when this machine&amp;rsquo;s opencode is version 2 or later, devvm reads its logins with &lt;code&gt;opencode auth export&lt;/code&gt; and saves them in the store in the format of &lt;code&gt;auth.json&lt;/code&gt;, the file that devvm copies for opencode 1. When &lt;code&gt;opencode auth export&lt;/code&gt; fails, the import fails too, and the store keeps the login it had.&lt;/p&gt;
&lt;h3 data-hextra-search-id="links-out-of-an-agents-folder"&gt;Links out of an agent&amp;rsquo;s folder&lt;span class="hx:absolute hx:-mt-20" id="links-out-of-an-agents-folder"&gt;&lt;/span&gt;
&lt;a href="#links-out-of-an-agents-folder" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The import reads each agent&amp;rsquo;s folder through a handle that&amp;rsquo;s rooted at that folder, so no link inside it leads out of it (&lt;a href="https://next.devvm.dev/docs/contributing/structure/#the-packages"&gt;the packages&lt;/a&gt;). A link that leads out is resolved, every link on the way, and only then followed, as &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#links-out-of-an-agents-folder"&gt;links out of an agent&amp;rsquo;s folder&lt;/a&gt; says, and &lt;a href="https://next.devvm.dev/docs/contributing/design/#links-out-of-an-agents-folder"&gt;the design note&lt;/a&gt; explains why:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;How it resolves.&lt;/strong&gt; devvm resolves a link one name at a time, as the system does, and keeps where each link on the way is, so it sees a link that a VM put in its project folder even in the middle of a chain. It compares a target with the refused places and the VMs&amp;rsquo; folders by name and by identity, so another spelling of a folder, such as &lt;code&gt;~/.SSH&lt;/code&gt; on a Mac, where case doesn&amp;rsquo;t count, is still that folder.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Where it reads.&lt;/strong&gt; devvm opens the folder it reads the link&amp;rsquo;s target through, a &lt;code&gt;follow-links&lt;/code&gt; folder, the linked folder or the linked file&amp;rsquo;s own folder, one folder at a time from &lt;code&gt;/&lt;/code&gt;, each opened from its parent and never through a link, so a link that a VM swaps into that path fails the import rather than lead elsewhere. It lists what the link leads to through that folder as a root, and reads each file without blocking, refusing a FIFO, a device or a file that changed into a link as it opened it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What it lists.&lt;/strong&gt; A linked folder&amp;rsquo;s folders and files are listed under the link&amp;rsquo;s own path, and a link inside it is listed as a file when the root resolves it to a regular file. Anything else is left out with a warning.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The bounds.&lt;/strong&gt; It counts every entry it reads, a folder&amp;rsquo;s read 256 at a time, and the size of every file, across all the links of one import, and leaves out a link that would pass 20,000 entries, 128 MiB or a file of 16 MiB, the bounds of &lt;a href="#saving-a-vms-settings"&gt;saving a VM&amp;rsquo;s settings&lt;/a&gt;. The walks of all the links read at most 80,000 entries, those of links left out included, and once they have, each link left is left out unread, with the same warning. A file that grows past them between the listing and the read fails the import.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A VM&amp;rsquo;s folder.&lt;/strong&gt; It reads the state of every VM devvm has, and warns once for each link and VM when the link&amp;rsquo;s target is in that VM&amp;rsquo;s project folder or holds it, or when a link inside a linked folder resolves into it. While a VM&amp;rsquo;s state can&amp;rsquo;t be read, it follows no link out of an agent&amp;rsquo;s folder, as &lt;a href="#importing"&gt;importing&lt;/a&gt; says.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 data-hextra-search-id="saving-a-vms-settings"&gt;Saving a VM&amp;rsquo;s settings&lt;span class="hx:absolute hx:-mt-20" id="saving-a-vms-settings"&gt;&lt;/span&gt;
&lt;a href="#saving-a-vms-settings" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The save reads only the settings in &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#devvms-agent-store"&gt;the store&amp;rsquo;s table&lt;/a&gt; from the VM&amp;rsquo;s home, and never the logins, so it never reads your history, &lt;code&gt;~/.claude/.credentials.json&lt;/code&gt;, &lt;code&gt;~/.codex/auth.json&lt;/code&gt;, opencode&amp;rsquo;s &lt;code&gt;auth.json&lt;/code&gt; or pi&amp;rsquo;s. From the VM&amp;rsquo;s &lt;code&gt;~/.claude.json&lt;/code&gt; it keeps only the settings, account state and MCP servers, as the import does, and the VM leaves out its per-project entries before it sends anything. devvm puts that part in the store&amp;rsquo;s logins folder, where the import keeps it too. A folder that the store already has is mounted read-only in the VM, so the agent there can&amp;rsquo;t change it, and the save leaves it as it is. The exception is Claude Code&amp;rsquo;s plugins folder, which is the VM&amp;rsquo;s own, with the store&amp;rsquo;s as its seed (&lt;a href="#claude-codes-plugins"&gt;Claude Code&amp;rsquo;s plugins&lt;/a&gt;). A folder that the store doesn&amp;rsquo;t have yet is the VM&amp;rsquo;s own until you save it, and once the VM next starts with the store&amp;rsquo;s new folder mounted, its setup links that folder in place of its own (&lt;a href="https://next.devvm.dev/docs/using/coding-agents/#mounts"&gt;mounts&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;devvm treats everything the VM sends as untrusted, because the agent in the VM could have changed any of it. It reads at most 128 MiB from the VM, in at most 20,000 files, folders and links, none of the files larger than 16 MiB, at most 128 folders deep and in paths of at most 4,096 bytes, the import&amp;rsquo;s bounds, because the save opens each folder one name at a time from the store down. When the VM sends more, or sends a path outside the agents&amp;rsquo; settings or a name with a character that a terminal wouldn&amp;rsquo;t show, devvm saves nothing. Each file it saves is yours alone (mode 600), or mode 700 when it was executable in the VM, so it never keeps a set-user-ID or set-group-ID bit. A link in a settings folder that leads to a file in the same folder becomes a copy of that file. devvm leaves out any other link, any other kind of file, such as a socket, and a settings file that it can&amp;rsquo;t parse whole, such as a &lt;code&gt;settings.json&lt;/code&gt; that isn&amp;rsquo;t JSON, and it warns you about each. When it leaves out a file in a folder, the store keeps its own copy of that file. A settings file that the VM doesn&amp;rsquo;t have stays in the store. A folder that the VM sends, other than Claude Code&amp;rsquo;s plugins folder, replaces the store&amp;rsquo;s folder whole, so devvm writes each of its files again and takes out the files that the VM&amp;rsquo;s folder doesn&amp;rsquo;t have, but it keeps the store&amp;rsquo;s folder itself, so a running VM&amp;rsquo;s mounts still show it. It compares each of the VM&amp;rsquo;s names with the store&amp;rsquo;s file that the store&amp;rsquo;s volume reads it as, found by what the file is, so where the volume ignores case, the diff shows the VM&amp;rsquo;s &lt;code&gt;foo.md&lt;/code&gt; as a change to the store&amp;rsquo;s &lt;code&gt;Foo.md&lt;/code&gt; rather than a file added and another removed. The save writes holding the store&amp;rsquo;s lock, as &lt;a href="#importing"&gt;the import&lt;/a&gt; does, and once it holds the lock, it plans again from the store as it is then. When that differs from what it showed you, as when an import wrote the store while you read the diff, it saves nothing and says so, rather than write over that change. Where the store has a folder and the VM has a file, or the other way round, the save saves nothing and names the store&amp;rsquo;s path, because putting one in the other&amp;rsquo;s place would take out what the store has there, which the diff doesn&amp;rsquo;t show. It then saves all or nothing, as the import does, so it first writes every agent&amp;rsquo;s files into a staging folder of the agent&amp;rsquo;s store first, with the import&amp;rsquo;s name, &lt;code&gt;.devvm-import-&lt;/code&gt; and a random name, and takes out any that a killed import or save left there. Then it moves each file into place and moves aside what a folder the VM sent no longer has, and it saves the part of &lt;code&gt;~/.claude.json&lt;/code&gt; last, holding the lock of the folder of Claude Code&amp;rsquo;s logins, which a VM&amp;rsquo;s proxy holds while it saves a Claude Code login made in that VM, so the two take turns. A failure from then on, such as a rename that fails or the login that can&amp;rsquo;t be saved, puts back every agent&amp;rsquo;s store and the login as they were, the last change first, and when putting a store back fails too, devvm says so, naming each store it couldn&amp;rsquo;t put back and its staging folder, which it keeps until the next import or save. A run that&amp;rsquo;s killed while it puts the settings in place can leave the store partly saved, so run the save again. A Ctrl-C while the save waits for the store&amp;rsquo;s lock or the login&amp;rsquo;s ends the wait, and the save leaves the store as it was.&lt;/p&gt;
&lt;p&gt;The VM&amp;rsquo;s &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#copies"&gt;copies&lt;/a&gt; of the settings files and of &lt;code&gt;~/.claude.json&lt;/code&gt; hold placeholders, such as &lt;code&gt;devvm-redacted&lt;/code&gt;, where the store has your secrets. devvm puts the store&amp;rsquo;s secret back in place of each placeholder, as long as the VM&amp;rsquo;s copy had that placeholder in that place and nothing around it changed, such as the URL of the MCP server that a header is for. When something around a placeholder changed, devvm leaves the whole file out and warns you, so a VM can&amp;rsquo;t send a secret it never saw to another host, and you can make that change in the store&amp;rsquo;s file yourself. devvm also leaves out any other file that holds a placeholder, such as a skill. No VM gets opencode&amp;rsquo;s files in &lt;code&gt;~/.config/opencode&lt;/code&gt; that are neither settings nor Markdown, such as a &lt;code&gt;.env&lt;/code&gt;, so devvm leaves out the VM&amp;rsquo;s own file of that name and keeps the store&amp;rsquo;s.&lt;/p&gt;
&lt;h2 data-hextra-search-id="mounts"&gt;Mounts&lt;span class="hx:absolute hx:-mt-20" id="mounts"&gt;&lt;/span&gt;
&lt;a href="#mounts" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Absolute paths in the mounted folders, such as Claude Code&amp;rsquo;s plugin paths, still work, because each is mounted at the same path as in the store on this machine. The VM follows a symlink in these folders among its own files, so a link to a file outside the folder, by a relative or an absolute path, doesn&amp;rsquo;t reach that file on this machine, on macOS&amp;rsquo;s virtiofs mounts and on Linux&amp;rsquo;s 9p mounts alike. devvm doesn&amp;rsquo;t mount a folder whose path has a comma, on any backend, and it warns you. Lima can&amp;rsquo;t mount such a path (&lt;a href="https://next.devvm.dev/docs/backends/lima/#limits"&gt;Lima&amp;rsquo;s limits&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The VM reads every file in these folders, a Claude Code marketplace&amp;rsquo;s git clone included, so when &lt;code&gt;devvm agent import&lt;/code&gt; or &lt;code&gt;devvm agent save&lt;/code&gt; copies a marketplace, it checks the clone for a credential and warns of each one. It reads, with git itself and without its includes, every git config below the clone&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt;, a submodule&amp;rsquo;s included, and each file a config includes from inside the clone, which the copy holds too, and it looks for an &lt;code&gt;http.extraHeader&lt;/code&gt; and a URL with a password or an access token in its user info: a remote&amp;rsquo;s or a submodule&amp;rsquo;s URL, a push URL, a proxy, or the base of an &lt;code&gt;insteadOf&lt;/code&gt;. It judges a URL as &lt;code&gt;--clone&lt;/code&gt; judges a remote, so an scp-like &lt;code&gt;git@host:path&lt;/code&gt; is a name, not a credential. It also checks each marketplace&amp;rsquo;s source in &lt;code&gt;known_marketplaces.json&lt;/code&gt;. A warning names the keys, never the credential, and a URL in a key&amp;rsquo;s name that holds one shows as &lt;code&gt;&amp;lt;url&amp;gt;&lt;/code&gt;. When git can&amp;rsquo;t read such a config, devvm warns that it couldn&amp;rsquo;t check it, with git&amp;rsquo;s reason, as the VM reads the file whatever git makes of it.&lt;/p&gt;
&lt;h2 data-hextra-search-id="claude-codes-plugins"&gt;Claude Code&amp;rsquo;s plugins&lt;span class="hx:absolute hx:-mt-20" id="claude-codes-plugins"&gt;&lt;/span&gt;
&lt;a href="#claude-codes-plugins" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Claude Code keeps everything of its plugins in one folder, &lt;code&gt;~/.claude/plugins&lt;/code&gt; unless &lt;code&gt;CLAUDE_CODE_PLUGIN_CACHE_DIR&lt;/code&gt; names another, and writes there as it runs: each plugin&amp;rsquo;s data in &lt;code&gt;data/&amp;lt;plugin&amp;gt;&lt;/code&gt;, which a plugin reaches as &lt;code&gt;${CLAUDE_PLUGIN_DATA}&lt;/code&gt;, the plugins it installs in &lt;code&gt;cache&lt;/code&gt;, its marketplaces&amp;rsquo; copies in &lt;code&gt;marketplaces&lt;/code&gt; and their updates, its MCP bundles in &lt;code&gt;mcpb&lt;/code&gt;, the plugins claude.ai synced in &lt;code&gt;synced&lt;/code&gt;, its trash in &lt;code&gt;.trash&lt;/code&gt;, and its records, such as &lt;code&gt;installed_plugins.json&lt;/code&gt;. The store&amp;rsquo;s plugins folder is mounted read-only in every VM with Claude Code, because a VM that could write it could change what Claude Code runs in every other VM (&lt;a href="https://next.devvm.dev/docs/contributing/design/#claude-codes-plugins-a-seed-and-a-folder-of-the-vms-own"&gt;the design note&lt;/a&gt;). So each VM&amp;rsquo;s &lt;code&gt;~/.claude/plugins&lt;/code&gt; is its own folder, on its own disk, and the store&amp;rsquo;s folder is the VM&amp;rsquo;s seed, Claude Code&amp;rsquo;s own support for a plugins folder it only reads. Every shell in the VM sets &lt;code&gt;CLAUDE_CODE_PLUGIN_CACHE_DIR&lt;/code&gt; to &lt;code&gt;~/.claude/plugins&lt;/code&gt; and &lt;code&gt;CLAUDE_CODE_PLUGIN_SEED_DIR&lt;/code&gt; to &lt;code&gt;~/.claude/plugins-seed&lt;/code&gt;, where the VM links the store&amp;rsquo;s folder. A seed is laid out as a plugins folder, with the marketplaces&amp;rsquo; records in &lt;code&gt;known_marketplaces.json&lt;/code&gt;, their copies in &lt;code&gt;marketplaces&lt;/code&gt; and the plugins in &lt;code&gt;cache&lt;/code&gt;. As Claude Code starts, it registers the seed&amp;rsquo;s marketplaces in the VM&amp;rsquo;s own folder, turns off their updates, and loads each plugin that &lt;code&gt;enabledPlugins&lt;/code&gt; turns on from the seed&amp;rsquo;s &lt;code&gt;cache&lt;/code&gt;, without copying it, and it never writes into the seed. It registers a marketplace from the seed only when the seed has its copy in &lt;code&gt;marketplaces&lt;/code&gt;, so a marketplace from a folder on this machine, which Claude Code reads in place and never copies, isn&amp;rsquo;t one, and Claude Code in the VM adds it from &lt;code&gt;extraKnownMarketplaces&lt;/code&gt; in &lt;code&gt;settings.json&lt;/code&gt; only when that folder is in the VM too. In &lt;code&gt;claude -p&lt;/code&gt;, Claude Code registers the seed&amp;rsquo;s marketplaces during the first session that the VM&amp;rsquo;s folder doesn&amp;rsquo;t have them yet, so a plugin&amp;rsquo;s hooks for the start of a session run from the next session on.&lt;/p&gt;
&lt;p&gt;At every launch, the VM&amp;rsquo;s setup makes &lt;code&gt;~/.claude/plugins&lt;/code&gt; a folder of the VM&amp;rsquo;s own when it isn&amp;rsquo;t one, replacing a link there, and it links &lt;code&gt;~/.claude/plugins-seed&lt;/code&gt; to the store&amp;rsquo;s folder. A VM made again with other layers keeps its own plugins folder, as it keeps the rest of its home.&lt;/p&gt;
&lt;p&gt;A store that devvm 0.1.0&amp;rsquo;s &lt;code&gt;devvm agent import&lt;/code&gt; wrote can hold the whole of &lt;code&gt;~/.claude/plugins&lt;/code&gt;, each plugin&amp;rsquo;s data included, and every VM with Claude Code mounts the store&amp;rsquo;s folder whole. So every start, before the VM runs, takes out of the store&amp;rsquo;s plugins folder each entry that a seed doesn&amp;rsquo;t have and warns once, naming them. It leaves the folder itself, so no VM&amp;rsquo;s mounts change and its Lima config needs no edit. A VM that&amp;rsquo;s already running stops seeing the entries through its mount at once on macOS, while on a Linux host, whose 9p mounts cache what the VM has read, it can keep seeing what it read until its next start. devvm reaches the folder from its config folder, every part of the path below it a folder, never a link, which only a hand-made store has and which the VM&amp;rsquo;s mount would follow, perhaps to your own &lt;code&gt;~/.claude/plugins&lt;/code&gt;. It takes a link among the entries out without following it, and it leaves the temporary files that a &lt;code&gt;devvm agent import&lt;/code&gt; or &lt;code&gt;devvm agent save&lt;/code&gt; running at the same time writes &lt;code&gt;known_marketplaces.json&lt;/code&gt; through. When it can&amp;rsquo;t take an entry out, or finds a link on the path, the start of a VM with Claude Code fails, naming the folder and what it should hold, rather than give the VM what it would read, and the start of any other VM warns.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;devvm agent import&lt;/code&gt; and &lt;code&gt;devvm agent save&lt;/code&gt; copy only what a seed has, so neither copies what each machine keeps of its own. The save&amp;rsquo;s script in the VM excludes, by name, every other entry of the VM&amp;rsquo;s &lt;code&gt;~/.claude/plugins&lt;/code&gt; when it&amp;rsquo;s a folder and not a link, and devvm saves nothing when the VM sends any other entry of it, as for any path outside the agents&amp;rsquo; settings. The VM&amp;rsquo;s folder holds only what the VM added to its seed, so the save adds the files that the VM&amp;rsquo;s folder has and changes those that differ, but it never takes a file out of the store&amp;rsquo;s folder. The save merges the VM&amp;rsquo;s &lt;code&gt;known_marketplaces.json&lt;/code&gt; into the store&amp;rsquo;s. It renames each path in the VM&amp;rsquo;s records that leads to the VM&amp;rsquo;s own plugins folder to the store&amp;rsquo;s folder, where every VM mounts it, and then each marketplace whose copy is in the store&amp;rsquo;s &lt;code&gt;marketplaces&lt;/code&gt;, by a path without &lt;code&gt;.&lt;/code&gt; or &lt;code&gt;..&lt;/code&gt; parts, replaces the store&amp;rsquo;s of the same name. The others stay as the store has them, because a seed can&amp;rsquo;t use them. They are the ones that Claude Code registered from the seed, whose copies are at the seed&amp;rsquo;s link, which are the store&amp;rsquo;s own, and those that Claude Code reads where they are, such as a folder in the VM. So a save that changes no marketplace leaves the file as it is. devvm leaves the file out with a warning when it isn&amp;rsquo;t a JSON object. The save&amp;rsquo;s script sends an entry whose name has a wildcard&amp;rsquo;s character, such as &lt;code&gt;*&lt;/code&gt;, rather than exclude it by a pattern that could match other names, so devvm then saves nothing, naming it.&lt;/p&gt;
&lt;p&gt;An export of a VM&amp;rsquo;s history leaves out the VM&amp;rsquo;s &lt;code&gt;~/.claude/plugins&lt;/code&gt;, and an import of one leaves out both it and &lt;code&gt;~/.claude/plugins-seed&lt;/code&gt;. The VM&amp;rsquo;s plugins folder holds settings, not history. The plugins it installed reach another VM only through &lt;code&gt;devvm agent save&lt;/code&gt;, after you read its diff, and each plugin&amp;rsquo;s data can hold the plugin&amp;rsquo;s own logins and large caches, which an export on this machine would keep. A new VM gets the store&amp;rsquo;s plugins from its seed again.&lt;/p&gt;
&lt;h2 data-hextra-search-id="copies"&gt;Copies&lt;span class="hx:absolute hx:-mt-20" id="copies"&gt;&lt;/span&gt;
&lt;a href="#copies" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;devvm merges the settings and MCP servers from the store&amp;rsquo;s &lt;code&gt;.claude.json&lt;/code&gt; into the VM&amp;rsquo;s own &lt;code&gt;~/.claude.json&lt;/code&gt;, so servers added in the VM stay (&lt;a href="https://next.devvm.dev/docs/internals/network/#mcp-servers"&gt;MCP servers&lt;/a&gt;). Your API key, your answers about API keys and your per-project entries never reach the VM. devvm also replaces the secrets in the agents&amp;rsquo; settings files with &lt;code&gt;devvm-redacted&lt;/code&gt;, and names what it replaced. Those are the values under keys that look like secrets, every env value and header, and the secrets in URLs and in arguments. In other text, such as a hook&amp;rsquo;s command, devvm replaces the secrets in its URLs, the keys that start like a known key, such as &lt;code&gt;sk-&lt;/code&gt; or &lt;code&gt;ghp_&lt;/code&gt;, and the credential after &lt;code&gt;Bearer&lt;/code&gt; or &lt;code&gt;Basic&lt;/code&gt;, and keeps the words around them (&lt;a href="https://next.devvm.dev/docs/internals/network/#keys-in-settings-files"&gt;keys in settings files&lt;/a&gt;). pi&amp;rsquo;s settings files that can hold a key are &lt;code&gt;settings.json&lt;/code&gt;, &lt;code&gt;models.json&lt;/code&gt; and &lt;code&gt;mcp.json&lt;/code&gt;, so a provider&amp;rsquo;s &lt;code&gt;apiKey&lt;/code&gt; in &lt;code&gt;models.json&lt;/code&gt; reaches the VM as &lt;code&gt;devvm-redacted&lt;/code&gt;, and pi&amp;rsquo;s &lt;code&gt;keybindings.json&lt;/code&gt; and Markdown files reach it as they are. From the &lt;code&gt;env&lt;/code&gt; of Claude Code&amp;rsquo;s &lt;code&gt;settings.json&lt;/code&gt;, the VM gets only Claude Code&amp;rsquo;s own settings, such as &lt;code&gt;ANTHROPIC_MODEL&lt;/code&gt;, the &lt;code&gt;CLAUDE_CODE_*&lt;/code&gt;, &lt;code&gt;DISABLE_*&lt;/code&gt; and &lt;code&gt;MAX_*&lt;/code&gt; variables and those ending in &lt;code&gt;_TIMEOUT_MS&lt;/code&gt;, but none whose name marks it as a credential, such as &lt;code&gt;ANTHROPIC_AUTH_TOKEN&lt;/code&gt;. It also gets the values that only name where a secret is, base URLs without their passwords, &lt;code&gt;true&lt;/code&gt;, &lt;code&gt;false&lt;/code&gt; and short numbers. Every other env value, and every env value of an MCP server, becomes &lt;code&gt;devvm-redacted&lt;/code&gt;. When devvm can&amp;rsquo;t parse a settings file to take its secrets out, the VM doesn&amp;rsquo;t get a copy of it, and neither does it get opencode&amp;rsquo;s files in &lt;code&gt;~/.config/opencode&lt;/code&gt; that are neither settings nor Markdown, such as a &lt;code&gt;.env&lt;/code&gt;. devvm names each file it doesn&amp;rsquo;t copy, and when it can&amp;rsquo;t make the copy of a login, it says why.&lt;/p&gt;
&lt;h2 data-hextra-search-id="opencodes-service"&gt;opencode&amp;rsquo;s service&lt;span class="hx:absolute hx:-mt-20" id="opencodes-service"&gt;&lt;/span&gt;
&lt;a href="#opencodes-service" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;opencode keeps its background service&amp;rsquo;s settings in &lt;code&gt;~/.config/opencode/service.json&lt;/code&gt;, or in &lt;code&gt;service-&amp;lt;channel&amp;gt;.json&lt;/code&gt; for a channel other than latest, dev, beta or next (an earlier build named it &lt;code&gt;service-&amp;lt;hash&amp;gt;.json&lt;/code&gt;), and it writes each one through a temporary file beside it, &lt;code&gt;&amp;lt;file&amp;gt;.&amp;lt;pid&amp;gt;.tmp&lt;/code&gt;. They hold the service&amp;rsquo;s password, 32 random bytes that the service makes when it starts and the file has none, and with remote access on, the route that the service is served on, a random name that keeps its address unguessable. So &lt;code&gt;opencode service get&lt;/code&gt; with no key hides both, and only &lt;code&gt;opencode service get password&lt;/code&gt; shows the password. They also hold the service&amp;rsquo;s port, host name, CORS origins and environment. That makes them each machine&amp;rsquo;s own rather than settings, so the import and the save leave out every entry of &lt;code&gt;~/.config/opencode&lt;/code&gt; with one of these names, what&amp;rsquo;s in a folder of that name included, and the save&amp;rsquo;s script in the VM never sends them, so the VM&amp;rsquo;s own file never makes a save fail. The VM&amp;rsquo;s file stays in the VM, so a VM made again keeps it, and no export of the VM&amp;rsquo;s history holds it, because &lt;code&gt;~/.config/opencode&lt;/code&gt; isn&amp;rsquo;t history.&lt;/p&gt;
&lt;p&gt;A store that an earlier import filled can hold them, so every start looks for them in the store&amp;rsquo;s &lt;code&gt;~/.config/opencode&lt;/code&gt;, which it opens as it opens &lt;a href="#claude-codes-plugins"&gt;Claude Code&amp;rsquo;s plugins&lt;/a&gt; folder, and once it finds any, it takes them out holding the store&amp;rsquo;s lock and warns once, naming them. No VM gets them from the store meanwhile, because a VM&amp;rsquo;s setup copies only the files that the import would copy, so a start whose clean-up fails only warns, naming the folder. devvm writes &lt;code&gt;devvm-redacted&lt;/code&gt; in place of a secret in every copy of a settings file that it makes, so a file with one of these names that holds it is a copy that devvm made, whose password every VM with such a copy shares. Each launch&amp;rsquo;s setup takes out each such regular file in the VM&amp;rsquo;s &lt;code&gt;~/.config/opencode&lt;/code&gt; and leaves the VM&amp;rsquo;s own files, links and folders, so the VM&amp;rsquo;s opencode makes its own password when its service next starts. A service that&amp;rsquo;s running keeps the password it started with until it stops, as when the VM restarts.&lt;/p&gt;
&lt;h2 data-hextra-search-id="claude-codes-login"&gt;Claude Code&amp;rsquo;s login&lt;span class="hx:absolute hx:-mt-20" id="claude-codes-login"&gt;&lt;/span&gt;
&lt;a href="#claude-codes-login" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm agent login claude&lt;/code&gt; runs Claude Code&amp;rsquo;s own login in the VM, and the VM&amp;rsquo;s proxy saves the login as it reaches Claude&amp;rsquo;s token endpoint, and Claude Code in the VM gets only placeholders. devvm then sets the VM up again, so it uses the login at once, and every other VM with Claude Code gets it from its next launch.&lt;/p&gt;
&lt;p&gt;A VM gets either &lt;code&gt;~/.claude/.credentials.json&lt;/code&gt; or &lt;code&gt;CLAUDE_CODE_OAUTH_TOKEN&lt;/code&gt; from devvm, never both, because Claude Code would use the token in its environment over the login in its file. A VM that started with the login devvm replaced keeps working, because its proxy puts the login devvm keeps now in place of either placeholder. The VM gets placeholders whatever its network tier.&lt;/p&gt;
&lt;p&gt;The VM&amp;rsquo;s setup merges devvm&amp;rsquo;s copy of the login into the VM&amp;rsquo;s own &lt;code&gt;~/.claude/.credentials.json&lt;/code&gt;, because Claude Code keeps more than its Claude login in that file, such as its logins to MCP servers under &lt;code&gt;mcpOAuth&lt;/code&gt;, which hold an MCP server&amp;rsquo;s tokens and, while a login is under way, its PKCE verifier. devvm sends its copy beside the setup as &lt;code&gt;claude-credentials.json&lt;/code&gt;, and the setup&amp;rsquo;s &lt;code&gt;merge_claude_credentials&lt;/code&gt; replaces the VM&amp;rsquo;s &lt;code&gt;claudeAiOauth&lt;/code&gt; with the copy&amp;rsquo;s, or takes it out when the copy has none, and keeps every other key of the VM&amp;rsquo;s file. It reads the file with &lt;code&gt;jq&lt;/code&gt; and writes the result whole, mode 600, to a temp file in &lt;code&gt;~/.cache&lt;/code&gt;, which neither an export of the VM&amp;rsquo;s history nor a VM made again carries, and then moves it over the file. When the VM&amp;rsquo;s file is a link, isn&amp;rsquo;t JSON or isn&amp;rsquo;t one JSON object, the copy replaces it and the setup says so, and a link is taken away first, so the move never writes through it. When it&amp;rsquo;s a folder, the setup leaves it as it is and says so. When the move fails, the setup removes the temp file and fails. A write that Claude Code makes to the file between the setup&amp;rsquo;s read and its move, such as a login to an MCP server that finishes in those milliseconds, is lost, and you make that login again. With a Claude Code token, devvm sends no copy, so the VM&amp;rsquo;s file stays as it is. Claude Code uses the token in its environment over any login left in the file, and that login&amp;rsquo;s placeholder gets the token at &lt;code&gt;api.anthropic.com&lt;/code&gt; and nothing at &lt;code&gt;mcp-proxy.anthropic.com&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/network/#logins-made-in-a-vm"&gt;logins made in a VM&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The MCP servers&amp;rsquo; logins stay in the VM. &lt;code&gt;devvm agent save&lt;/code&gt; reads only the settings, an export of the VM&amp;rsquo;s history leaves &lt;code&gt;~/.claude/.credentials.json&lt;/code&gt; out and an import never writes it, and a VM made again doesn&amp;rsquo;t get it, so nothing of the VM&amp;rsquo;s file reaches devvm&amp;rsquo;s store, this machine or another VM. Only the store&amp;rsquo;s copy goes into the file, and it holds the placeholders alone.&lt;/p&gt;
&lt;h2 data-hextra-search-id="codexs-and-opencodes-logins"&gt;Codex&amp;rsquo;s and opencode&amp;rsquo;s logins&lt;span class="hx:absolute hx:-mt-20" id="codexs-and-opencodes-logins"&gt;&lt;/span&gt;
&lt;a href="#codexs-and-opencodes-logins" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The proxy reads the real API keys and logins from the login files in devvm&amp;rsquo;s store as it needs them and refreshes ChatGPT logins there. The proxy puts in opencode&amp;rsquo;s API keys for the providers that &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#api-keys-the-proxy-puts-in"&gt;API keys the proxy puts in&lt;/a&gt; lists, and its OpenAI and GitHub Copilot logins. The VM&amp;rsquo;s entry for such an API key holds only its type and the placeholder, so the entry&amp;rsquo;s other fields, such as its &lt;code&gt;metadata&lt;/code&gt;, stay on this machine.&lt;/p&gt;
&lt;p&gt;The VM&amp;rsquo;s copy of Codex&amp;rsquo;s &lt;code&gt;auth.json&lt;/code&gt; holds only what Codex needs for its API key and its ChatGPT login: the placeholders, how it logs in, when it last refreshed, and the IDs of the account and the login. devvm keeps every other field on this machine, because the VM&amp;rsquo;s proxy can&amp;rsquo;t put it in, and it names those fields at every launch. That includes Codex&amp;rsquo;s other ways to log in, such as a personal access token or an Amazon Bedrock key, so Codex in a VM can&amp;rsquo;t use them. devvm treats Claude Code&amp;rsquo;s account state in &lt;code&gt;~/.claude.json&lt;/code&gt; the same way, so the VM gets only the account fields that Claude Code writes there today, and devvm names any other field at every launch.&lt;/p&gt;
&lt;p&gt;devvm keeps every other entry of opencode&amp;rsquo;s &lt;code&gt;auth.json&lt;/code&gt; on this machine too, because devvm doesn&amp;rsquo;t know which hosts it&amp;rsquo;s for, so the VM gets that entry without its key or its tokens, and devvm warns you about each at every launch. That&amp;rsquo;s an API key for any other provider, such as Azure&amp;rsquo;s or a local model server&amp;rsquo;s, a well-known login, which an organization&amp;rsquo;s own opencode config sets up, and any other OAuth login, such as Copilot Enterprise&amp;rsquo;s. The VM keeps only the fields of a withheld entry that name the account or how it logs in, such as its type, its &lt;code&gt;enterpriseUrl&lt;/code&gt; and its expiry, so opencode in the VM doesn&amp;rsquo;t use that provider.&lt;/p&gt;
&lt;h2 data-hextra-search-id="logging-in"&gt;Logging in&lt;span class="hx:absolute hx:-mt-20" id="logging-in"&gt;&lt;/span&gt;
&lt;a href="#logging-in" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When you approve a browser login, the browser comes back to &lt;code&gt;localhost:1455&lt;/code&gt;, where the agent&amp;rsquo;s own server in the VM waits, so devvm forwards this machine&amp;rsquo;s &lt;code&gt;localhost:1455&lt;/code&gt;, and &lt;code&gt;localhost:1457&lt;/code&gt;, which Codex uses when 1455 is taken in the VM, to the same ports in the VM. The forward lasts only while the login runs, and it ends when the login ends, fails or you press Ctrl+C, which ends the agent&amp;rsquo;s login in the VM too.&lt;/p&gt;
&lt;p&gt;Codex in a VM keeps its login in &lt;code&gt;~/.codex/auth.json&lt;/code&gt;, never in a keyring, because devvm sets &lt;code&gt;cli_auth_credentials_store = &amp;quot;file&amp;quot;&lt;/code&gt; in the VM&amp;rsquo;s &lt;code&gt;~/.codex/config.toml&lt;/code&gt; on every launch.&lt;/p&gt;
&lt;p&gt;With &lt;code&gt;--api-key&lt;/code&gt;, devvm gives the running VM its copy of the login, with a placeholder in place of the key, and the VM&amp;rsquo;s proxy puts the key in at once. opencode keeps its logins in its own database in the VM, and it reads its &lt;code&gt;auth.json&lt;/code&gt; only when it first makes that database, so when opencode has already run in the VM, devvm also gives it the key&amp;rsquo;s placeholder with &lt;code&gt;opencode auth import&lt;/code&gt;. devvm reads at most 1 MiB of what that import prints in the VM, and when it prints more, devvm stops it and fails, so running devvm in the VM&amp;rsquo;s folder tries again. Every other VM with opencode gets the key&amp;rsquo;s placeholder at its next launch, the same way, and any credentials that you added to opencode in a VM yourself stay in its database.&lt;/p&gt;
&lt;h2 data-hextra-search-id="logins-made-in-a-vm"&gt;Logins made in a VM&lt;span class="hx:absolute hx:-mt-20" id="logins-made-in-a-vm"&gt;&lt;/span&gt;
&lt;a href="#logins-made-in-a-vm" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When Codex or opencode in a VM logs in to OpenAI, whether &lt;code&gt;devvm agent login&lt;/code&gt; runs it or you run it yourself, the VM&amp;rsquo;s proxy saves the login in devvm&amp;rsquo;s store, in the agent&amp;rsquo;s own &lt;code&gt;auth.json&lt;/code&gt;, and the agent in the VM gets only placeholders, so on every tier but open the VM never holds the login&amp;rsquo;s tokens. The VM you logged in from uses the login at once, and every VM with that agent gets it from its next launch. opencode reads its &lt;code&gt;auth.json&lt;/code&gt; only when it first makes its database, so in a VM where opencode has already run, devvm adds the store&amp;rsquo;s logins to opencode&amp;rsquo;s database at each launch when they changed since the VM last got them, and makes them the ones opencode uses. Credentials that you added to opencode in the VM yourself stay in its database, labeled with your names rather than devvm, and &lt;code&gt;opencode auth switch&lt;/code&gt; changes back to one of them. A login that shows a code to type into a browser on any machine works in a VM as it is, such as &lt;code&gt;codex login --device-auth&lt;/code&gt; and opencode&amp;rsquo;s Codex device code login. opencode&amp;rsquo;s Sign in with ChatGPT doesn&amp;rsquo;t work in a VM, because it gets its tokens from another endpoint, whose replies the VM&amp;rsquo;s proxy refuses so that they never reach the VM, so choose one of opencode&amp;rsquo;s Codex logins instead, as &lt;code&gt;devvm agent login opencode&lt;/code&gt; does. A new login replaces the one in the store, together with Codex&amp;rsquo;s API key, so every VM with the agent uses the account you logged in to last. A VM saves a login only for an agent that it has, so a VM without Codex can&amp;rsquo;t replace the store&amp;rsquo;s Codex login, and a VM without opencode can&amp;rsquo;t replace opencode&amp;rsquo;s. When a VM sends a login for an agent it doesn&amp;rsquo;t have, such as one that a program installed in the VM itself, its proxy refuses the login, devvm saves nothing, and the proxy&amp;rsquo;s own log says so. In a VM with both Codex and opencode, devvm tells their logins apart by the program that sends them. &lt;code&gt;devvm network log&lt;/code&gt; shows a &lt;code&gt;login&lt;/code&gt; line for each login it saved. On the open tier, a program that goes around the VM&amp;rsquo;s proxy gets the login&amp;rsquo;s tokens itself, and devvm saves nothing (&lt;a href="https://next.devvm.dev/docs/internals/network/#logins-made-in-a-vm"&gt;logins made in a VM&lt;/a&gt;). Claude Code&amp;rsquo;s logins in a VM are saved in the same way (&lt;a href="https://next.devvm.dev/docs/using/coding-agents/#claude-code-login"&gt;Claude Code login&lt;/a&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="pis-logins"&gt;pi&amp;rsquo;s logins&lt;span class="hx:absolute hx:-mt-20" id="pis-logins"&gt;&lt;/span&gt;
&lt;a href="#pis-logins" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;devvm agent login pi --api-key --provider PROVIDER&lt;/code&gt; saves the key in the store&amp;rsquo;s &lt;code&gt;~/.local/share/devvm/logins/pi/.pi/agent/auth.json&lt;/code&gt;, in pi&amp;rsquo;s own format, beside pi&amp;rsquo;s other providers, as opencode&amp;rsquo;s &lt;code&gt;--api-key&lt;/code&gt; does (&lt;a href="https://next.devvm.dev/docs/using/coding-agents/#logging-in-with-devvm-agent-login"&gt;logging in with devvm agent login&lt;/a&gt;). The VM&amp;rsquo;s &lt;code&gt;~/.pi/agent/auth.json&lt;/code&gt; holds a placeholder in place of each of those keys, and the VM&amp;rsquo;s proxy puts the key into pi&amp;rsquo;s requests to that provider&amp;rsquo;s hosts, on every network tier, and allows those hosts, as the table in &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#api-keys-the-proxy-puts-in"&gt;API keys the proxy puts in&lt;/a&gt; describes. The VM&amp;rsquo;s entry for such a provider holds only its type and the placeholder, so it gets none of the entry&amp;rsquo;s other fields, such as its &lt;code&gt;env&lt;/code&gt;, whose values pi uses before the environment&amp;rsquo;s, and the store keeps them on this machine.&lt;/p&gt;
&lt;p&gt;devvm keeps every other entry of pi&amp;rsquo;s &lt;code&gt;auth.json&lt;/code&gt; on this machine too, and the VM gets that entry without its key, its &lt;code&gt;env&lt;/code&gt; or its tokens, and devvm warns you about each. That&amp;rsquo;s an API key for any other provider, such as a local model server&amp;rsquo;s, a key that&amp;rsquo;s a command for pi to run, such as &lt;code&gt;!security find-generic-password&lt;/code&gt;, and a key that pi fills in from a variable, such as &lt;code&gt;$KEY&lt;/code&gt; or &lt;code&gt;${KEY}&lt;/code&gt;, even for a provider whose key the proxy puts in, because devvm can&amp;rsquo;t tell what pi would send. The VM keeps only the fields of a withheld entry that name the account or how it logs in, such as its type, its &lt;code&gt;accountId&lt;/code&gt; and its expiry.&lt;/p&gt;
&lt;p&gt;pi&amp;rsquo;s Claude and ChatGPT logins use the same token endpoints as Claude Code&amp;rsquo;s, Codex&amp;rsquo;s and opencode&amp;rsquo;s logins, whose replies the VM&amp;rsquo;s proxy captures for those agents, and devvm never keeps such a login as pi&amp;rsquo;s. In a VM that also has the matching agent, Claude Code for a Claude login and Codex or opencode for a ChatGPT login, the proxy saves pi&amp;rsquo;s login as that agent&amp;rsquo;s own, in place of the one devvm keeps for every VM with that agent. In a VM with none of them, the proxy refuses pi&amp;rsquo;s login and devvm saves nothing (&lt;a href="#logins-made-in-a-vm"&gt;logins made in a VM&lt;/a&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="cursors-cli"&gt;Cursor&amp;rsquo;s CLI&lt;span class="hx:absolute hx:-mt-20" id="cursors-cli"&gt;&lt;/span&gt;
&lt;a href="#cursors-cli" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The VM&amp;rsquo;s proxy puts the real login only into the requests for the methods that devvm found the CLI calling in its package, on Cursor&amp;rsquo;s API, its agent&amp;rsquo;s hosts and its codebase indexing, and into no other. It refuses every other request below &lt;code&gt;/auth/&lt;/code&gt; on those hosts, the methods that make or show a key, a token, a secret or a sign-in, the methods that change your account, and any path it can&amp;rsquo;t read as Cursor&amp;rsquo;s hosts do. Those are the real control. As a defence in depth, the proxy also reads every reply from those hosts as it passes, its headers and the agent&amp;rsquo;s streams included, and cuts one off where a token starts. devvm checked this against one release of the CLI, by reading its code, and against Cursor&amp;rsquo;s own answers to a login that isn&amp;rsquo;t there, so a method that Cursor adds that hands out a token in a shape devvm doesn&amp;rsquo;t know would reach the VM. Such a token would work without the proxy, so if you suspect that one reached a VM, log in again with &lt;code&gt;devvm agent login cursor&lt;/code&gt; (&lt;a href="https://next.devvm.dev/docs/internals/network/#logins-made-in-a-vm"&gt;logins made in a VM&lt;/a&gt;). Neither does devvm guard Cursor&amp;rsquo;s hosts that the CLI doesn&amp;rsquo;t use: if one of them also answered &lt;code&gt;/auth/poll&lt;/code&gt;, a VM could finish a login there and keep its tokens, though none is known to.&lt;/p&gt;
&lt;p&gt;Your Cursor agents on every machine and in the cloud share Cursor&amp;rsquo;s agent store, your cloud agents follow the skills in it, and your team shares a store of its own, so a VM that could write there could leave instructions for them. So no VM gets the store (&lt;a href="https://next.devvm.dev/docs/internals/network/#logins-made-in-a-vm"&gt;why&lt;/a&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="api-keys"&gt;API keys&lt;span class="hx:absolute hx:-mt-20" id="api-keys"&gt;&lt;/span&gt;
&lt;a href="#api-keys" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The proxy puts in opencode&amp;rsquo;s and pi&amp;rsquo;s API keys for the providers that &lt;a href="https://next.devvm.dev/docs/using/coding-agents/#api-keys-the-proxy-puts-in"&gt;API keys the proxy puts in&lt;/a&gt; lists, in the headers it names. OpenRouter&amp;rsquo;s key goes in either of its two headers, because pi sends it in &lt;code&gt;x-api-key&lt;/code&gt; for OpenRouter&amp;rsquo;s Anthropic models, as Anthropic&amp;rsquo;s own API takes a key, and in &lt;code&gt;Authorization&lt;/code&gt; for every other model. The proxy swaps the placeholder only when the header holds the placeholder and nothing else, or for &lt;code&gt;Authorization&lt;/code&gt;, &lt;code&gt;Bearer&lt;/code&gt;, one space and the placeholder, which is how opencode and pi send each of these keys. A header that holds anything else beside the placeholder, or a second header of the same name, keeps the placeholder, so code in the VM can&amp;rsquo;t surround your key with text of its own, which a provider that quotes part of a key it refuses could show back to it.&lt;/p&gt;
&lt;p&gt;The placeholder for an OpenAI key starts with &lt;code&gt;sk-&lt;/code&gt;, as an OpenAI API key does, because pi takes an OpenAI key that starts any other way for a Sign in with ChatGPT login and then leaves settings such as the longest reply it wants out of its requests.&lt;/p&gt;
&lt;p&gt;The placeholder keeps a key out of the VM only from the launch that first gives the VM the placeholder. A VM that was given one of these keys as it was before then, such as through &lt;code&gt;[pass-keys]&lt;/code&gt; when the proxy didn&amp;rsquo;t put that provider&amp;rsquo;s key in, may still hold copies of it. They can be in opencode&amp;rsquo;s database, its write-ahead log and its freed pages, in the disk&amp;rsquo;s free space and anywhere that the VM&amp;rsquo;s own code copied the key. While opencode in the VM fails to import the placeholder, devvm&amp;rsquo;s record of opencode&amp;rsquo;s last import, &lt;code&gt;~/.local/state/devvm/opencode-import.json&lt;/code&gt;, holds the key too.&lt;/p&gt;
&lt;p&gt;With some of these keys, code in the VM can make a credential of its own that works without the proxy. Google Gemini&amp;rsquo;s key gets an ephemeral token for Gemini&amp;rsquo;s Live API, which lasts up to about 20 hours and allows as many uses as the VM asks for. xAI&amp;rsquo;s key gets a realtime client secret that lasts as long as the VM chooses, and OpenAI&amp;rsquo;s key gets one that lasts up to 2 hours. opencode&amp;rsquo;s experimental voice mode asks for these itself, so the proxy allows those requests (&lt;a href="https://next.devvm.dev/docs/safety/attack-vectors/#secrets-and-keys-the-vm-may-use"&gt;attack vectors&lt;/a&gt;). Some of these providers&amp;rsquo; own tools also fetch the URLs that a request names, such as Google Gemini&amp;rsquo;s URL context and Search grounding, xAI&amp;rsquo;s live search, Groq&amp;rsquo;s compound models and Mistral&amp;rsquo;s agents with web search, so code in the VM can reach hosts that the allowlist doesn&amp;rsquo;t have through them, as it can through Anthropic&amp;rsquo;s and OpenAI&amp;rsquo;s.&lt;/p&gt;
&lt;h2 data-hextra-search-id="history-exports"&gt;History exports&lt;span class="hx:absolute hx:-mt-20" id="history-exports"&gt;&lt;/span&gt;
&lt;a href="#history-exports" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The agents&amp;rsquo; logins aren&amp;rsquo;t in the export, which leaves out &lt;code&gt;~/.claude/.credentials.json&lt;/code&gt;, &lt;code&gt;~/.codex/auth.json&lt;/code&gt;, and opencode&amp;rsquo;s &lt;code&gt;auth.json&lt;/code&gt;, &lt;code&gt;account.json&lt;/code&gt;, &lt;code&gt;mcp-auth.json&lt;/code&gt; and &lt;code&gt;bin&lt;/code&gt;, and holds nothing of &lt;code&gt;~/.pi/agent&lt;/code&gt; but its sessions, so pi&amp;rsquo;s &lt;code&gt;auth.json&lt;/code&gt; stays out too. It leaves out the VM&amp;rsquo;s &lt;code&gt;~/.claude/plugins&lt;/code&gt;, which holds settings and each plugin&amp;rsquo;s data rather than history (&lt;a href="#claude-codes-plugins"&gt;Claude Code&amp;rsquo;s plugins&lt;/a&gt;). It also leaves out what of &lt;code&gt;~/.local/state/opencode&lt;/code&gt; is the VM&amp;rsquo;s own as a machine:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;its &lt;code&gt;machine&lt;/code&gt; folder, whose &lt;code&gt;home-key&lt;/code&gt; is the private key that every machine opencode pairs with &lt;code&gt;opencode machine add&lt;/code&gt; trusts&lt;/li&gt;
&lt;li&gt;its &lt;code&gt;service.json&lt;/code&gt;, or &lt;code&gt;service-&amp;lt;channel&amp;gt;.json&lt;/code&gt; for another channel&amp;rsquo;s opencode, which holds the password of opencode&amp;rsquo;s background service, and the handoff tickets and temporary files that opencode writes beside it&lt;/li&gt;
&lt;li&gt;its &lt;code&gt;pty&lt;/code&gt; folder, which holds the sockets of its terminals&amp;rsquo; daemons and their access tokens&lt;/li&gt;
&lt;li&gt;its &lt;code&gt;plugin-approvals.json&lt;/code&gt;, with its lock and the temporary files it&amp;rsquo;s written through, which holds the project plugins you approved in opencode&amp;rsquo;s native client, which doesn&amp;rsquo;t ship in opencode 2.4.1&lt;/li&gt;
&lt;li&gt;its &lt;code&gt;plugin-staged&lt;/code&gt; folder, the approved plugins&amp;rsquo; copies, which that client runs without checking their hash again, so an export would otherwise approve a plugin for another VM&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The copy of opencode&amp;rsquo;s database leaves out its &lt;code&gt;machine&lt;/code&gt; table too, which holds the public keys that the machines it paired log in to it with. An import never writes them either, so the new VM&amp;rsquo;s opencode makes its own, and a VM made again keeps the VM&amp;rsquo;s own, because it&amp;rsquo;s the same machine (&lt;a href="https://next.devvm.dev/docs/using/images/#what-a-vm-made-again-keeps"&gt;what a VM made again keeps&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;opencode keeps its sessions and its logins together in one database, &lt;code&gt;~/.local/share/opencode/opencode.db&lt;/code&gt;, so the export holds a copy of that database without its logins. The VM makes the copy with &lt;code&gt;sqlite3&lt;/code&gt;, which every base image has, and the copy has no logins, API keys or opencode account in any part of the file, not even a key you typed into opencode in the VM, while the VM&amp;rsquo;s own database keeps them (&lt;a href="https://next.devvm.dev/docs/contributing/design/#opencodes-database-in-history-exports"&gt;how&lt;/a&gt;). The copy also leaves out what opencode 2.4 would act on without asking in the VM that imports it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;its &lt;code&gt;automation&lt;/code&gt; table, because opencode runs each automation&amp;rsquo;s shell command on its schedule or event without asking again&lt;/li&gt;
&lt;li&gt;its &lt;code&gt;permission&lt;/code&gt; table, the requests you said always to allow&lt;/li&gt;
&lt;li&gt;its &lt;code&gt;job&lt;/code&gt; table, the subagents&amp;rsquo; jobs, and its &lt;code&gt;session_inbox&lt;/code&gt; table, the messages queued for a session&amp;rsquo;s next turn, because opencode&amp;rsquo;s service starts those jobs and turns when it starts&lt;/li&gt;
&lt;li&gt;each session&amp;rsquo;s allow rules, as the session keeps only the deny and ask rules of its permission rules&lt;/li&gt;
&lt;li&gt;each suspended session&amp;rsquo;s mark, so no session resumes its turn on its own&lt;/li&gt;
&lt;li&gt;each project&amp;rsquo;s commands, whose start command opencode runs for each worktree it makes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The export also leaves out opencode&amp;rsquo;s git repositories in &lt;code&gt;~/.local/share/opencode&lt;/code&gt;, which are &lt;code&gt;snapshot&lt;/code&gt;, &lt;code&gt;repos&lt;/code&gt; and &lt;code&gt;worktree&lt;/code&gt;, because a repository&amp;rsquo;s config can name a command that git runs, and opencode&amp;rsquo;s own git commands would run it in the VM that imports it. So the export doesn&amp;rsquo;t hold opencode&amp;rsquo;s worktrees, and the work in them stays in the VM, which a VM made again keeps and &lt;code&gt;devvm rm&lt;/code&gt; deletes, after it checks them (&lt;a href="#opencodes-worktrees"&gt;opencode&amp;rsquo;s worktrees&lt;/a&gt;). Their commits are in the project&amp;rsquo;s own repository. A view or a generated column in the database could hide rows from these steps, so the copy drops every view, and it fails its check when a table has a generated column. The export never holds the database&amp;rsquo;s &lt;code&gt;-wal&lt;/code&gt;, &lt;code&gt;-shm&lt;/code&gt; or &lt;code&gt;-journal&lt;/code&gt; files, which can hold logins that opencode saved last. When the VM has no &lt;code&gt;sqlite3&lt;/code&gt;, such as a VM made from an image built without it, the export leaves the database out, so opencode&amp;rsquo;s sessions aren&amp;rsquo;t in it, and the run log says so. It does the same when the VM&amp;rsquo;s &lt;code&gt;sqlite3&lt;/code&gt; can&amp;rsquo;t read JSON, which the sessions&amp;rsquo; rules are. devvm starts a stopped VM for the export as a launch does, so it locks the folder&amp;rsquo;s &lt;code&gt;.git&lt;/code&gt; again and checks the VM&amp;rsquo;s confinement first, and the VM stays running. devvm writes the file only once the export is complete, so a failed export leaves no file and leaves an existing FILE as it was. An export holds at most 2 GiB, because a VM could otherwise write until this machine&amp;rsquo;s disk is full. When the VM sends more, devvm stops the export and keeps nothing of it, so &lt;code&gt;devvm history export&lt;/code&gt; fails, while &lt;code&gt;devvm rm&lt;/code&gt; and the commands that make a VM again warn that they kept no export and go on without one. Only you can read the file, and devvm makes the exports folder yours alone each time it writes one there, whatever its mode was before. When FILE is in a folder of your own, that folder keeps its mode. If the export fails, &lt;code&gt;devvm rm&lt;/code&gt; keeps the VM, and &lt;code&gt;devvm rm --no-export&lt;/code&gt; deletes it without exporting. &lt;code&gt;devvm rm VM&lt;/code&gt;, for a VM whose folder is gone, exports in the same way, but only from a running VM or a &lt;code&gt;--clone&lt;/code&gt; VM, because starting any other would make its folder again (&lt;a href="https://next.devvm.dev/docs/using/vms/#a-vm-whose-folder-is-gone"&gt;a VM whose folder is gone&lt;/a&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="opencodes-worktrees"&gt;opencode&amp;rsquo;s worktrees&lt;span class="hx:absolute hx:-mt-20" id="opencodes-worktrees"&gt;&lt;/span&gt;
&lt;a href="#opencodes-worktrees" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;opencode 2.4 makes each worktree with &lt;code&gt;git worktree add&lt;/code&gt;, in &lt;code&gt;~/.local/share/opencode/worktree/&amp;lt;project&amp;gt;/&amp;lt;name&amp;gt;&lt;/code&gt;, where &lt;code&gt;&amp;lt;project&amp;gt;&lt;/code&gt; is the first six characters of the project&amp;rsquo;s ID in opencode. Because an export leaves that folder out, &lt;code&gt;devvm rm&lt;/code&gt;, and a command that makes the VM again with &lt;code&gt;--clean-home&lt;/code&gt;, read the worktrees there before the VM&amp;rsquo;s disk goes. devvm runs one command in the running VM, in its home folder, which finds each folder at that depth with a &lt;code&gt;.git&lt;/code&gt; in it, those whose names start with a dot too, and prints, for each one, its path, its &lt;code&gt;git status --porcelain&lt;/code&gt;, and the commit its HEAD is detached at when no branch, tag or remote-tracking branch in the VM has that commit. A worktree whose &lt;code&gt;git status&lt;/code&gt; fails counts as one with changes, because the VM still has its files. The command looks at 100 worktrees at most and says when there are more. devvm reads at most 8 MiB of its answer and stops the command once it sends more, and it waits at most 2 minutes for the answer, so a VM that answers without end, or never, can&amp;rsquo;t keep &lt;code&gt;devvm rm&lt;/code&gt; waiting.&lt;/p&gt;
&lt;p&gt;The answer comes from the VM, so devvm checks it before it shows any of it. Each record must be whole, each path must be a clean path below the home folder that opencode&amp;rsquo;s pattern matches, each worktree must appear once and be followed by its status, and there can be no more than 100 of them. An answer that breaks any of these, a command that fails, an answer over the limit or one that doesn&amp;rsquo;t come in time keeps the VM, because the VM may hold work devvm can&amp;rsquo;t see, and devvm names &lt;code&gt;--no-worktree-check&lt;/code&gt;. A path or a change devvm shows goes through the same filter as every message, which drops the characters that would move the cursor or hide text. The VM can still leave a worktree out of its answer, which hides only its own work. For a &lt;code&gt;--clone&lt;/code&gt; VM, the same question covers the clone check&amp;rsquo;s findings, so devvm asks once.&lt;/p&gt;
&lt;p&gt;devvm checks only that folder. A worktree that opencode&amp;rsquo;s &lt;code&gt;worktree.directory&lt;/code&gt; setting puts elsewhere in the VM&amp;rsquo;s home folder isn&amp;rsquo;t checked, and it goes with the VM as any other file there does. One that the setting puts in the project folder is on this machine for a VM that mounts it, and in the clone for a &lt;code&gt;--clone&lt;/code&gt; VM, whose check covers the worktrees inside its folder (&lt;a href="https://next.devvm.dev/docs/using/clone/#deleting-the-vm"&gt;deleting the VM&lt;/a&gt;).&lt;/p&gt;
&lt;h2 data-hextra-search-id="importing-history"&gt;Importing history&lt;span class="hx:absolute hx:-mt-20" id="importing-history"&gt;&lt;/span&gt;
&lt;a href="#importing-history" class="subheading-anchor" aria-label="Permalink for this section"&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The import works on every VM, whether its base is Ubuntu&amp;rsquo;s image or a Debian-, Ubuntu- or Alpine-based container image (&lt;a href="https://next.devvm.dev/docs/using/from/"&gt;starting from a container image&lt;/a&gt;), because it unpacks the export with GNU &lt;code&gt;tar&lt;/code&gt;, which Debian and Ubuntu always have and which devvm installs in every base made &lt;code&gt;--from alpine&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;An export holds what a VM wrote, so devvm treats it as untrusted. Its transcripts can hold what the old VM&amp;rsquo;s agents read, and a VM on a less strict tier reaches more, such as your local network on the open tier. So when the export comes from a VM on a less strict tier than the VM you import it into, going from open to internet, allowlist and none, devvm warns you before it imports. devvm knows an export&amp;rsquo;s tier only from the &lt;code&gt;.folder&lt;/code&gt; file beside it in &lt;code&gt;~/.local/share/devvm/exports&lt;/code&gt;, so it warns about an export with no tier recorded, or any FILE elsewhere, such as in the project folder that a VM can write, as if it came from an open VM. devvm never unpacks an export on this machine. It streams the file into the VM as it is, and the VM&amp;rsquo;s own &lt;code&gt;tar&lt;/code&gt; unpacks it there as the VM&amp;rsquo;s user, so it can only write what that user can write. Before unpacking anything, the VM lists the paths in the export, and when one of them is outside &lt;!-- the agents' history, generated from internal/agents by mise run cli-docs --&gt;&lt;code&gt;~/.claude&lt;/code&gt;, &lt;code&gt;~/.claude.json&lt;/code&gt;, &lt;code&gt;~/.codex&lt;/code&gt;, &lt;code&gt;~/.local/share/opencode&lt;/code&gt;, &lt;code&gt;~/.local/state/opencode&lt;/code&gt;, &lt;code&gt;~/.pi/agent/sessions&lt;/code&gt; and &lt;code&gt;~/.cursor/chats&lt;/code&gt;&lt;!-- end of the agents' history --&gt;, starts with &lt;code&gt;/&lt;/code&gt; or has a &lt;code&gt;.&lt;/code&gt;, &lt;code&gt;..&lt;/code&gt; or empty part, such as &lt;code&gt;.claude/./plugins&lt;/code&gt; or &lt;code&gt;.claude//plugins&lt;/code&gt;, devvm imports nothing and says so, because &lt;code&gt;tar&lt;/code&gt; matches the paths it leaves out against each name as the export writes it. Once it has unpacked the export, it also deletes each of those paths by its path, whatever name put a file there. It leaves out of that check, and never unpacks, the AppleDouble files whose names start with &lt;code&gt;._&lt;/code&gt;, which macOS&amp;rsquo;s &lt;code&gt;tar&lt;/code&gt; puts beside each file that has extended attributes, so an export you packed yourself on a Mac imports. The import keeps no owner or mode from the export, so the VM user&amp;rsquo;s umask applies and no file is set-user-ID. It also takes out every symbolic link that points outside the folder it&amp;rsquo;s in, which is any link to an absolute path or one with a &lt;code&gt;..&lt;/code&gt; part, so an agent writing to a session file can&amp;rsquo;t follow a link out of its history. An export that devvm didn&amp;rsquo;t write, such as a &lt;code&gt;.tar.gz&lt;/code&gt; you made yourself, can hold opencode&amp;rsquo;s database with its logins, so the import takes out the database&amp;rsquo;s &lt;code&gt;-wal&lt;/code&gt;, &lt;code&gt;-shm&lt;/code&gt; and &lt;code&gt;-journal&lt;/code&gt; files and puts in a copy of the database without its logins or what opencode would act on without asking, as the export makes it (&lt;a href="#history-exports"&gt;history exports&lt;/a&gt;), or leaves the database out when the VM has no &lt;code&gt;sqlite3&lt;/code&gt;. It never writes opencode&amp;rsquo;s git repositories either. opencode in the new VM then reads the logins that devvm gave the VM, as it does when it first makes its database. When the VM already has an opencode database, it keeps its own, and opencode&amp;rsquo;s sessions from the export aren&amp;rsquo;t imported.&lt;/p&gt;</description></item></channel></rss>